Just the backend of the plugin system.
16
.gitignore
vendored
@ -1,12 +1,6 @@
|
||||
build/*
|
||||
*.cbp
|
||||
*.elf
|
||||
*.cscope_file_list
|
||||
*.layout
|
||||
screenshots/*
|
||||
release/*
|
||||
*.mod
|
||||
*.id*
|
||||
*.nam
|
||||
*.til
|
||||
*.layout
|
||||
*.rpx
|
||||
*.bin
|
||||
hook.h
|
||||
build/
|
||||
*.cbp
|
||||
|
4
.gitmodules
vendored
@ -1,4 +0,0 @@
|
||||
[submodule "src/mocha"]
|
||||
path = src/mocha
|
||||
url = https://github.com/Maschell/mocha
|
||||
branch = sd_access
|
43
.travis.yml
@ -1,43 +0,0 @@
|
||||
sudo: required
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
services:
|
||||
- docker
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- p7zip-full
|
||||
|
||||
before_script:
|
||||
- docker build . -t wups-loader-builder
|
||||
script:
|
||||
- docker run -it --rm -v ${PWD}:/project wups-loader-builder make
|
||||
before_deploy:
|
||||
- cd $TRAVIS_BUILD_DIR/
|
||||
- mkdir -p "wiiu/apps/wiiupluginloader"
|
||||
- commit="$(git rev-parse --short=7 HEAD)"
|
||||
- chmod +x gitrev.sh
|
||||
- versiontag="$(./gitrev.sh)"
|
||||
- docker run -it --rm -v ${PWD}:/project wups-loader-builder make
|
||||
- cp meta/* wiiu/apps/wiiupluginloader
|
||||
- cp wiiupluginloader.elf wiiu/apps/wiiupluginloader
|
||||
- zip -r WiiUPluginLoader_$versiontag.zip wiiu
|
||||
- git config --global user.email "builds@travis-ci.com"
|
||||
- git config --global user.name "Travis CI"
|
||||
- export GIT_TAG=WiiUPluginLoader-$versiontag
|
||||
- commitLog="$(git log -1 --pretty=%B)"
|
||||
- commitMessage="$(echo -e "-\n" && echo "WiiUPluginLoader nightly build. Not a stable release. Expect bugs!\n Only use the plugins with the bundled loaded as they may not work on others." && echo -e "\nCommitlog:\n")"
|
||||
- git tag $GIT_TAG -a -m "$commitMessage" -m "$commitLog"
|
||||
- git push --quiet https://$GITHUBKEY@github.com/Maschell/WiiUPluginLoader $GIT_TAG > /dev/null 2>&1
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
skip_cleanup: true
|
||||
prerelease: true
|
||||
api_key:
|
||||
secure: X2kG+KU92Z1G4nMNIycVWk1nvKjfmDlyyh0rYIKbpt2JmvBv/fO4v6oPrVVec7Zc3m42VeqFdjrCn0VatBwNkW9TLjGCysvZrUh2BOgA8cIfJvnt54bckbdbt4DgN6H/QAW7pHVjv6eDZLH4IhBIaxSDN60mhAu2Aa7cZdkkBrHeKwks+fztBNvOYqPcOgxWQbLtN2e9LBk+0tt6n64/Z5F37ydTXm5B8LSI5oEPifPWYfycqmEFxKJUIRPr149Iz62nET/aMC9fUOCjjTOS9k/J0NVuhD/433dto60OUXWGKrMSwfz1hP7HIChgEvxWeczSZP2MczcKm+jZgLK7ML7nIwBIMQovNb8qXdLfRY//IbGYTTjA/4efJ/Przpahry2/5JTAtWxVpfkjXNsajSFFxqYpHkNcYK0+lV2la+Gdp3l7ZkjTcAw22RA6Epfr53cYxXY7PapTc/g/Xe9SMI236QoMobDwAYsxU8Oz+LcCx7an1vJp3O59HqQx5YNNfmSSHOx3DY5Vt4Zxc4POx+v7UIJtJXJZWj09j1s/Spn1Lv7gRomxemneSzsNYMgLduQzwCGD9Eo8DDFyvr//nf5GOB5PDqSP1K9GfLlJs04YdT6Giw/p6JRqvQxnVFIP0I0tll6OARyd6+svjf+q6AQYdlUwYqF03ciFZ555QUo=
|
||||
file: WiiUPluginLoader_$versiontag.zip
|
||||
on:
|
||||
repo: Maschell/WiiUPluginLoader
|
22
Dockerfile
@ -1,22 +0,0 @@
|
||||
FROM wups/core:latest
|
||||
|
||||
# clear portlibs. just in case.
|
||||
RUN rm -rf $DEVKITPRO/portlibs
|
||||
|
||||
# Install devkitARM. Needed to build mocha.
|
||||
ENV DEVKITARM=${DEVKITPRO}/devkitARM
|
||||
COPY --from=devkitpro/devkitarm $DEVKITARM $DEVKITARM
|
||||
|
||||
# Get dependencies
|
||||
COPY --from=wiiulegacy/dynamic_libs:0.1 /artifacts $DEVKITPRO/portlibs
|
||||
COPY --from=wiiulegacy/libiosuhax:0.3 /artifacts $DEVKITPRO/portlibs
|
||||
COPY --from=wiiulegacy/libfat:1.1.3a /artifacts $DEVKITPRO/portlibs
|
||||
COPY --from=wiiulegacy/libntfs:2013.1.13 /artifacts $DEVKITPRO/portlibs
|
||||
COPY --from=wiiulegacy/libutils:0.1 /artifacts $DEVKITPRO/portlibs
|
||||
COPY --from=wiiulegacy/libgui:0.1 /artifacts $DEVKITPRO/portlibs
|
||||
|
||||
RUN wget https://github.com/Maschell/WiiUPluginLoader/raw/master/libs/portlibs.zip && \
|
||||
7z x -y portlibs.zip -o${DEVKITPRO} && \
|
||||
rm portlibs.zip
|
||||
|
||||
WORKDIR project
|
674
LICENSE
@ -1,674 +0,0 @@
|
||||
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:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
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>.
|
194
Makefile
@ -1,91 +1,69 @@
|
||||
DO_LOGGING := 1
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(DEVKITPPC)),)
|
||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
||||
endif
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitPro")
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH):$(DEVKITPRO)/tools/bin
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
ifeq ($(strip $(DEVKITPPC)),)
|
||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>/devkitPro/devkitPPC")
|
||||
endif
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
TOPDIR ?= $(CURDIR)
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
include $(DEVKITPPC)/base_rules
|
||||
|
||||
print-% : ; @echo $* = $($*)
|
||||
MACHDEP = -DESPRESSO -mcpu=750 -meabi -mhard-float
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := wiiupluginloader
|
||||
BUILD := build
|
||||
BUILD_DBG := $(TARGET)_dbg
|
||||
SOURCES := src/common \
|
||||
src/custom/gui \
|
||||
src/libelf \
|
||||
src/menu/content \
|
||||
src/menu \
|
||||
src/mymemory \
|
||||
src/mykernel \
|
||||
src/myutils \
|
||||
src/patcher \
|
||||
src/plugin \
|
||||
src/resources \
|
||||
src/settings \
|
||||
src/
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#-------------------------------------------------------------------------------
|
||||
TARGET := hook_payload.elf
|
||||
BUILD := build
|
||||
BUILD_DBG := $(TARGET)_dbg
|
||||
SOURCES := src \
|
||||
src/common \
|
||||
src/libelf \
|
||||
src/fs \
|
||||
src/dynamic_libs \
|
||||
src/kernel \
|
||||
src/memory \
|
||||
src/plugin \
|
||||
src/patcher \
|
||||
src/settings \
|
||||
src/system \
|
||||
src/utils
|
||||
|
||||
DATA := data/images \
|
||||
data/sounds \
|
||||
data/fonts \
|
||||
DATA := data
|
||||
INCLUDES := src \
|
||||
src/libelf
|
||||
|
||||
INCLUDES := src/libelf \
|
||||
src/
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \
|
||||
-O0 -D__wiiu__ -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing -D_GNU_SOURCE $(INCLUDE)
|
||||
CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \
|
||||
-O0 -D__wiiu__ -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing -D_GNU_SOURCE $(INCLUDE)
|
||||
#-------------------------------------------------------------------------------
|
||||
CFLAGS := -g -Wall -O0 -ffunction-sections \
|
||||
$(MACHDEP)
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
CFLAGS += $(INCLUDE) -D__WIIU__ -D_GNU_SOURCE
|
||||
|
||||
ASFLAGS := -mregnames
|
||||
LDFLAGS := -nostartfiles -Wl,-Map,$(notdir $@).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,--gc-sections
|
||||
CXXFLAGS := $(CFLAGS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lgui -lm -lgcc -lfat -liosuhax -lutils -ldynamiclibs -lfreetype -lgd -lpng -ljpeg -lz -lmad -lvorbisidec -logg -lbz2
|
||||
ASFLAGS := -g -mregnames $(ARCH)
|
||||
LDFLAGS = -g $(ARCH) -nostartfiles -Wl,-Map,$(notdir $@).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,--gc-sections
|
||||
|
||||
LIBS :=
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level
|
||||
# containing include and lib
|
||||
#-------------------------------------------------------------------------------
|
||||
LIBDIRS := $(DEVKITPRO)/wups
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CURDIR) \
|
||||
$(DEVKITPPC)/lib \
|
||||
$(DEVKITPRO)/wups
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
@ -102,8 +80,6 @@ export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
FILELIST := $(shell bash ./filelist.sh)
|
||||
LANGUAGES := $(shell bash ./updatelang.sh)
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
@ -130,53 +106,24 @@ export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(PORTLIBS)/include -I$(CURDIR)/$(BUILD) \
|
||||
-I$(PORTLIBS)/include/libutils \
|
||||
-I$(PORTLIBS)/include/freetype2 -I$(PORTLIBS)/include/libgui
|
||||
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
-L$(PORTLIBS)/lib
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD): $(CURDIR)/src/mocha/ios_kernel/ios_kernel.bin.h
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
$(CURDIR)/src/mocha/ios_kernel/ios_kernel.bin.h: $(CURDIR)/src/mocha/ios_usb/ios_usb.bin.h $(CURDIR)/src/mocha/ios_mcp/ios_mcp.bin.h $(CURDIR)/src/mocha/ios_fs/ios_fs.bin.h $(CURDIR)/src/mocha/ios_bsp/ios_bsp.bin.h $(CURDIR)/src/mocha/ios_acp/ios_acp.bin.h
|
||||
@$(MAKE) -j1 --no-print-directory -C $(CURDIR)/src/mocha/ios_kernel -f $(CURDIR)/src/mocha/ios_kernel/Makefile
|
||||
|
||||
$(CURDIR)/src/mocha/ios_usb/ios_usb.bin.h:
|
||||
@$(MAKE) -j1 --no-print-directory -C $(CURDIR)/src/mocha/ios_usb -f $(CURDIR)/src/mocha/ios_usb/Makefile
|
||||
|
||||
$(CURDIR)/src/mocha/ios_fs/ios_fs.bin.h:
|
||||
@$(MAKE) -j1 --no-print-directory -C $(CURDIR)/src/mocha/ios_fs -f $(CURDIR)/src/mocha/ios_fs/Makefile
|
||||
|
||||
$(CURDIR)/src/mocha/ios_bsp/ios_bsp.bin.h:
|
||||
@$(MAKE) -j1 --no-print-directory -C $(CURDIR)/src/mocha/ios_bsp -f $(CURDIR)/src/mocha/ios_bsp/Makefile
|
||||
|
||||
$(CURDIR)/src/mocha/ios_mcp/ios_mcp.bin.h:
|
||||
@$(MAKE) -j1 --no-print-directory -C $(CURDIR)/src/mocha/ios_mcp -f $(CURDIR)/src/mocha/ios_mcp/Makefile
|
||||
|
||||
$(CURDIR)/src/mocha/ios_acp/ios_acp.bin.h:
|
||||
@$(MAKE) -j1 --no-print-directory -C $(CURDIR)/src/mocha/ios_acp -f $(CURDIR)/src/mocha/ios_acp/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf
|
||||
@$(MAKE) --no-print-directory -C $(CURDIR)/src/mocha/ios_kernel -f $(CURDIR)/src/mocha/ios_kernel/Makefile clean
|
||||
@$(MAKE) --no-print-directory -C $(CURDIR)/src/mocha/ios_usb -f $(CURDIR)/src/mocha/ios_usb/Makefile clean
|
||||
@$(MAKE) --no-print-directory -C $(CURDIR)/src/mocha/ios_fs -f $(CURDIR)/src/mocha/ios_fs/Makefile clean
|
||||
@$(MAKE) --no-print-directory -C $(CURDIR)/src/mocha/ios_bsp -f $(CURDIR)/src/mocha/ios_bsp/Makefile clean
|
||||
@$(MAKE) --no-print-directory -C $(CURDIR)/src/mocha/ios_mcp -f $(CURDIR)/src/mocha/ios_mcp/Makefile clean
|
||||
@$(MAKE) --no-print-directory -C $(CURDIR)/src/mocha/ios_acp -f $(CURDIR)/src/mocha/ios_acp/Makefile clean
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(BUILD_DBG).elf
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
@ -186,7 +133,7 @@ DEPENDS := $(OFILES:.o=.d)
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).elf: $(OFILES)
|
||||
$(OUTPUT).elf: $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .jpg extension
|
||||
@ -218,51 +165,16 @@ $(OUTPUT).elf: $(OFILES)
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.s
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.tga.o : %.tga
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
76
README.md
@ -1,76 +0,0 @@
|
||||
[Nightly builds](https://github.com/Maschell/WiiUPluginLoader/releases) | [Issue Tracker](https://github.com/Maschell/WiiUPluginLoader/issues) | [Discussion](https://gbatemp.net/threads/wii-u-plugin-system.496659/) | [Discord](https://discord.gg/bZ2rep2) | [Wiki](https://maschell.github.io/WiiUPluginSystem/dev_overview.html)
|
||||
|
||||
# Wii U Plugin Loader [![Build Status](https://api.travis-ci.org/Maschell/WiiUPluginLoader.svg?branch=master)](https://travis-ci.org/Maschell/WiiUPluginLoader)
|
||||
|
||||
This is the plugin loader for the [WiiUPluginSystem](https://github.com/Maschell/WiiUPluginSystem).
|
||||
|
||||
# Features
|
||||
|
||||
The project is still in it's very early days, but it already has basic functions to play with.
|
||||
|
||||
- The plugins will be loaded, even when you swap the running game.
|
||||
- Support for up to 32 plugins at the same time.
|
||||
- Each plugin can override up to 100 different existing system functions.
|
||||
- Multiple plugins can override the same system functions.
|
||||
- Plugins can register for certain hook (for example whenever an application was started)
|
||||
- Plugins inherit the SD/USB access from the loader. All plugins have global SD and USB (FAT32 only) access.
|
||||
- Plugins can be configured at run-time. Press L, DPAD down, and minus on the gamepad at the same time to open the configuration menu.
|
||||
|
||||
## Usage
|
||||
|
||||
Use the "Wii U Plugin Loader" to load plugins from the sd card. It is built to be loaded through the homebrew launcher, which can be either loaded with the browser exploit or haxchi.
|
||||
Plugins needs to be placed into the following folder:
|
||||
|
||||
```
|
||||
sd:/wiiu/plugins
|
||||
```
|
||||
|
||||
You need to start this Application every time you reboot your console.
|
||||
When you re-enter the homebrew launcher, the plugins will get unloaded.
|
||||
This means it's not possible to combine this with other homebrews (yet).
|
||||
|
||||
## Create plugins
|
||||
Information on how to create plugin can be found in the [wiki](https://maschell.github.io/WiiUPluginSystem/dev_plugin_creation_overview.html).
|
||||
|
||||
## Building
|
||||
Make sure the toolchain is uptodate `pacman -Syu devkitPPC devkitARM vim general-tools`
|
||||
|
||||
For building you need:
|
||||
- [libiosuhax](https://github.com/dimok789/libiosuhax) (Build WITHOUT the WUT flag set.)
|
||||
- [libfat](https://github.com/Maschell/libfat/) (Build with `make wiiu-release && make wiiu-install`)
|
||||
- [dynamic_libs](https://github.com/Maschell/dynamic_libs/tree/lib) for access to the functions.
|
||||
- [libutils](https://github.com/Maschell/libutils) for common functions.
|
||||
- [libgui](https://github.com/Maschell/libgui) for the gui elements.
|
||||
|
||||
Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself.
|
||||
|
||||
A detailed instruction can be found in the Wiki:
|
||||
|
||||
- [How to compile the loader](https://maschell.github.io/WiiUPluginSystem/dev_compile_loader.html)
|
||||
|
||||
### Building using the Dockerfile
|
||||
It's possible to use a docker image for building. This way you don't need anything installed on your host system.
|
||||
|
||||
```
|
||||
# Build docker image (only needed once
|
||||
docker build . -t wups-loader-builder
|
||||
|
||||
# make
|
||||
docker run -it --rm -v ${PWD}:/project wups-loader-builder make
|
||||
|
||||
# make clean
|
||||
docker run -it --rm -v ${PWD}:/project wups-loader-builder make clean
|
||||
```
|
||||
|
||||
# Load a plugin via network
|
||||
|
||||
While the loader is running, it's possible to load a single plugin via [wiiload](http://wiibrew.org/wiki/Wiiload).
|
||||
When using this feature, this and all plugins in `sd:/wiiu/plugins/temp` will be loaded. The plugin will copied to the SDCard, this mean a SDCard is required.
|
||||
A windows executable can be found in `tools/wiiload.exe`
|
||||
More information about wiiload and alternatives can be found here: http://wiibrew.org/wiki/Wiiload
|
||||
|
||||
# Credits
|
||||
Some files are based on brainslug by Chadderz:
|
||||
https://github.com/Chadderz121/brainslug-wii
|
||||
Much stuff also wouldn't be possible without dimok789. He made many great tools and homebrew this stuff in based on (Makefiles, Mocha, homebrew channel, udp logger, dynamic_libs etc.)
|
||||
Also thanks to everyone who made actual exploits.
|
Before Width: | Height: | Size: 795 B |
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 18 KiB |
71
filelist.sh
@ -1,71 +0,0 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
# Automatic resource file list generation
|
||||
# Created by Dimok
|
||||
|
||||
outFile="./src/resources/filelist.cpp"
|
||||
count_old=$(cat $outFile 2>/dev/null | tr -d '\n\n' | sed 's/[^0-9]*\([0-9]*\).*/\1/')
|
||||
|
||||
count=0
|
||||
if [[ $OSTYPE == darwin* ]];
|
||||
then
|
||||
|
||||
for i in $(gfind ./data/images/ ./data/sounds/ ./data/fonts/ -maxdepth 1 -type f \( ! -printf "%f\n" \) | sort -f)
|
||||
do
|
||||
files[count]=$i
|
||||
count=$((count+1))
|
||||
done
|
||||
|
||||
else
|
||||
|
||||
for i in $(find ./data/images/ ./data/sounds/ ./data/fonts/ -maxdepth 1 -type f \( ! -printf "%f\n" \) | sort -f)
|
||||
do
|
||||
files[count]=$i
|
||||
count=$((count+1))
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
if [ "$count_old" != "$count" ] || [ ! -f $outFile ]
|
||||
then
|
||||
|
||||
echo "Generating filelist.c for $count files." >&2
|
||||
cat <<EOF > $outFile
|
||||
/****************************************************************************
|
||||
* Resource files.
|
||||
* This file is generated automatically.
|
||||
* Includes $count files.
|
||||
*
|
||||
* NOTE:
|
||||
* Any manual modification of this file will be overwriten by the generation.
|
||||
*****************************************************************************/
|
||||
#include <resources/filelist.h>
|
||||
#include <stdint.h>
|
||||
|
||||
EOF
|
||||
|
||||
for i in ${files[@]}
|
||||
do
|
||||
filename=${i%.*}
|
||||
extension=${i##*.}
|
||||
echo 'extern const uint8_t '$filename'_'$extension'[];' >> $outFile
|
||||
echo 'extern const uint32_t '$filename'_'$extension'_size;' >> $outFile
|
||||
echo '' >> $outFile
|
||||
done
|
||||
|
||||
echo 'static ResourceFile ResourceList[] =' >> $outFile
|
||||
echo '{' >> $outFile
|
||||
|
||||
for i in ${files[@]}
|
||||
do
|
||||
filename=${i%.*}
|
||||
extension=${i##*.}
|
||||
echo -e '\t{"'$i'", '$filename'_'$extension', '$filename'_'$extension'_size, NULL, 0},' >> $outFile
|
||||
done
|
||||
|
||||
echo -e '\t{NULL, NULL, 0, NULL, 0}' >> $outFile
|
||||
echo '};' >> $outFile
|
||||
echo '' >> $outFile
|
||||
echo 'ResourceFile * getResourceList(){ return ResourceList; }' >> $outFile
|
||||
echo '' >> $outFile
|
||||
fi
|
29
gitrev.sh
@ -1,29 +0,0 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
rev_new=$(git rev-parse --short=7 HEAD)
|
||||
version=$(cat ./loader/src/version.h 2>/dev/null | cut -d '"' -f2)
|
||||
|
||||
|
||||
rev_date=`date -u +%Y%m%d%H%M%S`
|
||||
|
||||
cat <<EOF > ./loader/meta/meta.xml
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<app version="1">
|
||||
<name>Wii U Plugin Loader</name>
|
||||
<coder>Maschell</coder>
|
||||
<url>https://github.com/Maschell/WiiUPluginSystem</url>
|
||||
<version>$version-nightly-$rev_new</version>
|
||||
<release_date>$rev_date</release_date>
|
||||
<short_description>Plugin loader for the Wii U</short_description>
|
||||
<long_description></long_description>
|
||||
<category>tool</category>
|
||||
|
||||
</app>
|
||||
EOF
|
||||
|
||||
cat <<EOF > ./loader/src/version.h
|
||||
#define APP_VERSION "$version-nightly-$rev_new"
|
||||
EOF
|
||||
|
||||
|
||||
echo $version-nightly-$rev_new
|
@ -1,19 +0,0 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
7z x -y ./libs/portlibs.zip -o${DEVKITPRO}
|
||||
mkdir portlib_repos
|
||||
cd portlib_repos
|
||||
((git clone https://github.com/Maschell/dynamic_libs.git -b lib && (7z x -y ./dynamic_libs/libs/portlibs.zip -o${DEVKITPRO})) || (cd dynamic_libs && git pull))
|
||||
(git clone https://github.com/dimok789/libiosuhax.git || (cd libiosuhax && git pull))
|
||||
(git clone https://github.com/Maschell/libfat.git || (cd libfat && git pull))
|
||||
(git clone https://github.com/Maschell/libutils.git || (cd libutils && git pull))
|
||||
((git clone https://github.com/Maschell/libgui.git && (7z x -y ./libgui/libs/portlibs.zip -o${DEVKITPRO})) || (cd libgui && git pull))
|
||||
(git clone https://github.com/Maschell/fs_wrapper.git || (cd fs_wrapper && git pull))
|
||||
(git clone https://github.com/Maschell/controller_patcher.git || (cd controller_patcher && git pull))
|
||||
(cd dynamic_libs && ((make -j8 | grep -c "built ... ") && make install && echo "installed" ) || (echo "no need for make install" && make))
|
||||
(cd libiosuhax && make -j8 && make install)
|
||||
(cd libfat && make wiiu-release && make wiiu-install)
|
||||
(cd libutils && ((make -j8 | grep -c "built ... ") && make install && echo "installed" ) || (echo "no need for make install" && make))
|
||||
(cd libgui && ((make -j8 | grep -c "built ... ") && make install) || echo "no need for make install")
|
||||
(cd fs_wrapper && ((make -j8 | grep -c "built ... ") && make install && echo "installed" ) || (echo "no need for make install" && make))
|
||||
(cd controller_patcher && ((make -j8 | grep -c "built ... ") && make install && echo "installed" ) || (echo "no need for make install" && make))
|
@ -1,54 +0,0 @@
|
||||
msgid "Press HOME to return."
|
||||
msgstr ""
|
||||
|
||||
msgid "Language"
|
||||
msgstr ""
|
||||
|
||||
msgid "Press B to return to the plugin overview."
|
||||
msgstr ""
|
||||
|
||||
# English translations for Wii U Plugin System loader
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-05-08 17:13+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "Press B to return to the plugin overview, HOME to return to the running application."
|
||||
msgstr ""
|
||||
|
||||
#: src/menu/content/ContentHome.cpp:24
|
||||
msgid "Welcome to the Wii U plugin loader"
|
||||
msgstr ""
|
||||
|
||||
#: src/menu/content/ContentHome.cpp:33
|
||||
msgid "Exit to HBL "
|
||||
msgstr ""
|
||||
|
||||
#: src/menu/content/ContentHome.cpp:36
|
||||
msgid "Apply Patches"
|
||||
msgstr ""
|
||||
|
||||
#: src/myutils/ConfigUtils.cpp:113
|
||||
msgid "Press HOME to return to the running application."
|
||||
msgstr ""
|
||||
|
||||
#: src/myutils/ConfigUtils.cpp:114
|
||||
msgid "Configurable running plugins:"
|
||||
msgstr ""
|
||||
|
||||
#: src/myutils/ConfigUtils.cpp:118
|
||||
msgid "No configurable running plugins found."
|
||||
msgstr ""
|
||||
|
||||
#: src/myutils/ConfigUtils.cpp:243
|
||||
msgid "B = plugin overview, HOME = back to running application."
|
||||
msgstr ""
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<app version="1">
|
||||
<name>Wii U Plugin Loader</name>
|
||||
<coder>Maschell</coder>
|
||||
<url>https://github.com/Maschell/WiiUPluginSystem</url>
|
||||
<version>pre-alpha</version>
|
||||
<release_date>201802103162900</release_date>
|
||||
<short_description>Plugin loader for the Wii U</short_description>
|
||||
<long_description>
|
||||
</long_description>
|
||||
<category>tool</category>
|
||||
|
||||
</app>
|
@ -1,255 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
* Modified by Maschell, 2018 for Wii U Plugin System loader
|
||||
*
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
#include "Application.h"
|
||||
#include "common/common.h"
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <gui/FreeTypeGX.h>
|
||||
#include <gui/VPadController.h>
|
||||
#include <gui/WPadController.h>
|
||||
#include "resources/Resources.h"
|
||||
#include <sounds/SoundHandler.hpp>
|
||||
#include <utils/logger.h>
|
||||
#include "settings/CSettings.h"
|
||||
#include "myutils/TcpReceiver.h"
|
||||
#include "mymemory/memory_mapping.h"
|
||||
|
||||
Application *Application::applicationInstance = NULL;
|
||||
bool Application::exitApplication = false;
|
||||
|
||||
Application::Application()
|
||||
: CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x20000)
|
||||
, bgMusic(NULL)
|
||||
, video(NULL)
|
||||
, mainWindow(NULL)
|
||||
, exitCode(EXIT_RELAUNCH_ON_LOAD) {
|
||||
controller[0] = new VPadController(GuiTrigger::CHANNEL_1);
|
||||
controller[1] = new WPadController(GuiTrigger::CHANNEL_2);
|
||||
controller[2] = new WPadController(GuiTrigger::CHANNEL_3);
|
||||
controller[3] = new WPadController(GuiTrigger::CHANNEL_4);
|
||||
controller[4] = new WPadController(GuiTrigger::CHANNEL_5);
|
||||
|
||||
CSettings::instance()->Load();
|
||||
|
||||
//! create bgMusic
|
||||
bgMusic = new GuiSound(Resources::GetFile("bgMusic.mp3"), Resources::GetFileSize("bgMusic.mp3"));
|
||||
|
||||
//! load language
|
||||
loadLanguageFromConfig();
|
||||
|
||||
exitApplication = false;
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
DEBUG_FUNCTION_LINE("Destroy music\n");
|
||||
delete bgMusic;
|
||||
|
||||
DEBUG_FUNCTION_LINE("Destroy controller\n");
|
||||
|
||||
for(int32_t i = 0; i < 5; i++)
|
||||
delete controller[i];
|
||||
|
||||
//We may have to handle Asyncdelete in the Destructors.
|
||||
DEBUG_FUNCTION_LINE("Destroy async deleter\n");
|
||||
do {
|
||||
DEBUG_FUNCTION_LINE("Triggering AsyncDeleter\n");
|
||||
AsyncDeleter::triggerDeleteProcess();
|
||||
while(!AsyncDeleter::realListEmpty()) {
|
||||
DEBUG_FUNCTION_LINE("Waiting...\n");
|
||||
os_usleep(1000);
|
||||
}
|
||||
} while(!AsyncDeleter::deleteListEmpty());
|
||||
AsyncDeleter::destroyInstance();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Clear resources\n");
|
||||
Resources::Clear();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Stop sound handler\n");
|
||||
SoundHandler::DestroyInstance();
|
||||
}
|
||||
|
||||
int32_t Application::exec() {
|
||||
//! start main GX2 thread
|
||||
resumeThread();
|
||||
//! now wait for thread to finish
|
||||
shutdownThread();
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
void Application::reloadUI() {
|
||||
reloadUIflag = true;
|
||||
}
|
||||
void Application::fadeOut() {
|
||||
GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color) {
|
||||
0, 0, 0, 255
|
||||
});
|
||||
|
||||
for(int32_t i = 0; i < 255; i += 10) {
|
||||
if(i > 255)
|
||||
i = 255;
|
||||
|
||||
fadeOut.setAlpha(i / 255.0f);
|
||||
|
||||
//! start rendering DRC
|
||||
video->prepareDrcRendering();
|
||||
mainWindow->drawDrc(video);
|
||||
|
||||
GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_ALWAYS);
|
||||
fadeOut.draw(video);
|
||||
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_LEQUAL);
|
||||
|
||||
video->drcDrawDone();
|
||||
|
||||
//! start rendering TV
|
||||
video->prepareTvRendering();
|
||||
|
||||
mainWindow->drawTv(video);
|
||||
|
||||
GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_ALWAYS);
|
||||
fadeOut.draw(video);
|
||||
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_LEQUAL);
|
||||
|
||||
video->tvDrawDone();
|
||||
|
||||
//! as last point update the effects as it can drop elements
|
||||
mainWindow->updateEffects();
|
||||
|
||||
video->waitForVSync();
|
||||
}
|
||||
|
||||
//! one last cleared black screen
|
||||
video->prepareDrcRendering();
|
||||
video->drcDrawDone();
|
||||
video->prepareTvRendering();
|
||||
video->tvDrawDone();
|
||||
video->waitForVSync();
|
||||
video->tvEnable(false);
|
||||
video->drcEnable(false);
|
||||
}
|
||||
|
||||
void Application::executeThread(void) {
|
||||
DEBUG_FUNCTION_LINE("Initialize video\n");
|
||||
video = new CVideo(GX2_TV_SCAN_MODE_720P, GX2_DRC_SINGLE);
|
||||
|
||||
DEBUG_FUNCTION_LINE("Video size %i x %i\n", video->getTvWidth(), video->getTvHeight());
|
||||
|
||||
//! setup default Font
|
||||
DEBUG_FUNCTION_LINE("Initialize main font system\n");
|
||||
FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true);
|
||||
GuiText::setPresetFont(fontSystem);
|
||||
|
||||
reloadUIflag = true;
|
||||
if(bgMusic != NULL) {
|
||||
bgMusic->SetLoop(true);
|
||||
bgMusic->SetVolume(50);
|
||||
bgMusic->Stop(); //CHANG MEEEEEEEEEEEEEEEEEEE
|
||||
}
|
||||
|
||||
|
||||
while(reloadUIflag) {
|
||||
reloadUIflag = false;
|
||||
exitCode = EXIT_RELAUNCH_ON_LOAD;
|
||||
DEBUG_FUNCTION_LINE("Initialize the language\n");
|
||||
loadLanguageFromConfig();
|
||||
DEBUG_FUNCTION_LINE("Initialize main window\n");
|
||||
mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight());
|
||||
|
||||
exitApplication = false;
|
||||
//! main GX2 loop (60 Hz cycle with max priority on core 1)
|
||||
|
||||
DEBUG_FUNCTION_LINE("Starting TcpReceiver\n");
|
||||
TcpReceiver pluginReceiver(4299);
|
||||
DEBUG_FUNCTION_LINE("Entering main loop\n");
|
||||
while(!exitApplication && !reloadUIflag) {
|
||||
//! Read out inputs
|
||||
for(int32_t i = 0; i < 5; i++) {
|
||||
if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false)
|
||||
continue;
|
||||
|
||||
if(controller[i]->data.buttons_d & VPAD_BUTTON_PLUS) {
|
||||
exitCode = APPLICATION_CLOSE_APPLY;
|
||||
if(linkPluginsCallback != NULL) {
|
||||
bool result = linkPluginsCallback();
|
||||
if(!result) {
|
||||
// On linking errors return to the HBL.
|
||||
#warning TODO: proper error handling when linking fails.
|
||||
exitCode = APPLICATION_CLOSE_MIIMAKER;
|
||||
}
|
||||
}
|
||||
exitApplication = true;
|
||||
}
|
||||
|
||||
if(controller[i]->data.buttons_d & VPAD_BUTTON_MINUS) {
|
||||
exitCode = APPLICATION_CLOSE_APPLY_MEMORY;
|
||||
exitApplication = true;
|
||||
}
|
||||
|
||||
if(controller[i]->data.buttons_d & VPAD_BUTTON_HOME) {
|
||||
exitCode = APPLICATION_CLOSE_MIIMAKER;
|
||||
exitApplication = true;
|
||||
}
|
||||
|
||||
//! update controller states
|
||||
mainWindow->update(controller[i]);
|
||||
}
|
||||
mainWindow->process();
|
||||
|
||||
//! start rendering DRC
|
||||
video->prepareDrcRendering();
|
||||
mainWindow->drawDrc(video);
|
||||
video->drcDrawDone();
|
||||
|
||||
//! start rendering TV
|
||||
video->prepareTvRendering();
|
||||
mainWindow->drawTv(video);
|
||||
video->tvDrawDone();
|
||||
|
||||
//! enable screen after first frame render
|
||||
if(video->getFrameCount() == 0) {
|
||||
video->tvEnable(true);
|
||||
video->drcEnable(true);
|
||||
}
|
||||
|
||||
|
||||
//! as last point update the effects as it can drop elements
|
||||
mainWindow->updateEffects();
|
||||
|
||||
video->waitForVSync();
|
||||
|
||||
//! transfer elements to real delete list here after all processes are finished
|
||||
//! the elements are transfered to another list to delete the elements in a separate thread
|
||||
//! and avoid blocking the GUI thread
|
||||
AsyncDeleter::triggerDeleteProcess();
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Fading out\n");
|
||||
fadeOut();
|
||||
DEBUG_FUNCTION_LINE("Destroying the MainWindow\n");
|
||||
MainWindow::destroyInstance();
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Delete fontSystem\n");
|
||||
delete fontSystem;
|
||||
DEBUG_FUNCTION_LINE("Delete video\n");
|
||||
delete video;
|
||||
}
|
||||
|
||||
void Application::loadLanguageFromConfig() {
|
||||
if(!CSettings::getValueAsString(CSettings::AppLanguage).empty()) {
|
||||
std::string languagePath = std::string(DEFAULT_LANG_PATH) + "/" + CSettings::getValueAsString(CSettings::AppLanguage) + std::string(LANGUAGE_FILE_EXT);
|
||||
gettextLoadLanguage(languagePath.c_str());
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
* Modified by Maschell, 2018 for Wii U Plugin System loader
|
||||
*
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
#ifndef _APPLICATION_H
|
||||
#define _APPLICATION_H
|
||||
|
||||
#include "menu/MainWindow.h"
|
||||
#include <functional>
|
||||
#include <video/CVideo.h>
|
||||
#include <system/CThread.h>
|
||||
#include <language/gettext.h>
|
||||
|
||||
#define APPLICATION_CLOSE_APPLY 1
|
||||
#define APPLICATION_CLOSE_APPLY_MEMORY 3
|
||||
#define APPLICATION_CLOSE_MIIMAKER 2
|
||||
|
||||
class Application : public CThread {
|
||||
public:
|
||||
static Application * instance() {
|
||||
if(!applicationInstance)
|
||||
applicationInstance = new Application();
|
||||
return applicationInstance;
|
||||
}
|
||||
static void destroyInstance() {
|
||||
if(applicationInstance) {
|
||||
delete applicationInstance;
|
||||
applicationInstance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
CVideo *getVideo(void) const {
|
||||
return video;
|
||||
}
|
||||
MainWindow *getMainWindow(void) const {
|
||||
return mainWindow;
|
||||
}
|
||||
|
||||
GuiSound *getBgMusic(void) const {
|
||||
return bgMusic;
|
||||
}
|
||||
|
||||
int32_t exec(void);
|
||||
void fadeOut(void);
|
||||
|
||||
void reloadUI(void);
|
||||
|
||||
void quit(int32_t code) {
|
||||
exitCode = code;
|
||||
exitApplication = true;
|
||||
}
|
||||
|
||||
void setLinkPluginsCallback(std::function<bool(void)> fun) {
|
||||
linkPluginsCallback = fun;
|
||||
DEBUG_FUNCTION_LINE("Set callback to %08X \n",linkPluginsCallback);
|
||||
}
|
||||
private:
|
||||
Application();
|
||||
|
||||
virtual ~Application();
|
||||
|
||||
static Application *applicationInstance;
|
||||
static bool exitApplication;
|
||||
|
||||
void executeThread(void);
|
||||
|
||||
void loadLanguageFromConfig();
|
||||
|
||||
bool reloadUIflag = false;
|
||||
|
||||
GuiSound *bgMusic;
|
||||
CVideo *video;
|
||||
MainWindow *mainWindow;
|
||||
GuiController *controller[5];
|
||||
int32_t exitCode;
|
||||
std::function<bool(void)> linkPluginsCallback = NULL;
|
||||
};
|
||||
|
||||
#endif //_APPLICATION_H
|
@ -1,54 +0,0 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <dynamic_libs/os_defs.h>
|
||||
|
||||
#define CAFE_OS_SD_PATH "/vol/external01"
|
||||
#define WIIU_PATH "/wiiu"
|
||||
#define SD_PATH "sd:"
|
||||
#define USB_PATH "usb:"
|
||||
#define DEFAULT_NAME_PACKAGE "DEFAULT"
|
||||
#define NAME_PREFIX_SD "sd: "
|
||||
#define NAME_PREFIX_USB "usb:"
|
||||
|
||||
#define ELF_DATA_ADDR (*(volatile uint32_t*)(MEM_BASE + 0x1300 + 0x00))
|
||||
#define ELF_DATA_SIZE (*(volatile uint32_t*)(MEM_BASE + 0x1300 + 0x04))
|
||||
#define MAIN_ENTRY_ADDR (*(volatile uint32_t*)(MEM_BASE + 0x1400 + 0x00))
|
||||
|
||||
#ifndef EXIT_SUCCESS
|
||||
#define EXIT_SUCCESS 0
|
||||
#endif
|
||||
#define EXIT_HBL_EXIT 0xFFFFFFFE
|
||||
#define EXIT_RELAUNCH_ON_LOAD 0xFFFFFFFD
|
||||
|
||||
#define DEFAULT_WUPSLOADER_PATH SD_PATH WIIU_PATH "/apps/wiiupluginsystem"
|
||||
#define DEFAULT_LANG_PATH DEFAULT_WUPSLOADER_PATH "/languages"
|
||||
#define LANGUAGE_FILE_EXT ".lang"
|
||||
#define PLUGIN_CONFIG_FILE_EXT ".cfg"
|
||||
#define PLUGIN_FILE_EXT ".mod"
|
||||
|
||||
#define WUPS_PLUGIN_PATH SD_PATH WIIU_PATH "/plugins"
|
||||
#define WUPS_TEMP_PLUGIN_PATH SD_PATH WIIU_PATH "/plugins/temp"
|
||||
#define WUPS_TEMP_PLUGIN_FILE WUPS_TEMP_PLUGIN_PATH "/temp" PLUGIN_FILE_EXT
|
||||
|
||||
#define WUPS_SDUSB_MOUNTED_NONE 0
|
||||
#define WUPS_SDUSB_MOUNTED_FAKE (1<<0)
|
||||
#define WUPS_SDUSB_MOUNTED_OS_SD (1<<1)
|
||||
#define WUPS_SDUSB_LIBIOSU_LOADED (1<<2)
|
||||
#define WUPS_SD_MOUNTED_LIBFAT (1<<3)
|
||||
#define WUPS_USB_MOUNTED_LIBFAT (1<<4)
|
||||
#define WUPS_USB_MOUNTED_LIBNTFS (1<<5)
|
||||
|
||||
#define WUPS_SD_MOUNTED (WUPS_SDUSB_MOUNTED_OS_SD | WUPS_SD_MOUNTED_LIBFAT)
|
||||
#define WUPS_USB_MOUNTED (WUPS_USB_MOUNTED_LIBFAT)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COMMON_H */
|
||||
|
@ -1,26 +1,23 @@
|
||||
#include "retain_vars.h"
|
||||
#include "myutils/overlay_helper.h"
|
||||
#include "utils/overlay_helper.h"
|
||||
replacement_data_t gbl_replacement_data __attribute__((section(".data")));
|
||||
dyn_linking_relocation_data_t gbl_dyn_linking_data __attribute__((section(".data")));
|
||||
|
||||
uint8_t gAppStatus __attribute__((section(".data"))) = 0;
|
||||
bool g_NotInLoader __attribute__((section(".data"))) = false;
|
||||
bool g_NotInLoader __attribute__((section(".data"))) = true;
|
||||
uint64_t gGameTitleID __attribute__((section(".data"))) = 0;
|
||||
volatile uint8_t gSDInitDone __attribute__((section(".data"))) = 0;
|
||||
|
||||
void * ntfs_mounts __attribute__((section(".data"))) = NULL;
|
||||
int32_t ntfs_mount_count __attribute__((section(".data"))) = 0;
|
||||
|
||||
struct buffer_store drc_store __attribute__((section(".data")));
|
||||
struct buffer_store tv_store __attribute__((section(".data")));
|
||||
|
||||
|
||||
char gbl_common_data[0x20000] __attribute__((section(".data")));
|
||||
char * gbl_common_data_ptr __attribute__((section(".data"))) = gbl_common_data;
|
||||
|
||||
/*
|
||||
GX2ColorBuffer g_vid_main_cbuf __attribute__((section(".data")));
|
||||
GX2Texture g_vid_drcTex __attribute__((section(".data")));
|
||||
GX2Sampler g_vid_sampler __attribute__((section(".data")));
|
||||
GX2Texture g_vid_tvTex __attribute__((section(".data")));
|
||||
GX2ContextState* g_vid_ownContextState __attribute__((section(".data")));
|
||||
GX2ContextState* g_vid_originalContextSave __attribute__((section(".data")))= NULL;
|
||||
GX2ContextState* g_vid_originalContextSave __attribute__((section(".data")))= NULL;*/
|
||||
|
@ -2,30 +2,30 @@
|
||||
#define RETAINS_VARS_H_
|
||||
#include "patcher/function_patcher.h"
|
||||
#include "plugin/dynamic_linking_defines.h"
|
||||
#include <dynamic_libs/gx2_functions.h>
|
||||
#include "utils/overlay_helper.h"
|
||||
//#include <dynamic_libs/gx2_functions.h>
|
||||
|
||||
extern replacement_data_t gbl_replacement_data;
|
||||
extern dyn_linking_relocation_data_t gbl_dyn_linking_data;
|
||||
|
||||
|
||||
extern bool g_NotInLoader;
|
||||
|
||||
extern uint8_t gAppStatus;
|
||||
extern uint64_t gGameTitleID;
|
||||
extern volatile uint8_t gSDInitDone;
|
||||
|
||||
|
||||
extern void * ntfs_mounts;
|
||||
extern int32_t ntfs_mount_count;
|
||||
|
||||
extern struct buffer_store drc_store;
|
||||
extern struct buffer_store tv_store;
|
||||
|
||||
/*
|
||||
extern GX2ColorBuffer g_vid_main_cbuf;
|
||||
extern GX2Texture g_vid_drcTex;
|
||||
extern GX2Texture g_vid_tvTex;
|
||||
extern GX2ContextState* g_vid_ownContextState;
|
||||
extern GX2ContextState* g_vid_originalContextSave;
|
||||
extern GX2Sampler g_vid_sampler;
|
||||
extern GX2Sampler g_vid_sampler;*/
|
||||
|
||||
#endif // RETAINS_VARS_H_
|
||||
|
@ -1,50 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017 Maschell
|
||||
*
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
#include "DefaultGuiSelectBox.h"
|
||||
/**
|
||||
* Constructor for the DefaultGuiSelectBox class.
|
||||
*/
|
||||
|
||||
DefaultGuiSelectBox::DefaultGuiSelectBox(std::string caption, GuiFrame *parent)
|
||||
: GuiSelectBox(NULL,caption)
|
||||
,topBackgroundImg_imgdata(Resources::GetImageData("gameSettingsButton.png"))
|
||||
,topBackgroundImg_img(topBackgroundImg_imgdata)
|
||||
,topHighlightedImg_imgdata(Resources::GetImageData("gameSettingsButtonSelected.png"))
|
||||
,topHighlightedImg_img(topHighlightedImg_imgdata)
|
||||
,valueImageData(Resources::GetImageData("gameSettingsButtonEx.png"))
|
||||
,valueSelectedImageData(Resources::GetImageData("gameSettingsButtonExSelected.png"))
|
||||
,valueHighlightedImageData(Resources::GetImageData("gameSettingsButtonExHighlighted.png"))
|
||||
,buttonClickSound(Resources::GetSound("settings_click_2.mp3")) {
|
||||
setSize(topBackgroundImg_img.getWidth(),topBackgroundImg_img.getHeight());
|
||||
this->setImageTopBackground(&topBackgroundImg_img);
|
||||
this->setImageTopHighlighted(&topHighlightedImg_img);
|
||||
this->setImageValueBackground(valueImageData);
|
||||
this->setImageValueHighlighted(valueHighlightedImageData);
|
||||
this->setImageValueSelected(valueSelectedImageData);
|
||||
this->setSoundClick(buttonClickSound);
|
||||
}
|
||||
/**
|
||||
* Destructor for the DefaultGuiSelectBox class.
|
||||
*/
|
||||
DefaultGuiSelectBox::~DefaultGuiSelectBox() {
|
||||
Resources::RemoveImageData(topBackgroundImg_imgdata);
|
||||
Resources::RemoveImageData(topHighlightedImg_imgdata);
|
||||
Resources::RemoveImageData(valueImageData);
|
||||
Resources::RemoveImageData(valueSelectedImageData);
|
||||
Resources::RemoveImageData(valueHighlightedImageData);
|
||||
Resources::RemoveSound(buttonClickSound);
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017 Maschell
|
||||
*
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
#ifndef DEFAULT_GUI_SELECTBOX_H_
|
||||
#define DEFAULT_GUI_SELECTBOX_H_
|
||||
|
||||
#include <gui/GuiSelectBox.h>
|
||||
|
||||
//!A simple select box with default values.
|
||||
class DefaultGuiSelectBox : public GuiSelectBox {
|
||||
public:
|
||||
//!Constructor
|
||||
//!\param checked Checked
|
||||
DefaultGuiSelectBox(std::string caption, GuiFrame *parent = NULL);
|
||||
//!Destructor
|
||||
virtual ~DefaultGuiSelectBox();
|
||||
|
||||
protected:
|
||||
GuiImageData * topBackgroundImg_imgdata;
|
||||
GuiImage topBackgroundImg_img;
|
||||
|
||||
GuiImageData * topHighlightedImg_imgdata;
|
||||
GuiImage topHighlightedImg_img;
|
||||
|
||||
GuiImageData * valueImageData;
|
||||
GuiImageData * valueSelectedImageData;
|
||||
GuiImageData * valueHighlightedImageData;
|
||||
|
||||
GuiSound * buttonClickSound;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,46 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017 Maschell
|
||||
*
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
#include "DefaultGuiSwitch.h"
|
||||
/**
|
||||
* Constructor for the DefaultGuiSwitch class.
|
||||
*/
|
||||
|
||||
DefaultGuiSwitch::DefaultGuiSwitch(bool checked)
|
||||
: GuiSwitch(NULL,checked)
|
||||
,switchbase_imgdata(Resources::GetImageData("switchIconBase.png"))
|
||||
,switchbase_img(switchbase_imgdata)
|
||||
,switchbase_highlighted_imgdata(Resources::GetImageData("switchIconBaseHighlighted.png"))
|
||||
,switchbase_highlighted_img(switchbase_highlighted_imgdata)
|
||||
,switchOn_imgdata(Resources::GetImageData("switchIconOn.png"))
|
||||
,switchOn_img(switchOn_imgdata)
|
||||
,switchOff_imgdata(Resources::GetImageData("switchIconOff.png"))
|
||||
,switchOff_img(switchOff_imgdata) {
|
||||
setSize(switchbase_img.getWidth(),switchbase_img.getHeight());
|
||||
this->setImageBackground(&switchbase_img);
|
||||
this->setImageHighlighted(&switchbase_highlighted_img);
|
||||
this->setImageOn(&switchOn_img);
|
||||
this->setImageOff(&switchOff_img);
|
||||
}
|
||||
/**
|
||||
* Destructor for the DefaultGuiSwitch class.
|
||||
*/
|
||||
DefaultGuiSwitch::~DefaultGuiSwitch() {
|
||||
Resources::RemoveImageData(switchbase_imgdata);
|
||||
Resources::RemoveImageData(switchbase_highlighted_imgdata);
|
||||
Resources::RemoveImageData(switchOn_imgdata);
|
||||
Resources::RemoveImageData(switchOff_imgdata);
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017 Maschell
|
||||
*
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
#ifndef DEFAULT_GUI_SWTICH_H_
|
||||
#define DEFAULT_GUI_SWTICH_H_
|
||||
|
||||
#include <gui/GuiSwitch.h>
|
||||
|
||||
//!A simple switch
|
||||
class DefaultGuiSwitch : public GuiSwitch {
|
||||
public:
|
||||
//!Constructor
|
||||
//!\param checked Checked
|
||||
DefaultGuiSwitch(bool checked);
|
||||
//!Destructor
|
||||
virtual ~DefaultGuiSwitch();
|
||||
|
||||
protected:
|
||||
GuiImageData * switchbase_imgdata = NULL;
|
||||
GuiImage switchbase_img;
|
||||
|
||||
GuiImageData * switchbase_highlighted_imgdata = NULL;
|
||||
GuiImage switchbase_highlighted_img;
|
||||
|
||||
GuiImageData * switchOn_imgdata = NULL;
|
||||
GuiImage switchOn_img;
|
||||
|
||||
GuiImageData * switchOff_imgdata = NULL;
|
||||
GuiImage switchOff_img;
|
||||
};
|
||||
|
||||
#endif
|
142
src/dynamic_libs/coreinit.c
Normal file
@ -0,0 +1,142 @@
|
||||
#include "coreinit.h"
|
||||
|
||||
uint32_t coreinit_handle __attribute__((section(".data"))) = 0;
|
||||
|
||||
EXPORT_DECL(void, DCInvalidateRange, void *buffer, uint32_t length);
|
||||
EXPORT_DECL(void, DCFlushRange, const void *addr, uint32_t length);
|
||||
EXPORT_DECL(void, DCStoreRange, const void *addr, uint32_t length);
|
||||
EXPORT_DECL(void, ICInvalidateRange, const void *addr, uint32_t length);
|
||||
EXPORT_DECL(void*, OSEffectiveToPhysical, uint32_t);
|
||||
EXPORT_DECL(void*, OSSleepTicks, uint64_t);
|
||||
|
||||
EXPORT_DECL(int32_t, OSCreateThread, OSThread *thread, int32_t (*callback)(int32_t, void*), int32_t argc, void *args, uint32_t stack, uint32_t stack_size, int32_t priority, uint32_t attr);
|
||||
EXPORT_DECL(int32_t, OSResumeThread, OSThread *thread);
|
||||
EXPORT_DECL(int32_t, OSSuspendThread, OSThread *thread);
|
||||
EXPORT_DECL(int32_t, OSIsThreadTerminated, OSThread *thread);
|
||||
EXPORT_DECL(int32_t, OSIsThreadSuspended, OSThread *thread);
|
||||
EXPORT_DECL(int32_t, OSSetThreadPriority, OSThread * thread, int32_t priority);
|
||||
EXPORT_DECL(int32_t, OSJoinThread, OSThread * thread, int32_t * ret_val);
|
||||
EXPORT_DECL(void, OSDetachThread, OSThread * thread);
|
||||
EXPORT_DECL(OSThread *,OSGetCurrentThread,void);
|
||||
EXPORT_DECL(const char *,OSGetThreadName,OSThread * thread);
|
||||
EXPORT_DECL(void,OSGetActiveThreadLink,OSThread * thread, void* link);
|
||||
EXPORT_DECL(uint32_t,OSGetThreadAffinity,OSThread * thread);
|
||||
EXPORT_DECL(int32_t,OSGetThreadPriority,OSThread * thread);
|
||||
EXPORT_DECL(void,OSSetThreadName,OSThread * thread, const char *name);
|
||||
EXPORT_DECL(int32_t, OSGetCoreId, void);
|
||||
EXPORT_DECL(int32_t, MEMCreateExpHeapEx, void *heap, uint32_t size, uint16_t flags);
|
||||
EXPORT_DECL(void*, MEMAllocFromExpHeapEx, int32_t heap, uint32_t size, int alignment);
|
||||
EXPORT_DECL(void, MEMFreeToExpHeap, int32_t heap, void * block);
|
||||
|
||||
EXPORT_DECL(void, OSEnableHomeButtonMenu, int32_t);
|
||||
|
||||
EXPORT_VAR(uint32_t *, pMEMAllocFromDefaultHeapEx);
|
||||
EXPORT_VAR(uint32_t *, pMEMAllocFromDefaultHeap);
|
||||
EXPORT_VAR(uint32_t *, pMEMFreeToDefaultHeap);
|
||||
|
||||
EXPORT_DECL(int32_t, OSIsHomeButtonMenuEnabled, void);
|
||||
EXPORT_DECL(uint64_t, OSGetTitleID, void);
|
||||
|
||||
EXPORT_DECL(void,OSScreenInit,void);
|
||||
EXPORT_DECL(unsigned int, OSScreenGetBufferSizeEx,unsigned int bufferNum);
|
||||
EXPORT_DECL(unsigned int, OSScreenSetBufferEx,unsigned int bufferNum, void * addr);
|
||||
EXPORT_DECL(unsigned int, OSScreenFlipBuffersEx,unsigned int x);
|
||||
EXPORT_DECL(int32_t, OSScreenEnableEx,uint32_t bufferNum, int32_t enable);
|
||||
EXPORT_DECL(int32_t, OSScreenPutFontEx,uint32_t bufferNum, uint32_t posX, uint32_t posY, const char * buffer);
|
||||
EXPORT_DECL(unsigned int, OSScreenClearBufferEx,unsigned int bufferNum, unsigned int temp);
|
||||
|
||||
EXPORT_DECL(void, OSInitMutex, void* mutex);
|
||||
EXPORT_DECL(void, OSLockMutex, void* mutex);
|
||||
EXPORT_DECL(void, OSUnlockMutex, void* mutex);
|
||||
EXPORT_DECL(int32_t, OSTryLockMutex, void* mutex);
|
||||
|
||||
void _os_find_export(uint32_t handle, const char *funcName, void *funcPointer) {
|
||||
OSDynLoad_FindExport(handle, 0, funcName, funcPointer);
|
||||
|
||||
if(!*(uint32_t *)funcPointer) {
|
||||
/*
|
||||
* This is effectively OSFatal("Function %s is NULL", funcName),
|
||||
* but we can't rely on any library functions like snprintf or
|
||||
* strcpy at this point.
|
||||
*
|
||||
* Buffer bounds are not checked. Beware!
|
||||
*/
|
||||
char buf[256], *bufp = buf;
|
||||
const char a[] = "Function ", b[] = " is NULL", *p;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sizeof(a) - 1; i++)
|
||||
*bufp++ = a[i];
|
||||
|
||||
for (p = funcName; *p; p++)
|
||||
*bufp++ = *p;
|
||||
|
||||
for (i = 0; i < sizeof(b) - 1; i++)
|
||||
*bufp++ = b[i];
|
||||
|
||||
*bufp++ = '\0';
|
||||
|
||||
OSFatal(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InitAcquireOS() {
|
||||
OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
|
||||
}
|
||||
void InitOSFunctionPointers(void) {
|
||||
|
||||
if(coreinit_handle != 0){
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t funcPointer = 0;
|
||||
|
||||
InitAcquireOS();
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, OSInitMutex);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSLockMutex);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSUnlockMutex);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSTryLockMutex);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenInit);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenGetBufferSizeEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenSetBufferEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenFlipBuffersEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenEnableEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenPutFontEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenClearBufferEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSEnableHomeButtonMenu);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, OSIsHomeButtonMenuEnabled);
|
||||
OS_FIND_EXPORT(coreinit_handle, DCInvalidateRange);
|
||||
OS_FIND_EXPORT(coreinit_handle, DCFlushRange);
|
||||
OS_FIND_EXPORT(coreinit_handle, DCStoreRange);
|
||||
OS_FIND_EXPORT(coreinit_handle, ICInvalidateRange);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSEffectiveToPhysical);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSSleepTicks);
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMCreateExpHeapEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMAllocFromExpHeapEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMFreeToExpHeap);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSGetTitleID);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, OSCreateThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSResumeThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSSuspendThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSIsThreadTerminated);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSIsThreadSuspended);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSJoinThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSSetThreadPriority);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSDetachThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSGetCurrentThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSGetThreadName);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSGetActiveThreadLink);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSGetThreadAffinity);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSGetThreadPriority);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSSetThreadName);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSGetCoreId);
|
||||
|
||||
OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeapEx", &pMEMAllocFromDefaultHeapEx);
|
||||
OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeap", &pMEMAllocFromDefaultHeap);
|
||||
OSDynLoad_FindExport(coreinit_handle, 1, "MEMFreeToDefaultHeap", &pMEMFreeToDefaultHeap);
|
||||
}
|
205
src/dynamic_libs/coreinit.h
Normal file
@ -0,0 +1,205 @@
|
||||
#ifndef __COREINIT_H_
|
||||
#define __COREINIT_H_
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define OSTimerClockSpeed ((248625000) / 4)
|
||||
|
||||
#define OSSecondsToTicks(val) ((uint64_t)(val) * (uint64_t)OSTimerClockSpeed)
|
||||
#define OSMillisecondsToTicks(val) (((uint64_t)(val) * (uint64_t)OSTimerClockSpeed) / 1000ull)
|
||||
#define OSMicrosecondsToTicks(val) (((uint64_t)(val) * (uint64_t)OSTimerClockSpeed) / 1000000ull)
|
||||
|
||||
#define os_usleep(usecs) OSSleepTicks(OSMicrosecondsToTicks(usecs))
|
||||
#define os_sleep(secs) OSSleepTicks(OSSecondsToTicks(secs))
|
||||
|
||||
#define OSDynLoad_Acquire ((void (*)(char* rpl, unsigned int *handle))0x0102A3B4)
|
||||
#define OSDynLoad_FindExport ((void (*)(unsigned int handle, int isdata, const char *symbol, void *address))0x0102B828)
|
||||
#define OSFatal ((void (*)(char* msg))0x01031618)
|
||||
|
||||
#define EXPORT_DECL(res, func, ...) res (* func)(__VA_ARGS__) __attribute__((section(".data"))) = 0;
|
||||
#define EXPORT_VAR(type, var) type var __attribute__((section(".data")));
|
||||
|
||||
|
||||
#define EXPORT_FUNC_WRITE(func, val) *(uint32_t*)(((uint32_t)&func) + 0) = (uint32_t)val
|
||||
|
||||
#define OS_FIND_EXPORT(handle, func) _os_find_export(handle, # func, &funcPointer); \
|
||||
EXPORT_FUNC_WRITE(func, funcPointer);
|
||||
|
||||
#define OS_FIND_EXPORT_EX(handle, func, func_p) \
|
||||
_os_find_export(handle, # func, &funcPointer); \
|
||||
EXPORT_FUNC_WRITE(func_p, funcPointer);
|
||||
|
||||
#define OS_MUTEX_SIZE 44
|
||||
|
||||
extern void _os_find_export(uint32_t handle, const char *funcName, void *funcPointer);
|
||||
|
||||
|
||||
typedef struct OSThread_ OSThread;
|
||||
|
||||
typedef struct OSContext_ {
|
||||
char tag[8];
|
||||
|
||||
uint32_t gpr[32];
|
||||
|
||||
uint32_t cr;
|
||||
uint32_t lr;
|
||||
uint32_t ctr;
|
||||
uint32_t xer;
|
||||
|
||||
uint32_t srr0;
|
||||
uint32_t srr1;
|
||||
|
||||
uint32_t ex0;
|
||||
uint32_t ex1;
|
||||
|
||||
uint32_t exception_type;
|
||||
uint32_t reserved;
|
||||
|
||||
double fpscr;
|
||||
double fpr[32];
|
||||
|
||||
uint16_t spinLockCount;
|
||||
uint16_t state;
|
||||
|
||||
uint32_t gqr[8];
|
||||
uint32_t pir;
|
||||
double psf[32];
|
||||
|
||||
uint64_t coretime[3];
|
||||
uint64_t starttime;
|
||||
|
||||
uint32_t error;
|
||||
uint32_t attributes;
|
||||
|
||||
uint32_t pmc1;
|
||||
uint32_t pmc2;
|
||||
uint32_t pmc3;
|
||||
uint32_t pmc4;
|
||||
uint32_t mmcr0;
|
||||
uint32_t mmcr1;
|
||||
} OSContext;
|
||||
|
||||
typedef int (*ThreadFunc)(int argc, void *argv);
|
||||
|
||||
typedef struct OSThreadLink_ {
|
||||
OSThread *next;
|
||||
OSThread *prev;
|
||||
} OSThreadLink;
|
||||
|
||||
struct OSThread_ {
|
||||
OSContext context;
|
||||
|
||||
uint32_t txtTag;
|
||||
uint8_t state;
|
||||
uint8_t attr;
|
||||
|
||||
short threadId;
|
||||
int suspend;
|
||||
int priority;
|
||||
|
||||
char _[0x394 - 0x330 - sizeof(OSThreadLink)];
|
||||
OSThreadLink linkActive;
|
||||
|
||||
void *stackBase;
|
||||
void *stackEnd;
|
||||
|
||||
ThreadFunc entryPoint;
|
||||
|
||||
char _3A0[0x6A0 - 0x3A0];
|
||||
};
|
||||
|
||||
typedef struct OSThreadQueue_ {
|
||||
OSThread *head;
|
||||
OSThread *tail;
|
||||
void *parentStruct;
|
||||
uint32_t reserved;
|
||||
} OSThreadQueue;
|
||||
|
||||
typedef struct OSMessage_ {
|
||||
uint32_t message;
|
||||
uint32_t data0;
|
||||
uint32_t data1;
|
||||
uint32_t data2;
|
||||
} OSMessage;
|
||||
|
||||
typedef struct OSMessageQueue_ {
|
||||
uint32_t tag;
|
||||
char *name;
|
||||
uint32_t reserved;
|
||||
|
||||
OSThreadQueue sendQueue;
|
||||
OSThreadQueue recvQueue;
|
||||
OSMessage *messages;
|
||||
int msgCount;
|
||||
int firstIndex;
|
||||
int usedCount;
|
||||
} OSMessageQueue;
|
||||
|
||||
extern void (*DCInvalidateRange)(void *buffer, uint32_t length);
|
||||
extern void (* DCFlushRange)(const void *addr, uint32_t length);
|
||||
extern void (* DCStoreRange)(const void *addr, uint32_t length);
|
||||
extern void (* ICInvalidateRange)(const void *addr, uint32_t length);
|
||||
extern void* (* OSEffectiveToPhysical)(uint32_t);
|
||||
extern void* (* OSSleepTicks)(uint64_t ticks);
|
||||
extern void (* OSEnableHomeButtonMenu)(int32_t);
|
||||
|
||||
|
||||
extern int32_t (* OSCreateThread)(OSThread *thread, int32_t (*callback)(int32_t, void*), int32_t argc, void *args, uint32_t stack, uint32_t stack_size, int32_t priority, uint32_t attr);
|
||||
extern int32_t (* OSResumeThread)(OSThread *thread);
|
||||
extern int32_t (* OSSuspendThread)(OSThread *thread);
|
||||
extern int32_t (* OSIsThreadTerminated)(OSThread *thread);
|
||||
extern int32_t (* OSIsThreadSuspended)(OSThread *thread);
|
||||
extern int32_t (* OSJoinThread)(OSThread * thread, int32_t * ret_val);
|
||||
extern int32_t (* OSSetThreadPriority)(OSThread * thread, int32_t priority);
|
||||
extern void (* OSDetachThread)(OSThread * thread);
|
||||
extern OSThread * (* OSGetCurrentThread)(void);
|
||||
extern const char * (* OSGetThreadName)(OSThread * thread);
|
||||
|
||||
extern void (* OSGetActiveThreadLink)(OSThread * thread, void* link);
|
||||
extern uint32_t (* OSGetThreadAffinity)(OSThread * thread);
|
||||
extern int32_t (* OSGetThreadPriority)(OSThread * thread);
|
||||
extern void (* OSSetThreadName)(OSThread * thread, const char *name);
|
||||
extern int32_t (* OSGetCoreId)(void);
|
||||
extern uint64_t (* OSGetTitleID)(void);
|
||||
|
||||
extern int32_t (* OSIsHomeButtonMenuEnabled)(void);
|
||||
|
||||
extern int32_t (* MEMCreateExpHeapEx)(void* heap, uint32_t size, uint16_t flags);
|
||||
extern void* (* MEMAllocFromExpHeapEx)( int32_t heap, uint32_t size, int alignment);
|
||||
extern void (* MEMFreeToExpHeap)( int32_t heap, void * block);
|
||||
|
||||
|
||||
extern void(*OSScreenInit)();
|
||||
extern unsigned int(*OSScreenGetBufferSizeEx)(unsigned int bufferNum);
|
||||
extern unsigned int(*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr);
|
||||
extern unsigned int(*OSScreenFlipBuffersEx)(unsigned int x);
|
||||
extern int32_t (*OSScreenEnableEx)(uint32_t bufferNum, int32_t enable);
|
||||
extern int32_t (*OSScreenPutFontEx)(uint32_t bufferNum, uint32_t posX, uint32_t posY, const char * buffer);
|
||||
extern unsigned int(*OSScreenClearBufferEx)(unsigned int bufferNum, unsigned int temp);
|
||||
|
||||
extern void (* OSInitMutex)(void* mutex);
|
||||
extern void (* OSLockMutex)(void* mutex);
|
||||
extern void (* OSUnlockMutex)(void* mutex);
|
||||
extern int32_t (* OSTryLockMutex)(void* mutex);
|
||||
|
||||
|
||||
extern uint32_t coreinit_handle;
|
||||
|
||||
extern uint32_t *pMEMAllocFromDefaultHeapEx;
|
||||
extern uint32_t *pMEMAllocFromDefaultHeap;
|
||||
extern uint32_t *pMEMFreeToDefaultHeap;
|
||||
|
||||
void InitAcquireOS();
|
||||
void InitOSFunctionPointers(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __COREINIT_H_
|
93
src/dynamic_libs/fs_defs.h
Normal file
@ -0,0 +1,93 @@
|
||||
#ifndef FS_DEFS_H
|
||||
#define FS_DEFS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "dynamic_libs/coreinit.h"
|
||||
|
||||
/* FS defines and types */
|
||||
#define FS_MAX_LOCALPATH_SIZE 511
|
||||
#define FS_MAX_MOUNTPATH_SIZE 128
|
||||
#define FS_MAX_FULLPATH_SIZE (FS_MAX_LOCALPATH_SIZE + FS_MAX_MOUNTPATH_SIZE)
|
||||
#define FS_MAX_ARGPATH_SIZE FS_MAX_FULLPATH_SIZE
|
||||
|
||||
#define FS_STATUS_OK 0
|
||||
#define FS_STATUS_EOF -2
|
||||
#define FS_STATUS_FATAL_ERROR -0x400
|
||||
#define FS_RET_UNSUPPORTED_CMD 0x0400
|
||||
#define FS_RET_NO_ERROR 0x0000
|
||||
#define FS_RET_ALL_ERROR (uint32_t)(-1)
|
||||
|
||||
#define FS_IO_BUFFER_ALIGN 64
|
||||
|
||||
#define FS_STAT_FLAG_IS_DIRECTORY 0x80000000
|
||||
|
||||
/* max length of file/dir name */
|
||||
#define FS_MAX_ENTNAME_SIZE 256
|
||||
|
||||
#define FS_SOURCETYPE_EXTERNAL 0
|
||||
#define FS_SOURCETYPE_HFIO 1
|
||||
|
||||
#define FS_MOUNT_SOURCE_SIZE 0x300
|
||||
#define FS_CLIENT_SIZE 0x1700
|
||||
#define FS_CMD_BLOCK_SIZE 0xA80
|
||||
|
||||
typedef struct FSClient_ {
|
||||
uint8_t buffer[FS_CLIENT_SIZE];
|
||||
} FSClient;
|
||||
|
||||
typedef struct FSCmdBlock_ {
|
||||
uint8_t buffer[FS_CMD_BLOCK_SIZE];
|
||||
} FSCmdBlock;
|
||||
|
||||
typedef struct {
|
||||
uint32_t flag;
|
||||
uint32_t permission;
|
||||
uint32_t owner_id;
|
||||
uint32_t group_id;
|
||||
uint32_t size;
|
||||
uint32_t alloc_size;
|
||||
uint64_t quota_size;
|
||||
uint32_t ent_id;
|
||||
uint64_t ctime;
|
||||
uint64_t mtime;
|
||||
uint8_t attributes[48];
|
||||
} __attribute__((packed)) FSStat;
|
||||
|
||||
typedef struct {
|
||||
FSStat stat;
|
||||
char name[FS_MAX_ENTNAME_SIZE];
|
||||
} FSDirEntry;
|
||||
|
||||
typedef void (*FSAsyncCallback)(FSClient * pClient, FSCmdBlock * pCmd, int32_t result, void *context);
|
||||
typedef struct {
|
||||
FSAsyncCallback userCallback;
|
||||
void *userContext;
|
||||
OSMessageQueue *ioMsgQueue;
|
||||
} FSAsyncParams;
|
||||
|
||||
typedef struct {
|
||||
void* data; // pointer to a FSAsyncResult;
|
||||
uint32_t unkwn1;
|
||||
uint32_t unkwn2;
|
||||
uint32_t unkwn3; // always 0x08
|
||||
} __attribute__((packed)) FSMessage;
|
||||
|
||||
typedef struct FSAsyncResult_ {
|
||||
FSAsyncParams userParams;
|
||||
FSMessage ioMsg;
|
||||
|
||||
FSClient * client;
|
||||
FSCmdBlock * block;
|
||||
uint32_t result;
|
||||
} FSAsyncResult;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FS_DEFS_H */
|
||||
|
141
src/dynamic_libs/fs_functions.c
Normal file
@ -0,0 +1,141 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "fs_functions.h"
|
||||
#include "coreinit.h"
|
||||
|
||||
EXPORT_DECL(int32_t, FSInit, void);
|
||||
EXPORT_DECL(int32_t, FSShutdown, void);
|
||||
EXPORT_DECL(int32_t, FSAddClient, void *pClient, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSAddClientEx, void *pClient, int32_t unk_zero_param, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSDelClient, void *pClient);
|
||||
EXPORT_DECL(void, FSInitCmdBlock, void *pCmd);
|
||||
EXPORT_DECL(void *, FSGetCurrentCmdBlock, void *pClient);
|
||||
EXPORT_DECL(int32_t, FSGetMountSource, void *pClient, void *pCmd, int32_t type, void *source, int32_t errHandling);
|
||||
|
||||
EXPORT_DECL(int32_t, FSMount, void *pClient, void *pCmd, void *source, char *target, uint32_t bytes, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSUnmount, void *pClient, void *pCmd, const char *target, int32_t errHandling);
|
||||
|
||||
EXPORT_DECL(int32_t, FSGetStat, void *pClient, void *pCmd, const char *path, FSStat *stats, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSGetStatAsync, void *pClient, void *pCmd, const char *path, void *stats, int32_t error, void *asyncParams);
|
||||
EXPORT_DECL(int32_t, FSRename, void *pClient, void *pCmd, const char *oldPath, const char *newPath, int32_t error);
|
||||
EXPORT_DECL(int32_t, FSRenameAsync, void *pClient, void *pCmd, const char *oldPath, const char *newPath, int32_t error, void *asyncParams);
|
||||
EXPORT_DECL(int32_t, FSRemove, void *pClient, void *pCmd, const char *path, int32_t error);
|
||||
EXPORT_DECL(int32_t, FSRemoveAsync, void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
EXPORT_DECL(int32_t, FSFlushQuota, void *pClient, void *pCmd, const char* path, int32_t error);
|
||||
EXPORT_DECL(int32_t, FSFlushQuotaAsync, void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
EXPORT_DECL(int32_t, FSGetFreeSpaceSize, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int32_t error);
|
||||
EXPORT_DECL(int32_t, FSGetFreeSpaceSizeAsync, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int32_t error, void *asyncParams);
|
||||
EXPORT_DECL(int32_t, FSRollbackQuota, void *pClient, void *pCmd, const char *path, int32_t error);
|
||||
EXPORT_DECL(int32_t, FSRollbackQuotaAsync, void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
|
||||
EXPORT_DECL(int32_t, FSOpenDir, void *pClient, void *pCmd, const char *path, int32_t *dh, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSOpenDirAsync, void *pClient, void* pCmd, const char *path, int32_t *handle, int32_t error, void *asyncParams);
|
||||
EXPORT_DECL(int32_t, FSReadDir, void *pClient, void *pCmd, int32_t dh, FSDirEntry *dir_entry, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSRewindDir, void *pClient, void *pCmd, int32_t dh, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSCloseDir, void *pClient, void *pCmd, int32_t dh, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSChangeDir, void *pClient, void *pCmd, const char *path, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSChangeDirAsync, void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
EXPORT_DECL(int32_t, FSMakeDir, void *pClient, void *pCmd, const char *path, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSMakeDirAsync, void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
|
||||
EXPORT_DECL(int32_t, FSOpenFile, void *pClient, void *pCmd, const char *path, const char *mode, int32_t *fd, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSOpenFileAsync, void *pClient, void *pCmd, const char *path, const char *mode, int32_t *handle, int32_t error, const void *asyncParams);
|
||||
EXPORT_DECL(int32_t, FSReadFile, void *pClient, void *pCmd, void *buffer, int32_t size, int32_t count, int32_t fd, int32_t flag, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSCloseFile, void *pClient, void *pCmd, int32_t fd, int32_t errHandling);
|
||||
|
||||
EXPORT_DECL(int32_t, FSFlushFile, void *pClient, void *pCmd, int32_t fd, int32_t error);
|
||||
EXPORT_DECL(int32_t, FSTruncateFile, void *pClient, void *pCmd, int32_t fd, int32_t error);
|
||||
EXPORT_DECL(int32_t, FSGetStatFile, void *pClient, void *pCmd, int32_t fd, void *buffer, int32_t error);
|
||||
EXPORT_DECL(int32_t, FSSetPosFile, void *pClient, void *pCmd, int32_t fd, uint32_t pos, int32_t error);
|
||||
EXPORT_DECL(int32_t, FSWriteFile, void *pClient, void *pCmd, const void *source, int32_t block_size, int32_t block_count, int32_t fd, int32_t flag, int32_t error);
|
||||
|
||||
EXPORT_DECL(int32_t, FSBindMount, void *pClient, void *pCmd, char *source, char *target, int32_t error);
|
||||
EXPORT_DECL(int32_t, FSBindUnmount, void *pClient, void *pCmd, char *target, int32_t error);
|
||||
|
||||
EXPORT_DECL(int32_t, FSMakeQuota, void *pClient, void *pCmd, const char *path,uint32_t mode, uint64_t size, int32_t errHandling);
|
||||
EXPORT_DECL(int32_t, FSMakeQuotaAsync ,void *pClient, void *pCmd, const char *path,uint32_t mode, uint64_t size, int32_t errHandling,const void *asyncParams);
|
||||
|
||||
EXPORT_DECL(int32_t, FSGetCwd,void * client,void * block,char * buffer,uint32_t bufferSize,uint32_t flags);
|
||||
|
||||
void InitFSFunctionPointers(void) {
|
||||
if(coreinit_handle == 0) {
|
||||
InitAcquireOS();
|
||||
};
|
||||
uint32_t *funcPointer = 0;
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSInit);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSShutdown);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSAddClient);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSAddClientEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSDelClient);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSInitCmdBlock);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetCurrentCmdBlock);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetMountSource);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSMount);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSUnmount);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetStat);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetStatAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRename);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRenameAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRemove);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRemoveAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSFlushQuota);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSFlushQuotaAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetFreeSpaceSize);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetFreeSpaceSizeAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRollbackQuota);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRollbackQuotaAsync);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSOpenDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSOpenDirAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSReadDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRewindDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSCloseDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSChangeDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSChangeDirAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSMakeDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSMakeDirAsync);
|
||||
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSOpenFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSOpenFileAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSReadFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSCloseFile);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSFlushFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSTruncateFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetStatFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSSetPosFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSWriteFile);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSBindMount);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSBindUnmount);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSMakeQuota);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSMakeQuotaAsync);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetCwd);
|
||||
}
|
99
src/dynamic_libs/fs_functions.h
Normal file
@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __FS_FUNCTIONS_H_
|
||||
#define __FS_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fs_defs.h"
|
||||
|
||||
void InitFSFunctionPointers(void);
|
||||
|
||||
extern int32_t (* FSInit)(void);
|
||||
extern int32_t (* FSShutdown)(void);
|
||||
extern int32_t (* FSAddClient)(void *pClient, int32_t errHandling);
|
||||
extern int32_t (* FSAddClientEx)(void *pClient, int32_t unk_zero_param, int32_t errHandling);
|
||||
extern int32_t (* FSDelClient)(void *pClient);
|
||||
extern void (* FSInitCmdBlock)(void *pCmd);
|
||||
extern void *(* FSGetCurrentCmdBlock)(void *pClient);
|
||||
extern int32_t (* FSGetMountSource)(void *pClient, void *pCmd, int32_t type, void *source, int32_t errHandling);
|
||||
|
||||
extern int32_t (* FSMount)(void *pClient, void *pCmd, void *source, char *target, uint32_t bytes, int32_t errHandling);
|
||||
extern int32_t (* FSUnmount)(void *pClient, void *pCmd, const char *target, int32_t errHandling);
|
||||
extern int32_t (* FSRename)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int32_t error);
|
||||
extern int32_t (* FSRenameAsync)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int32_t error, void *asyncParams);
|
||||
extern int32_t (* FSRemove)(void *pClient, void *pCmd, const char *path, int32_t error);
|
||||
extern int32_t (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
|
||||
extern int32_t (* FSGetStat)(void *pClient, void *pCmd, const char *path, FSStat *stats, int32_t errHandling);
|
||||
extern int32_t (* FSGetStatAsync)(void *pClient, void *pCmd, const char *path, void *stats, int32_t error, void *asyncParams);
|
||||
extern int32_t (* FSRename)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int32_t error);
|
||||
extern int32_t (* FSRenameAsync)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int32_t error, void *asyncParams);
|
||||
extern int32_t (* FSRemove)(void *pClient, void *pCmd, const char *path, int32_t error);
|
||||
extern int32_t (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
extern int32_t (* FSFlushQuota)(void *pClient, void *pCmd, const char* path, int32_t error);
|
||||
extern int32_t (* FSFlushQuotaAsync)(void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
extern int32_t (* FSGetFreeSpaceSize)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int32_t error);
|
||||
extern int32_t (* FSGetFreeSpaceSizeAsync)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int32_t error, void *asyncParams);
|
||||
extern int32_t (* FSRollbackQuota)(void *pClient, void *pCmd, const char *path, int32_t error);
|
||||
extern int32_t (* FSRollbackQuotaAsync)(void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
|
||||
extern int32_t (* FSOpenDir)(void *pClient, void *pCmd, const char *path, int32_t *dh, int32_t errHandling);
|
||||
extern int32_t (* FSOpenDirAsync)(void *pClient, void* pCmd, const char *path, int32_t *handle, int32_t error, void *asyncParams);
|
||||
extern int32_t (* FSReadDir)(void *pClient, void *pCmd, int32_t dh, FSDirEntry *dir_entry, int32_t errHandling);
|
||||
extern int32_t (* FSRewindDir)(void *pClient, void *pCmd, int32_t dh, int32_t errHandling);
|
||||
extern int32_t (* FSCloseDir)(void *pClient, void *pCmd, int32_t dh, int32_t errHandling);
|
||||
extern int32_t (* FSChangeDir)(void *pClient, void *pCmd, const char *path, int32_t errHandling);
|
||||
extern int32_t (* FSChangeDirAsync)(void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
extern int32_t (* FSMakeDir)(void *pClient, void *pCmd, const char *path, int32_t errHandling);
|
||||
extern int32_t (* FSMakeDirAsync)(void *pClient, void *pCmd, const char *path, int32_t error, void *asyncParams);
|
||||
|
||||
extern int32_t (* FSOpenFile)(void *pClient, void *pCmd, const char *path, const char *mode, int32_t *fd, int32_t errHandling);
|
||||
extern int32_t (* FSOpenFileAsync)(void *pClient, void *pCmd, const char *path, const char *mode, int32_t *handle, int32_t error, const void *asyncParams);
|
||||
extern int32_t (* FSReadFile)(void *pClient, void *pCmd, void *buffer, int32_t size, int32_t count, int32_t fd, int32_t flag, int32_t errHandling);
|
||||
extern int32_t (* FSCloseFile)(void *pClient, void *pCmd, int32_t fd, int32_t errHandling);
|
||||
|
||||
extern int32_t (* FSFlushFile)(void *pClient, void *pCmd, int32_t fd, int32_t error);
|
||||
extern int32_t (* FSTruncateFile)(void *pClient, void *pCmd, int32_t fd, int32_t error);
|
||||
extern int32_t (* FSGetStatFile)(void *pClient, void *pCmd, int32_t fd, void *buffer, int32_t error);
|
||||
extern int32_t (* FSSetPosFile)(void *pClient, void *pCmd, int32_t fd, uint32_t pos, int32_t error);
|
||||
extern int32_t (* FSWriteFile)(void *pClient, void *pCmd, const void *source, int32_t block_size, int32_t block_count, int32_t fd, int32_t flag, int32_t error);
|
||||
|
||||
extern int32_t (* FSBindMount)(void *pClient, void *pCmd, char *source, char *target, int32_t error);
|
||||
extern int32_t (* FSBindUnmount)(void *pClient, void *pCmd, char *target, int32_t error);
|
||||
|
||||
extern int32_t (* FSMakeQuota)( void *pClient, void *pCmd, const char *path,uint32_t mode, uint64_t size, int32_t errHandling);
|
||||
extern int32_t (* FSMakeQuotaAsync)(void *pClient, void *pCmd, const char *path,uint32_t mode, uint64_t size, int32_t errHandling,const void *asyncParams);
|
||||
|
||||
extern int32_t (* FSGetCwd)(void * client,void * block,char * buffer,uint32_t bufferSize,uint32_t flags);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __FS_FUNCTIONS_H_
|
187
src/dynamic_libs/gx2_functions.c
Normal file
@ -0,0 +1,187 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "coreinit.h"
|
||||
#include "gx2_types.h"
|
||||
|
||||
uint32_t gx2_handle __attribute__((section(".data"))) = 0;
|
||||
|
||||
EXPORT_DECL(void, GX2Init, uint32_t * init_attribs);
|
||||
EXPORT_DECL(void, GX2Shutdown, void);
|
||||
EXPORT_DECL(void, GX2Flush, void);
|
||||
EXPORT_DECL(int32_t, GX2GetMainCoreId, void) ;
|
||||
EXPORT_DECL(int32_t, GX2DrawDone, void);
|
||||
EXPORT_DECL(void, GX2ClearColor, GX2ColorBuffer *colorBuffer, float r, float g, float b, float a);
|
||||
EXPORT_DECL(void, GX2SetViewport, float x, float y, float w, float h, float nearZ, float farZ);
|
||||
EXPORT_DECL(void, GX2SetScissor, uint32_t x_orig, uint32_t y_orig, uint32_t wd, uint32_t ht);
|
||||
EXPORT_DECL(void, GX2SetContextState, const GX2ContextState* state);
|
||||
EXPORT_DECL(void, GX2DrawEx, int32_t primitive_type, uint32_t count, uint32_t first_vertex, uint32_t instances_count);
|
||||
EXPORT_DECL(void, GX2DrawIndexedEx, int32_t primitive_type, uint32_t count, int32_t index_format, const void* idx, uint32_t first_vertex, uint32_t instances_count);
|
||||
EXPORT_DECL(void, GX2ClearDepthStencilEx, GX2DepthBuffer *depthBuffer, float depth_value, uint8_t stencil_value, int32_t clear_mode);
|
||||
EXPORT_DECL(void, GX2SetClearDepthStencil, GX2DepthBuffer *depthBuffer, float depth_value, uint8_t stencil_value);
|
||||
EXPORT_DECL(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, int32_t scan_target);
|
||||
EXPORT_DECL(void, GX2SwapScanBuffers, void);
|
||||
EXPORT_DECL(void, GX2SetTVEnable, int32_t enable);
|
||||
EXPORT_DECL(void, GX2SetSwapInterval, uint32_t swap_interval);
|
||||
EXPORT_DECL(uint32_t, GX2GetSwapInterval, void);
|
||||
EXPORT_DECL(void, GX2WaitForVsync, void);
|
||||
EXPORT_DECL(void, GX2CalcTVSize, int32_t tv_render_mode, int32_t format, int32_t buffering_mode, uint32_t * size, int32_t * scale_needed);
|
||||
EXPORT_DECL(void, GX2Invalidate, int32_t invalidate_type, void * ptr, uint32_t buffer_size);
|
||||
EXPORT_DECL(void, GX2SetTVBuffer, void *buffer, uint32_t buffer_size, int32_t tv_render_mode, int32_t format, int32_t buffering_mode);
|
||||
EXPORT_DECL(void, GX2CalcSurfaceSizeAndAlignment, GX2Surface *surface);
|
||||
EXPORT_DECL(void, GX2InitDepthBufferRegs, GX2DepthBuffer *depthBuffer);
|
||||
EXPORT_DECL(void, GX2InitColorBufferRegs, GX2ColorBuffer *colorBuffer);
|
||||
EXPORT_DECL(void, GX2CalcColorBufferAuxInfo, GX2ColorBuffer *colorBuffer, uint32_t *size, uint32_t *align);
|
||||
EXPORT_DECL(void, GX2CalcDepthBufferHiZInfo, GX2DepthBuffer *depthBuffer, uint32_t *size, uint32_t *align);
|
||||
EXPORT_DECL(void, GX2InitDepthBufferHiZEnable, GX2DepthBuffer *depthBuffer, int32_t hiZ_enable);
|
||||
EXPORT_DECL(void, GX2SetupContextStateEx, GX2ContextState* state, int32_t enable_profiling);
|
||||
EXPORT_DECL(void, GX2SetColorBuffer, const GX2ColorBuffer *colorBuffer, int32_t target);
|
||||
EXPORT_DECL(void, GX2SetDepthBuffer, const GX2DepthBuffer *depthBuffer);
|
||||
EXPORT_DECL(void, GX2SetAttribBuffer, uint32_t attr_index, uint32_t attr_size, uint32_t stride, const void* attr);
|
||||
EXPORT_DECL(void, GX2InitTextureRegs, GX2Texture *texture);
|
||||
EXPORT_DECL(void, GX2InitSampler, GX2Sampler *sampler, int32_t tex_clamp, int32_t min_mag_filter);
|
||||
EXPORT_DECL(uint32_t, GX2CalcFetchShaderSizeEx, uint32_t num_attrib, int32_t fetch_shader_type, int32_t tessellation_mode);
|
||||
EXPORT_DECL(void, GX2InitFetchShaderEx, GX2FetchShader* fs, void* fs_buffer, uint32_t count, const GX2AttribStream* attribs, int32_t fetch_shader_type, int32_t tessellation_mode);
|
||||
EXPORT_DECL(void, GX2SetFetchShader, const GX2FetchShader* fs);
|
||||
EXPORT_DECL(void, GX2SetVertexUniformReg, uint32_t offset, uint32_t count, const void *values);
|
||||
EXPORT_DECL(void, GX2SetPixelUniformReg, uint32_t offset, uint32_t count, const void *values);
|
||||
EXPORT_DECL(void, GX2SetPixelTexture, const GX2Texture *texture, uint32_t texture_hw_location);
|
||||
EXPORT_DECL(void, GX2SetVertexTexture, const GX2Texture *texture, uint32_t texture_hw_location);
|
||||
EXPORT_DECL(void, GX2SetPixelSampler, const GX2Sampler *sampler, uint32_t sampler_hw_location);
|
||||
EXPORT_DECL(void, GX2SetVertexSampler, const GX2Sampler *sampler, uint32_t sampler_hw_location);
|
||||
EXPORT_DECL(void, GX2SetPixelShader, const GX2PixelShader* pixelShader);
|
||||
EXPORT_DECL(void, GX2SetVertexShader, const GX2VertexShader* vertexShader);
|
||||
EXPORT_DECL(void, GX2InitSamplerZMFilter, GX2Sampler *sampler, int32_t z_filter, int32_t mip_filter);
|
||||
EXPORT_DECL(void, GX2SetColorControl, int32_t lop, uint8_t blend_enable_mask, int32_t enable_multi_write, int32_t enable_color_buffer);
|
||||
EXPORT_DECL(void, GX2SetDepthOnlyControl, int32_t enable_depth, int32_t enable_depth_write, int32_t depth_comp_function);
|
||||
EXPORT_DECL(void, GX2SetBlendControl, int32_t target, int32_t color_src_blend, int32_t color_dst_blend, int32_t color_combine, int32_t separate_alpha_blend, int32_t alpha_src_blend, int32_t alpha_dst_blend, int32_t alpha_combine);
|
||||
EXPORT_DECL(void, GX2CalcDRCSize, int32_t drc_mode, int32_t format, int32_t buffering_mode, uint32_t *size, int32_t *scale_needed);
|
||||
EXPORT_DECL(void, GX2SetDRCBuffer, void *buffer, uint32_t buffer_size, int32_t drc_mode, int32_t surface_format, int32_t buffering_mode);
|
||||
EXPORT_DECL(void, GX2SetDRCScale, uint32_t width, uint32_t height);
|
||||
EXPORT_DECL(void, GX2SetDRCEnable, int32_t enable);
|
||||
EXPORT_DECL(void, GX2SetPolygonControl, int32_t front_face_mode, int32_t cull_front, int32_t cull_back, int32_t enable_mode, int32_t mode_font, int32_t mode_back, int32_t poly_offset_front, int32_t poly_offset_back, int32_t point_line_offset);
|
||||
EXPORT_DECL(void, GX2SetCullOnlyControl, int32_t front_face_mode, int32_t cull_front, int32_t cull_back);
|
||||
EXPORT_DECL(void, GX2SetDepthStencilControl, int32_t enable_depth_test, int32_t enable_depth_write, int32_t depth_comp_function, int32_t stencil_test_enable, int32_t back_stencil_enable,
|
||||
int32_t font_stencil_func, int32_t front_stencil_z_pass, int32_t front_stencil_z_fail, int32_t front_stencil_fail,
|
||||
int32_t back_stencil_func, int32_t back_stencil_z_pass, int32_t back_stencil_z_fail, int32_t back_stencil_fail);
|
||||
EXPORT_DECL(void, GX2SetStencilMask, uint8_t mask_front, uint8_t write_mask_front, uint8_t ref_front, uint8_t mask_back, uint8_t write_mask_back, uint8_t ref_back);
|
||||
EXPORT_DECL(void, GX2SetLineWidth, float width);
|
||||
EXPORT_DECL(void, GX2SetTVGamma, float val);
|
||||
EXPORT_DECL(void, GX2SetDRCGamma, float gam);
|
||||
EXPORT_DECL(int32_t, GX2GetSystemTVScanMode, void);
|
||||
EXPORT_DECL(int32_t, GX2GetSystemDRCScanMode, void);
|
||||
EXPORT_DECL(void, GX2RSetAllocator, void * (* allocFunc)(uint32_t, uint32_t, uint32_t), void (* freeFunc)(uint32_t, void*));
|
||||
EXPORT_DECL(void, GX2CopySurface, GX2Surface * srcSurface,uint32_t srcMip,uint32_t srcSlice,GX2Surface * dstSurface,uint32_t dstMip,uint32_t dstSlice );
|
||||
|
||||
EXPORT_DECL(int32_t, GX2GetLastFrame, int32_t target, GX2Texture * texture);
|
||||
EXPORT_DECL(void, GX2BeginDisplayListEx,void * displayList,uint32_t size,int32_t unkwn);
|
||||
EXPORT_DECL(uint32_t, GX2EndDisplayList, void * list);
|
||||
EXPORT_DECL(void, GX2CallDisplayList, void * list, uint32_t size);
|
||||
EXPORT_DECL(void, GX2ExpandAAColorBuffer,GX2ColorBuffer * buffer);
|
||||
EXPORT_DECL(void, GX2ResolveAAColorBuffer, const GX2ColorBuffer * srcBuffer, GX2Surface * dstSurface,uint32_t dstMip,uint32_t dstSlice);
|
||||
|
||||
EXPORT_DECL(void, GX2ClearBuffersEx, GX2ColorBuffer * colorBuffer,GX2DepthBuffer * depthBuffer,float r, float g, float b, float a,float depthValue,uint8_t stencilValue,int32_t clearFlags);
|
||||
|
||||
void InitAcquireGX2(void) {
|
||||
if(coreinit_handle == 0) {
|
||||
InitAcquireOS();
|
||||
};
|
||||
OSDynLoad_Acquire("gx2.rpl", &gx2_handle);
|
||||
}
|
||||
|
||||
void InitGX2FunctionPointers(void) {
|
||||
uint32_t *funcPointer = 0;
|
||||
InitAcquireGX2();
|
||||
|
||||
OS_FIND_EXPORT(gx2_handle, GX2Init);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2Shutdown);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2Flush);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2GetMainCoreId);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2DrawDone);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2ClearColor);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetViewport);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetScissor);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetContextState);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2DrawEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2DrawIndexedEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2ClearDepthStencilEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CopyColorBufferToScanBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SwapScanBuffers);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetTVEnable);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetSwapInterval);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2GetSwapInterval);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2WaitForVsync);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcTVSize);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2Invalidate);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetTVBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcSurfaceSizeAndAlignment);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitDepthBufferRegs);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitColorBufferRegs);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcColorBufferAuxInfo);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcDepthBufferHiZInfo);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitDepthBufferHiZEnable);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetupContextStateEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetColorBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDepthBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetAttribBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitTextureRegs);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitSampler);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcFetchShaderSizeEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitFetchShaderEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetFetchShader);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetVertexUniformReg);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetPixelUniformReg);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetPixelTexture);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetVertexTexture);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetPixelSampler);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetVertexSampler);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetPixelShader);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetVertexShader);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitSamplerZMFilter);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetColorControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDepthOnlyControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetBlendControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcDRCSize);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDRCBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDRCScale);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDRCEnable);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetPolygonControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetCullOnlyControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDepthStencilControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetStencilMask);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetLineWidth);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDRCGamma);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetTVGamma);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2GetSystemTVScanMode);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2GetSystemDRCScanMode);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2RSetAllocator);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CopySurface);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2GetLastFrame);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2ClearBuffersEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2BeginDisplayListEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2EndDisplayList);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CallDisplayList);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2ExpandAAColorBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2ResolveAAColorBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetClearDepthStencil);
|
||||
}
|
213
src/dynamic_libs/gx2_functions.h
Normal file
@ -0,0 +1,213 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __GX2_FUNCTIONS_H_
|
||||
#define __GX2_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "gx2_types.h"
|
||||
|
||||
extern uint32_t gx2_handle;
|
||||
|
||||
void InitGX2FunctionPointers(void);
|
||||
void InitAcquireGX2(void);
|
||||
|
||||
extern void (* GX2Init)(uint32_t * init_attribs);
|
||||
extern void (* GX2Shutdown)(void);
|
||||
extern void (* GX2Flush)(void);
|
||||
extern int32_t (* GX2GetMainCoreId)(void) ;
|
||||
extern int32_t (* GX2DrawDone)(void);
|
||||
extern void (* GX2ClearColor)(GX2ColorBuffer *colorBuffer, float r, float g, float b, float a);
|
||||
extern void (* GX2SetViewport)(float x, float y, float w, float h, float nearZ, float farZ);
|
||||
extern void (* GX2SetScissor)(uint32_t x_orig, uint32_t y_orig, uint32_t wd, uint32_t ht);
|
||||
extern void (* GX2SetContextState)(const GX2ContextState* state);
|
||||
extern void (* GX2DrawEx)(int32_t primitive_type, uint32_t count, uint32_t first_vertex, uint32_t instances_count);
|
||||
extern void (* GX2DrawIndexedEx)(int32_t primitive_type, uint32_t count, int32_t index_format, const void* idx, uint32_t first_vertex, uint32_t instances_count);
|
||||
extern void (* GX2ClearDepthStencilEx)(GX2DepthBuffer *depthBuffer, float depth_value, uint8_t stencil_value, int32_t clear_mode);
|
||||
extern void (* GX2SetClearDepthStencil)(GX2DepthBuffer *depthBuffer, float depth_value, uint8_t stencil_value);
|
||||
extern void (* GX2CopyColorBufferToScanBuffer)(const GX2ColorBuffer *colorBuffer, int32_t scan_target);
|
||||
extern void (* GX2SwapScanBuffers)(void);
|
||||
extern void (* GX2SetTVEnable)(int32_t enable);
|
||||
extern void (* GX2SetSwapInterval)(uint32_t swap_interval);
|
||||
extern uint32_t (* GX2GetSwapInterval)(void);
|
||||
extern void (* GX2WaitForVsync)(void);
|
||||
extern void (* GX2CalcTVSize)(int32_t tv_render_mode, int32_t format, int32_t buffering_mode, uint32_t * size, int32_t * scale_needed);
|
||||
extern void (* GX2Invalidate)(int32_t invalidate_type, void * ptr, uint32_t buffer_size);
|
||||
extern void (* GX2SetTVBuffer)(void *buffer, uint32_t buffer_size, int32_t tv_render_mode, int32_t format, int32_t buffering_mode);
|
||||
extern void (* GX2CalcSurfaceSizeAndAlignment)(GX2Surface *surface);
|
||||
extern void (* GX2InitDepthBufferRegs)(GX2DepthBuffer *depthBuffer);
|
||||
extern void (* GX2InitColorBufferRegs)(GX2ColorBuffer *colorBuffer);
|
||||
extern void (* GX2CalcColorBufferAuxInfo)(GX2ColorBuffer *colorBuffer, uint32_t *size, uint32_t *align);
|
||||
extern void (* GX2CalcDepthBufferHiZInfo)(GX2DepthBuffer *depthBuffer, uint32_t *size, uint32_t *align);
|
||||
extern void (* GX2InitDepthBufferHiZEnable)(GX2DepthBuffer *depthBuffer, int32_t hiZ_enable);
|
||||
extern void (* GX2SetupContextStateEx)(GX2ContextState* state, int32_t enable_profiling);
|
||||
extern void (* GX2SetColorBuffer)(const GX2ColorBuffer *colorBuffer, int32_t target);
|
||||
extern void (* GX2SetDepthBuffer)(const GX2DepthBuffer *depthBuffer);
|
||||
extern void (* GX2SetAttribBuffer)(uint32_t attr_index, uint32_t attr_size, uint32_t stride, const void* attr);
|
||||
extern void (* GX2InitTextureRegs)(GX2Texture *texture);
|
||||
extern void (* GX2InitSampler)(GX2Sampler *sampler, int32_t tex_clamp, int32_t min_mag_filter);
|
||||
extern uint32_t (* GX2CalcFetchShaderSizeEx)(uint32_t num_attrib, int32_t fetch_shader_type, int32_t tessellation_mode);
|
||||
extern void (* GX2InitFetchShaderEx)(GX2FetchShader* fs, void* fs_buffer, uint32_t count, const GX2AttribStream* attribs, int32_t fetch_shader_type, int32_t tessellation_mode);
|
||||
extern void (* GX2SetFetchShader)(const GX2FetchShader* fs);
|
||||
extern void (* GX2SetVertexUniformReg)(uint32_t offset, uint32_t count, const void *values);
|
||||
extern void (* GX2SetPixelUniformReg)(uint32_t offset, uint32_t count, const void *values);
|
||||
extern void (* GX2SetPixelTexture)(const GX2Texture *texture, uint32_t texture_hw_location);
|
||||
extern void (* GX2SetVertexTexture)(const GX2Texture *texture, uint32_t texture_hw_location);
|
||||
extern void (* GX2SetPixelSampler)(const GX2Sampler *sampler, uint32_t sampler_hw_location);
|
||||
extern void (* GX2SetVertexSampler)(const GX2Sampler *sampler, uint32_t sampler_hw_location);
|
||||
extern void (* GX2SetPixelShader)(const GX2PixelShader* pixelShader);
|
||||
extern void (* GX2SetVertexShader)(const GX2VertexShader* vertexShader);
|
||||
extern void (* GX2InitSamplerZMFilter)(GX2Sampler *sampler, int32_t z_filter, int32_t mip_filter);
|
||||
extern void (* GX2SetColorControl)(int32_t lop, uint8_t blend_enable_mask, int32_t enable_multi_write, int32_t enable_color_buffer);
|
||||
extern void (* GX2SetDepthOnlyControl)(int32_t enable_depth, int32_t enable_depth_write, int32_t depth_comp_function);
|
||||
extern void (* GX2SetBlendControl)(int32_t target, int32_t color_src_blend, int32_t color_dst_blend, int32_t color_combine, int32_t separate_alpha_blend, int32_t alpha_src_blend, int32_t alpha_dst_blend, int32_t alpha_combine);
|
||||
extern void (* GX2CalcDRCSize)(int32_t drc_mode, int32_t format, int32_t buffering_mode, uint32_t *size, int32_t *scale_needed);
|
||||
extern void (* GX2SetDRCBuffer)(void *buffer, uint32_t buffer_size, int32_t drc_mode, int32_t surface_format, int32_t buffering_mode);
|
||||
extern void (* GX2SetDRCScale)(uint32_t width, uint32_t height);
|
||||
extern void (* GX2SetDRCEnable)(int32_t enable);
|
||||
extern void (* GX2SetPolygonControl)(int32_t front_face_mode, int32_t cull_front, int32_t cull_back, int32_t enable_mode, int32_t mode_font, int32_t mode_back, int32_t poly_offset_front, int32_t poly_offset_back, int32_t point_line_offset);
|
||||
extern void (* GX2SetCullOnlyControl)(int32_t front_face_mode, int32_t cull_front, int32_t cull_back);
|
||||
extern void (* GX2SetDepthStencilControl)(int32_t enable_depth_test, int32_t enable_depth_write, int32_t depth_comp_function, int32_t stencil_test_enable, int32_t back_stencil_enable,
|
||||
int32_t font_stencil_func, int32_t front_stencil_z_pass, int32_t front_stencil_z_fail, int32_t front_stencil_fail,
|
||||
int32_t back_stencil_func, int32_t back_stencil_z_pass, int32_t back_stencil_z_fail, int32_t back_stencil_fail);
|
||||
extern void (* GX2SetStencilMask)(uint8_t mask_front, uint8_t write_mask_front, uint8_t ref_front, uint8_t mask_back, uint8_t write_mask_back, uint8_t ref_back);
|
||||
extern void (* GX2SetLineWidth)(float width);
|
||||
extern void (* GX2SetTVGamma)(float val);
|
||||
extern void (* GX2SetDRCGamma)(float val);
|
||||
extern int32_t (* GX2GetSystemTVScanMode)(void);
|
||||
extern int32_t (* GX2GetSystemDRCScanMode)(void);
|
||||
extern void (* GX2RSetAllocator)(void * (*allocFunc)(uint32_t, uint32_t, uint32_t), void (*freeFunc)(uint32_t, void*));
|
||||
extern void (* GX2CopySurface)(GX2Surface * srcSurface,uint32_t srcMip,uint32_t srcSlice,GX2Surface * dstSurface,uint32_t dstMip,uint32_t dstSlice );
|
||||
extern void (* GX2ClearBuffersEx)(GX2ColorBuffer * colorBuffer,GX2DepthBuffer * depthBuffer,float r, float g, float b, float a,float depthValue,uint8_t stencilValue,int32_t clearFlags);
|
||||
extern int32_t (* GX2GetLastFrame)(int32_t target, GX2Texture * texture);
|
||||
extern void (* GX2BeginDisplayListEx)(void * displayList,uint32_t size,int32_t unkwn);
|
||||
extern uint32_t (*GX2EndDisplayList)(void * list);
|
||||
extern void (*GX2CallDisplayList)(void * list, uint32_t size);
|
||||
extern void (*GX2ExpandAAColorBuffer)(GX2ColorBuffer * buffer);
|
||||
extern void (*GX2ResolveAAColorBuffer)(const GX2ColorBuffer * srcBuffer, GX2Surface * dstSurface,uint32_t dstMip,uint32_t dstSlice);
|
||||
|
||||
static inline void GX2InitDepthBuffer(GX2DepthBuffer *depthBuffer, int32_t dimension, uint32_t width, uint32_t height, uint32_t depth, int32_t format, int32_t aa) {
|
||||
depthBuffer->surface.dimension = dimension;
|
||||
depthBuffer->surface.width = width;
|
||||
depthBuffer->surface.height = height;
|
||||
depthBuffer->surface.depth = depth;
|
||||
depthBuffer->surface.num_mips = 1;
|
||||
depthBuffer->surface.format = format;
|
||||
depthBuffer->surface.aa = aa;
|
||||
depthBuffer->surface.use = ((format==GX2_SURFACE_FORMAT_D_D24_S8_UNORM) || (format==GX2_SURFACE_FORMAT_D_D24_S8_FLOAT)) ? GX2_SURFACE_USE_DEPTH_BUFFER : GX2_SURFACE_USE_DEPTH_BUFFER_TEXTURE;
|
||||
depthBuffer->surface.tile = GX2_TILE_MODE_DEFAULT;
|
||||
depthBuffer->surface.swizzle = 0;
|
||||
depthBuffer->view_mip = 0;
|
||||
depthBuffer->view_first_slice = 0;
|
||||
depthBuffer->view_slices_count = depth;
|
||||
depthBuffer->clear_depth = 1.0f;
|
||||
depthBuffer->clear_stencil = 0;
|
||||
depthBuffer->hiZ_data = NULL;
|
||||
depthBuffer->hiZ_size = 0;
|
||||
GX2CalcSurfaceSizeAndAlignment(&depthBuffer->surface);
|
||||
GX2InitDepthBufferRegs(depthBuffer);
|
||||
}
|
||||
|
||||
static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, int32_t dimension, uint32_t width, uint32_t height, uint32_t depth, int32_t format, int32_t aa) {
|
||||
colorBuffer->surface.dimension = dimension;
|
||||
colorBuffer->surface.width = width;
|
||||
colorBuffer->surface.height = height;
|
||||
colorBuffer->surface.depth = depth;
|
||||
colorBuffer->surface.num_mips = 1;
|
||||
colorBuffer->surface.format = format;
|
||||
colorBuffer->surface.aa = aa;
|
||||
colorBuffer->surface.use = GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE_FTV;
|
||||
colorBuffer->surface.image_size = 0;
|
||||
colorBuffer->surface.image_data = NULL;
|
||||
colorBuffer->surface.mip_size = 0;
|
||||
colorBuffer->surface.mip_data = NULL;
|
||||
colorBuffer->surface.tile = GX2_TILE_MODE_DEFAULT;
|
||||
colorBuffer->surface.swizzle = 0;
|
||||
colorBuffer->surface.align = 0;
|
||||
colorBuffer->surface.pitch = 0;
|
||||
uint32_t i;
|
||||
for(i = 0; i < 13; i++)
|
||||
colorBuffer->surface.mip_offset[i] = 0;
|
||||
colorBuffer->view_mip = 0;
|
||||
colorBuffer->view_first_slice = 0;
|
||||
colorBuffer->view_slices_count = depth;
|
||||
colorBuffer->aux_data = NULL;
|
||||
colorBuffer->aux_size = 0;
|
||||
for(i = 0; i < 5; i++)
|
||||
colorBuffer->regs[i] = 0;
|
||||
|
||||
GX2CalcSurfaceSizeAndAlignment(&colorBuffer->surface);
|
||||
GX2InitColorBufferRegs(colorBuffer);
|
||||
}
|
||||
|
||||
static inline void GX2InitAttribStream(GX2AttribStream* attr, uint32_t location, uint32_t buffer, uint32_t offset, int32_t format) {
|
||||
attr->location = location;
|
||||
attr->buffer = buffer;
|
||||
attr->offset = offset;
|
||||
attr->format = format;
|
||||
attr->index_type = 0;
|
||||
attr->divisor = 0;
|
||||
attr->destination_selector = attribute_dest_comp_selector[format & 0xff];
|
||||
attr->endian_swap = GX2_ENDIANSWAP_DEFAULT;
|
||||
}
|
||||
|
||||
static inline void GX2InitTexture(GX2Texture *tex, uint32_t width, uint32_t height, uint32_t depth, uint32_t num_mips, int32_t format, int32_t dimension, int32_t tile) {
|
||||
tex->surface.dimension = dimension;
|
||||
tex->surface.width = width;
|
||||
tex->surface.height = height;
|
||||
tex->surface.depth = depth;
|
||||
tex->surface.num_mips = num_mips;
|
||||
tex->surface.format = format;
|
||||
tex->surface.aa = GX2_AA_MODE_1X;
|
||||
tex->surface.use = GX2_SURFACE_USE_TEXTURE;
|
||||
tex->surface.image_size = 0;
|
||||
tex->surface.image_data = NULL;
|
||||
tex->surface.mip_size = 0;
|
||||
tex->surface.mip_data = NULL;
|
||||
tex->surface.tile = tile;
|
||||
tex->surface.swizzle = 0;
|
||||
tex->surface.align = 0;
|
||||
tex->surface.pitch = 0;
|
||||
uint32_t i;
|
||||
for(i = 0; i < 13; i++)
|
||||
tex->surface.mip_offset[i] = 0;
|
||||
tex->view_first_mip = 0;
|
||||
tex->view_mips_count = num_mips;
|
||||
tex->view_first_slice = 0;
|
||||
tex->view_slices_count = depth;
|
||||
tex->component_selector = texture_comp_selector[format & 0x3f];
|
||||
for(i = 0; i < 5; i++)
|
||||
tex->regs[i] = 0;
|
||||
|
||||
GX2CalcSurfaceSizeAndAlignment(&tex->surface);
|
||||
GX2InitTextureRegs(tex);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __GX2_FUNCTIONS_H_
|
696
src/dynamic_libs/gx2_types.h
Normal file
@ -0,0 +1,696 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef _GX2_TYPES_H_
|
||||
#define _GX2_TYPES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! Constants
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_COMMAND_BUFFER_SIZE 0x400000
|
||||
#define GX2_SCAN_BUFFER_ALIGNMENT 0x1000
|
||||
#define GX2_SHADER_ALIGNMENT 0x100
|
||||
#define GX2_CONTEXT_STATE_ALIGNMENT 0x100
|
||||
#define GX2_DISPLAY_LIST_ALIGNMENT 0x20
|
||||
#define GX2_VERTEX_BUFFER_ALIGNMENT 0x40
|
||||
#define GX2_INDEX_BUFFER_ALIGNMENT 0x20
|
||||
|
||||
#define GX2_CONTEXT_STATE_SIZE 0xA100
|
||||
|
||||
#define GX2_AUX_BUFFER_CLEAR_VALUE 0xCC
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! Common
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_FALSE 0
|
||||
#define GX2_TRUE 1
|
||||
#define GX2_DISABLE 0
|
||||
#define GX2_ENABLE 1
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2InitAttrib
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_INIT_ATTRIB_NULL 0
|
||||
#define GX2_INIT_ATTRIB_CB_BASE 1
|
||||
#define GX2_INIT_ATTRIB_CB_SIZE 2
|
||||
#define GX2_INIT_ATTRIB_ARGC 7
|
||||
#define GX2_INIT_ATTRIB_ARGV 8
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 compare functions
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_COMPARE_NEVER 0
|
||||
#define GX2_COMPARE_LESS 1
|
||||
#define GX2_COMPARE_EQUAL 2
|
||||
#define GX2_COMPARE_LEQUAL 3
|
||||
#define GX2_COMPARE_GREATER 4
|
||||
#define GX2_COMPARE_NOTEQUAL 5
|
||||
#define GX2_COMPARE_GEQUAL 6
|
||||
#define GX2_COMPARE_ALWAYS 7
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 stencil functions
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_STENCIL_KEEP 0
|
||||
#define GX2_STENCIL_ZERO 1
|
||||
#define GX2_STENCIL_REPLACE 2
|
||||
#define GX2_STENCIL_INCR 3
|
||||
#define GX2_STENCIL_DECR 4
|
||||
#define GX2_STENCIL_INVERT 5
|
||||
#define GX2_STENCIL_INCR_WRAP 6
|
||||
#define GX2_STENCIL_DECR_WRAP 7
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 logic op functions
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_LOGIC_OP_CLEAR 0x00
|
||||
#define GX2_LOGIC_OP_NOR 0x11
|
||||
#define GX2_LOGIC_OP_INVAND 0x22
|
||||
#define GX2_LOGIC_OP_INVCOPY 0x33
|
||||
#define GX2_LOGIC_OP_REVAND 0x44
|
||||
#define GX2_LOGIC_OP_INV 0x55
|
||||
#define GX2_LOGIC_OP_XOR 0x66
|
||||
#define GX2_LOGIC_OP_NAND 0x77
|
||||
#define GX2_LOGIC_OP_AND 0x88
|
||||
#define GX2_LOGIC_OP_EQUIV 0x99
|
||||
#define GX2_LOGIC_OP_NOOP 0xAA
|
||||
#define GX2_LOGIC_OP_INVOR 0xBB
|
||||
#define GX2_LOGIC_OP_COPY 0xCC
|
||||
#define GX2_LOGIC_OP_REVOR 0xDD
|
||||
#define GX2_LOGIC_OP_OR 0xEE
|
||||
#define GX2_LOGIC_OP_SET 0xFF
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 blend combination functions
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_BLEND_COMBINE_ADD 0x00
|
||||
#define GX2_BLEND_COMBINE_SRC_MINUS_DST 0x01
|
||||
#define GX2_BLEND_COMBINE_MIN 0x02
|
||||
#define GX2_BLEND_COMBINE_MAX 0x03
|
||||
#define GX2_BLEND_COMBINE_DST_MINUS_SRC 0x04
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 blend functions
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_BLEND_ZERO 0x00
|
||||
#define GX2_BLEND_ONE 0x01
|
||||
#define GX2_BLEND_SRC_ALPHA 0x04
|
||||
#define GX2_BLEND_ONE_MINUS_SRC_ALPHA 0x05
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 render targets
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_RENDER_TARGET_0 0
|
||||
#define GX2_RENDER_TARGET_1 1
|
||||
#define GX2_RENDER_TARGET_2 2
|
||||
#define GX2_RENDER_TARGET_3 3
|
||||
#define GX2_RENDER_TARGET_4 4
|
||||
#define GX2_RENDER_TARGET_5 5
|
||||
#define GX2_RENDER_TARGET_6 6
|
||||
#define GX2_RENDER_TARGET_7 7
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 cull modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_FRONT_FACE_CCW 0
|
||||
#define GX2_FRONT_FACE_CW 1
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 polygon modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_POLYGON_MODE_POINT 0
|
||||
#define GX2_POLYGON_MODE_LINE 1
|
||||
#define GX2_POLYGON_MODE_TRIANGLE 2
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 special states
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SPECIAL_STATE_CLEAR 0
|
||||
#define GX2_SPECIAL_STATE_CLEAR_HIZ 1
|
||||
#define GX2_SPECIAL_STATE_COPY 2
|
||||
#define GX2_SPECIAL_STATE_EXPAND_COLOR 3
|
||||
#define GX2_SPECIAL_STATE_EXPAND_DEPTH 4
|
||||
#define GX2_SPECIAL_STATE_CONVERT_DEPTH 5
|
||||
#define GX2_SPECIAL_STATE_CONVERT_AADEPTH 6
|
||||
#define GX2_SPECIAL_STATE_RESOLVE_COLOR 7
|
||||
#define GX2_SPECIAL_STATE_CLEAR_COLOR_AS_DEPTH 8
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 attribute formats
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_ATTRIB_FORMAT_8_UNORM 0x00000000
|
||||
#define GX2_ATTRIB_FORMAT_4_4_UNORM 0x00000001
|
||||
#define GX2_ATTRIB_FORMAT_16_UNORM 0x00000002
|
||||
#define GX2_ATTRIB_FORMAT_8_8_UNORM 0x00000004
|
||||
#define GX2_ATTRIB_FORMAT_16_16_UNORM 0x00000007
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_UNORM 0x0000000A
|
||||
#define GX2_ATTRIB_FORMAT_10_10_10_2_UNORM 0x0000000B
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_UNORM 0x0000000E
|
||||
|
||||
#define GX2_ATTRIB_FORMAT_8_UINT 0x00000100
|
||||
#define GX2_ATTRIB_FORMAT_16_UINT 0x00000102
|
||||
#define GX2_ATTRIB_FORMAT_8_8_UINT 0x00000104
|
||||
#define GX2_ATTRIB_FORMAT_32_UINT 0x00000105
|
||||
#define GX2_ATTRIB_FORMAT_16_16_UINT 0x00000107
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_UINT 0x0000010A
|
||||
#define GX2_ATTRIB_FORMAT_10_10_10_2_UINT 0x0000010B
|
||||
#define GX2_ATTRIB_FORMAT_32_32_UINT 0x0000010C
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_UINT 0x0000010E
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_UINT 0x00000110
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_32_UINT 0x00000112
|
||||
|
||||
#define GX2_ATTRIB_FORMAT_8_SNORM 0x00000200
|
||||
#define GX2_ATTRIB_FORMAT_16_SNORM 0x00000202
|
||||
#define GX2_ATTRIB_FORMAT_8_8_SNORM 0x00000204
|
||||
#define GX2_ATTRIB_FORMAT_16_16_SNORM 0x00000207
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_SNORM 0x0000020A
|
||||
#define GX2_ATTRIB_FORMAT_10_10_10_2_SNORM 0x0000020B
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_SNORM 0x0000020E
|
||||
|
||||
#define GX2_ATTRIB_FORMAT_8_SINT 0x00000300
|
||||
#define GX2_ATTRIB_FORMAT_16_SINT 0x00000303
|
||||
#define GX2_ATTRIB_FORMAT_8_8_SINT 0x00000304
|
||||
#define GX2_ATTRIB_FORMAT_32_SINT 0x00000305
|
||||
#define GX2_ATTRIB_FORMAT_16_16_SINT 0x00000307
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_SINT 0x0000030A
|
||||
#define GX2_ATTRIB_FORMAT_10_10_10_2_SINT 0x0000030B
|
||||
#define GX2_ATTRIB_FORMAT_32_32_SINT 0x0000030C
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_SINT 0x0000030E
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_SINT 0x00000310
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_32_SINT 0x00000312
|
||||
|
||||
#define GX2_ATTRIB_FORMAT_8_UINT_TO_FLOAT 0x00000800
|
||||
#define GX2_ATTRIB_FORMAT_16_UINT_TO_FLOAT 0x00000802
|
||||
#define GX2_ATTRIB_FORMAT_16_FLOAT 0x00000803
|
||||
#define GX2_ATTRIB_FORMAT_8_8_UINT_TO_FLOAT 0x00000804
|
||||
#define GX2_ATTRIB_FORMAT_32_FLOAT 0x00000806
|
||||
#define GX2_ATTRIB_FORMAT_16_16_UINT_TO_FLOAT 0x00000807
|
||||
#define GX2_ATTRIB_FORMAT_16_16_FLOAT 0x00000808
|
||||
#define GX2_ATTRIB_FORMAT_10_11_11_FLOAT 0x00000809
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_UINT_TO_FLOAT 0x0000080A
|
||||
#define GX2_ATTRIB_FORMAT_32_32_FLOAT 0x0000080D
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_UINT_TO_FLOAT 0x0000080E
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_FLOAT 0x0000080F
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_FLOAT 0x00000811
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_32_FLOAT 0x00000813
|
||||
|
||||
#define GX2_ATTRIB_FORMAT_8_SINT_TO_FLOAT 0x00000A00
|
||||
#define GX2_ATTRIB_FORMAT_16_SINT_TO_FLOAT 0x00000A02
|
||||
#define GX2_ATTRIB_FORMAT_8_8_SINT_TO_FLOAT 0x00000A04
|
||||
#define GX2_ATTRIB_FORMAT_16_16_SINT_TO_FLOAT 0x00000A07
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_SINT_TO_FLOAT 0x00000A0A
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_SINT_TO_FLOAT 0x00000A0E
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 shader modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SHADER_MODE_UNIFORM_REGISTER 0
|
||||
#define GX2_SHADER_MODE_UNIFORM_BLOCK 1
|
||||
#define GX2_SHADER_MODE_GEOMETRY_SHADER 2
|
||||
#define GX2_SHADER_MODE_COMPUTE_SHADER 3
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 shader modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_COMP_SEL_NONE 0x04040405
|
||||
#define GX2_COMP_SEL_X001 0x00040405
|
||||
#define GX2_COMP_SEL_XY01 0x00010405
|
||||
#define GX2_COMP_SEL_XYZ1 0x00010205
|
||||
#define GX2_COMP_SEL_XYZW 0x00010203
|
||||
#define GX2_COMP_SEL_XXXX 0x00000000
|
||||
#define GX2_COMP_SEL_YYYY 0x01010101
|
||||
#define GX2_COMP_SEL_ZZZZ 0x02020202
|
||||
#define GX2_COMP_SEL_WWWW 0x03030303
|
||||
#define GX2_COMP_SEL_WZYX 0x03020100
|
||||
#define GX2_COMP_SEL_WXYZ 0x03000102
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 variable types
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_VAR_TYPE_VOID 0
|
||||
#define GX2_VAR_TYPE_BOOL 1
|
||||
#define GX2_VAR_TYPE_INT 2
|
||||
#define GX2_VAR_TYPE_UINT 3
|
||||
#define GX2_VAR_TYPE_FLOAT 4
|
||||
#define GX2_VAR_TYPE_DOUBLE 5
|
||||
#define GX2_VAR_TYPE_VEC2 9
|
||||
#define GX2_VAR_TYPE_VEC3 10
|
||||
#define GX2_VAR_TYPE_VEC4 11
|
||||
#define GX2_VAR_TYPE_MAT2 21
|
||||
#define GX2_VAR_TYPE_MAT3 25
|
||||
#define GX2_VAR_TYPE_MAT4 29
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 sample types
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SAMPLER_TYPE_2D 1
|
||||
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 index formats
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_INDEX_FORMAT_U16 4
|
||||
#define GX2_INDEX_FORMAT_uint32_t 9
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 primitive types
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_PRIMITIVE_POINTS 0x01
|
||||
#define GX2_PRIMITIVE_LINES 0x02
|
||||
#define GX2_PRIMITIVE_LINE_STRIP 0x03
|
||||
#define GX2_PRIMITIVE_TRIANGLES 0x04
|
||||
#define GX2_PRIMITIVE_TRIANGLE_FAN 0x05
|
||||
#define GX2_PRIMITIVE_TRIANGLE_STRIP 0x06
|
||||
#define GX2_PRIMITIVE_RECTS 0x11
|
||||
#define GX2_PRIMITIVE_QUADS 0x13
|
||||
#define GX2_PRIMITIVE_QUAD_STRIP 0x14
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 clear modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_CLEAR_DEPTH 0x01
|
||||
#define GX2_CLEAR_STENCIL 0x02
|
||||
#define GX2_CLEAR_BOTH (GX2_CLEAR_DEPTH | GX2_CLEAR_STENCIL)
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 surface formats
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_UNORM 0x00000001
|
||||
#define GX2_SURFACE_FORMAT_T_R4_G4_UNORM 0x00000002
|
||||
#define GX2_SURFACE_FORMAT_TCD_R16_UNORM 0x00000005
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_UNORM 0x00000007
|
||||
#define GX2_SURFACE_FORMAT_TCS_R5_G6_B5_UNORM 0x00000008
|
||||
#define GX2_SURFACE_FORMAT_TC_R5_G5_B5_A1_UNORM 0x0000000a
|
||||
#define GX2_SURFACE_FORMAT_TC_R4_G4_B4_A4_UNORM 0x0000000b
|
||||
#define GX2_SURFACE_FORMAT_TC_A1_B5_G5_R5_UNORM 0x0000000c
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_UNORM 0x0000000f
|
||||
#define GX2_SURFACE_FORMAT_D_D24_S8_UNORM 0x00000011
|
||||
#define GX2_SURFACE_FORMAT_T_R24_UNORM_X8 0x00000011
|
||||
#define GX2_SURFACE_FORMAT_TCS_R10_G10_B10_A2_UNORM 0x00000019
|
||||
#define GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM 0x0000001a
|
||||
#define GX2_SURFACE_FORMAT_TCS_A2_B10_G10_R10_UNORM 0x0000001b
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_UNORM 0x0000001f
|
||||
#define GX2_SURFACE_FORMAT_T_BC1_UNORM 0x00000031
|
||||
#define GX2_SURFACE_FORMAT_T_BC2_UNORM 0x00000032
|
||||
#define GX2_SURFACE_FORMAT_T_BC3_UNORM 0x00000033
|
||||
#define GX2_SURFACE_FORMAT_T_BC4_UNORM 0x00000034
|
||||
#define GX2_SURFACE_FORMAT_T_BC5_UNORM 0x00000035
|
||||
#define GX2_SURFACE_FORMAT_T_NV12_UNORM 0x00000081
|
||||
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_UINT 0x00000101
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_UINT 0x00000105
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_UINT 0x00000107
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_UINT 0x0000010d
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_UINT 0x0000010f
|
||||
#define GX2_SURFACE_FORMAT_T_X24_G8_UINT 0x00000111
|
||||
#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_UINT 0x00000119
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_UINT 0x0000011a
|
||||
#define GX2_SURFACE_FORMAT_TC_A2_B10_G10_R10_UINT 0x0000011b
|
||||
#define GX2_SURFACE_FORMAT_T_X32_G8_UINT_X24 0x0000011c
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_UINT 0x0000011d
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_UINT 0x0000011f
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_UINT 0x00000122
|
||||
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_SNORM 0x00000201
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_SNORM 0x00000205
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_SNORM 0x00000207
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_SNORM 0x0000020f
|
||||
#define GX2_SURFACE_FORMAT_T_R10_G10_B10_A2_SNORM 0x00000219
|
||||
#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_SNORM 0x00000219
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SNORM 0x0000021a
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_SNORM 0x0000021f
|
||||
#define GX2_SURFACE_FORMAT_T_BC4_SNORM 0x00000234
|
||||
#define GX2_SURFACE_FORMAT_T_BC5_SNORM 0x00000235
|
||||
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_SINT 0x00000301
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_SINT 0x00000305
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_SINT 0x00000307
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_SINT 0x0000030d
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_SINT 0x0000030f
|
||||
#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_SINT 0x00000319
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SINT 0x0000031a
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_SINT 0x0000031d
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_SINT 0x0000031f
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_SINT 0x00000322
|
||||
|
||||
#define GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB 0x0000041a
|
||||
#define GX2_SURFACE_FORMAT_T_BC1_SRGB 0x00000431
|
||||
#define GX2_SURFACE_FORMAT_T_BC2_SRGB 0x00000432
|
||||
#define GX2_SURFACE_FORMAT_T_BC3_SRGB 0x00000433
|
||||
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_FLOAT 0x00000806
|
||||
#define GX2_SURFACE_FORMAT_TCD_R32_FLOAT 0x0000080e
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_FLOAT 0x00000810
|
||||
#define GX2_SURFACE_FORMAT_D_D24_S8_FLOAT 0x00000811
|
||||
#define GX2_SURFACE_FORMAT_TC_R11_G11_B10_FLOAT 0x00000816
|
||||
#define GX2_SURFACE_FORMAT_D_D32_FLOAT_S8_UINT_X24 0x0000081c
|
||||
#define GX2_SURFACE_FORMAT_T_R32_FLOAT_X8_X24 0x0000081c
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_FLOAT 0x0000081e
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_FLOAT 0x00000820
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_FLOAT 0x00000823
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 tile modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TILE_MODE_DEFAULT 0x00000000
|
||||
#define GX2_TILE_MODE_LINEAR_ALIGNED 0x00000001
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 surface use
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SURFACE_USE_TEXTURE 0x00000001
|
||||
#define GX2_SURFACE_USE_COLOR_BUFFER 0x00000002
|
||||
#define GX2_SURFACE_USE_DEPTH_BUFFER 0x00000004
|
||||
#define GX2_SURFACE_USE_SCAN_BUFFER 0x00000008
|
||||
#define GX2_SURFACE_USE_FTV 0x80000000
|
||||
#define GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_TEXTURE)
|
||||
#define GX2_SURFACE_USE_DEPTH_BUFFER_TEXTURE (GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE)
|
||||
#define GX2_SURFACE_USE_COLOR_BUFFER_FTV (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_FTV)
|
||||
#define GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE_FTV (GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE | GX2_SURFACE_USE_FTV)
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 surface dim
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SURFACE_DIM_1D 0x00000000
|
||||
#define GX2_SURFACE_DIM_2D 0x00000001
|
||||
#define GX2_SURFACE_DIM_3D 0x00000002
|
||||
#define GX2_SURFACE_DIM_CUBE 0x00000003
|
||||
#define GX2_SURFACE_DIM_1D_ARRAY 0x00000004
|
||||
#define GX2_SURFACE_DIM_2D_ARRAY 0x00000005
|
||||
#define GX2_SURFACE_DIM_2D_MSAA 0x00000006
|
||||
#define GX2_SURFACE_DIM_2D_MSAA_ARRAY 0x00000007
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 AA modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_AA_MODE_1X 0x00000000
|
||||
#define GX2_AA_MODE_2X 0x00000001
|
||||
#define GX2_AA_MODE_4X 0x00000002
|
||||
#define GX2_AA_MODE_8X 0x00000003
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 texture clamp
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TEX_CLAMP_WRAP 0x00000000
|
||||
#define GX2_TEX_CLAMP_MIRROR 0x00000001
|
||||
#define GX2_TEX_CLAMP_CLAMP 0x00000002
|
||||
#define GX2_TEX_CLAMP_MIRROR_ONCE 0x00000003
|
||||
#define GX2_TEX_CLAMP_CLAMP_HALF_BORDER 0x00000004
|
||||
#define GX2_TEX_CLAMP_MIRROR_ONCE_HALF_BORDER 0x00000005
|
||||
#define GX2_TEX_CLAMP_CLAMP_BORDER 0x00000006
|
||||
#define GX2_TEX_CLAMP_MIRROR_ONCE_BORDER 0x00000007
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 texture filter
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TEX_XY_FILTER_POINT 0x00000000
|
||||
#define GX2_TEX_XY_FILTER_BILINEAR 0x00000001
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 TV scan modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TV_SCAN_MODE_NONE 0x00000000
|
||||
#define GX2_TV_SCAN_MODE_576I 0x00000001
|
||||
#define GX2_TV_SCAN_MODE_480I 0x00000002
|
||||
#define GX2_TV_SCAN_MODE_480P 0x00000003
|
||||
#define GX2_TV_SCAN_MODE_720P 0x00000004
|
||||
#define GX2_TV_SCAN_MODE_1080I 0x00000006
|
||||
#define GX2_TV_SCAN_MODE_1080P 0x00000007
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 TV render modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TV_RENDER_480_NARROW 0x00000001
|
||||
#define GX2_TV_RENDER_480_WIDE 0x00000002
|
||||
#define GX2_TV_RENDER_720 0x00000003
|
||||
#define GX2_TV_RENDER_1080 0x00000005
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 DRC render modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_DRC_NONE 0x00000000
|
||||
#define GX2_DRC_SINGLE 0x00000001
|
||||
#define GX2_DRC_DOUBLE 0x00000002
|
||||
#define GX2_DRC_SINGLE_30HZ 0x00000004
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 buffering mode
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_BUFFERING_SINGLE 0x00000001
|
||||
#define GX2_BUFFERING_DOUBLE 0x00000002
|
||||
#define GX2_BUFFERING_TRIPLE 0x00000003
|
||||
#define GX2_BUFFERING_QUAD
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 scan targets
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SCAN_TARGET_TV 0x00000001
|
||||
#define GX2_SCAN_TARGET_DRC_FIRST 0x00000004
|
||||
#define GX2_SCAN_TARGET_DRC_SECOND 0x00000008
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 invalidate types
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_INVALIDATE_ATTRIB_BUFFER 0x00000001
|
||||
#define GX2_INVALIDATE_TEXTURE 0x00000002
|
||||
#define GX2_INVALIDATE_UNIFORM_BLOCK 0x00000004
|
||||
#define GX2_INVALIDATE_SHADER 0x00000008
|
||||
#define GX2_INVALIDATE_COLOR_BUFFER 0x00000010
|
||||
#define GX2_INVALIDATE_DEPTH_BUFFER 0x00000020
|
||||
#define GX2_INVALIDATE_CPU 0x00000040
|
||||
#define GX2_INVALIDATE_CPU_ATTRIB_BUFFER (GX2_INVALIDATE_CPU | GX2_INVALIDATE_ATTRIB_BUFFER)
|
||||
#define GX2_INVALIDATE_CPU_TEXTURE (GX2_INVALIDATE_CPU | GX2_INVALIDATE_TEXTURE)
|
||||
#define GX2_INVALIDATE_CPU_UNIFORM_BLOCK (GX2_INVALIDATE_CPU | GX2_INVALIDATE_UNIFORM_BLOCK)
|
||||
#define GX2_INVALIDATE_CPU_SHADER (GX2_INVALIDATE_CPU | GX2_INVALIDATE_SHADER)
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 swap modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_ENDIANSWAP_DEFAULT 0x00000003
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 tessellation modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TESSELLATION_MODE_DISCRETE 0x00000000
|
||||
#define GX2_TESSELLATION_MODE_CONTINUOUS 0x00000001
|
||||
#define GX2_TESSELLATION_MODE_ADAPTIVE 0x00000002
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 fetch shader types
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_FETCH_SHADER_TESSELATION_NONE 0x00000000
|
||||
#define GX2_FETCH_SHADER_TESSELATION_LINES 0x00000001
|
||||
#define GX2_FETCH_SHADER_TESSELATION_TRIANGLES 0x00000002
|
||||
#define GX2_FETCH_SHADER_TESSELATION_QUADS 0x00000003
|
||||
|
||||
|
||||
typedef struct _GX2ContextState {
|
||||
uint8_t data[GX2_CONTEXT_STATE_SIZE];
|
||||
} GX2ContextState;
|
||||
|
||||
typedef struct _GX2Surface {
|
||||
int32_t dimension;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t depth;
|
||||
uint32_t num_mips;
|
||||
int32_t format;
|
||||
int32_t aa;
|
||||
int32_t use;
|
||||
uint32_t image_size;
|
||||
void *image_data;
|
||||
uint32_t mip_size;
|
||||
void *mip_data;
|
||||
int32_t tile;
|
||||
uint32_t swizzle;
|
||||
uint32_t align;
|
||||
uint32_t pitch;
|
||||
uint32_t mip_offset[13];
|
||||
} GX2Surface;
|
||||
|
||||
typedef struct _GX2ColorBuffer {
|
||||
GX2Surface surface;
|
||||
uint32_t view_mip;
|
||||
uint32_t view_first_slice;
|
||||
uint32_t view_slices_count;
|
||||
void *aux_data;
|
||||
uint32_t aux_size;
|
||||
uint32_t regs[5];
|
||||
} GX2ColorBuffer;
|
||||
|
||||
typedef struct _GX2DepthBuffer {
|
||||
GX2Surface surface;
|
||||
uint32_t view_mip;
|
||||
uint32_t view_first_slice;
|
||||
uint32_t view_slices_count;
|
||||
void *hiZ_data;
|
||||
uint32_t hiZ_size;
|
||||
float clear_depth;
|
||||
uint32_t clear_stencil;
|
||||
uint32_t regs[7];
|
||||
} GX2DepthBuffer;
|
||||
|
||||
|
||||
typedef struct _GX2Texture {
|
||||
GX2Surface surface;
|
||||
uint32_t view_first_mip;
|
||||
uint32_t view_mips_count;
|
||||
uint32_t view_first_slice;
|
||||
uint32_t view_slices_count;
|
||||
uint32_t component_selector;
|
||||
uint32_t regs[5];
|
||||
} GX2Texture;
|
||||
|
||||
|
||||
typedef struct _GX2Sampler {
|
||||
uint32_t regs[3];
|
||||
} GX2Sampler;
|
||||
|
||||
typedef struct _GX2AttribStream {
|
||||
uint32_t location;
|
||||
uint32_t buffer;
|
||||
uint32_t offset;
|
||||
int32_t format;
|
||||
int32_t index_type;
|
||||
uint32_t divisor;
|
||||
uint32_t destination_selector;
|
||||
int32_t endian_swap;
|
||||
} GX2AttribStream;
|
||||
|
||||
typedef struct _GX2FetchShader {
|
||||
int32_t type;
|
||||
uint32_t reg;
|
||||
uint32_t shader_size;
|
||||
void *shader_program;
|
||||
uint32_t attributes_count;
|
||||
uint32_t divisor[3];
|
||||
} GX2FetchShader;
|
||||
|
||||
typedef struct _GX2AttribVar {
|
||||
const char *name;
|
||||
int32_t var_type;
|
||||
uint32_t array_count;
|
||||
uint32_t location;
|
||||
} GX2AttribVar;
|
||||
|
||||
|
||||
typedef struct _GX2UniformBlock {
|
||||
const char *name;
|
||||
uint32_t location;
|
||||
uint32_t block_size;
|
||||
} GX2UniformBlock;
|
||||
|
||||
typedef struct _GX2UniformInitialValue {
|
||||
float value[4];
|
||||
uint32_t offset;
|
||||
} GX2UniformInitialValue;
|
||||
|
||||
typedef struct _GX2SamplerVar {
|
||||
const char *name;
|
||||
int32_t sampler_type;
|
||||
uint32_t location;
|
||||
} GX2SamplerVar;
|
||||
|
||||
typedef struct _GX2UniformVar {
|
||||
const char *name;
|
||||
int32_t var_type;
|
||||
uint32_t array_count;
|
||||
uint32_t offset;
|
||||
uint32_t block_index;
|
||||
} GX2UniformVar;
|
||||
|
||||
typedef struct _GX2VertexShader {
|
||||
uint32_t regs[52];
|
||||
uint32_t shader_size;
|
||||
void *shader_data;
|
||||
int32_t shader_mode;
|
||||
uint32_t uniform_blocks_count;
|
||||
GX2UniformBlock *uniform_block;
|
||||
uint32_t uniform_vars_count;
|
||||
GX2UniformVar *uniform_var;
|
||||
uint32_t initial_values_count;
|
||||
GX2UniformInitialValue *initial_value;
|
||||
uint32_t loops_count;
|
||||
void *loops_data;
|
||||
uint32_t sampler_vars_count;
|
||||
GX2SamplerVar *sampler_var;
|
||||
uint32_t attribute_vars_count;
|
||||
GX2AttribVar *attribute_var;
|
||||
uint32_t data[6];
|
||||
uint32_t shader_program_buffer[16];
|
||||
} GX2VertexShader;
|
||||
|
||||
typedef struct _GX2PixelShader {
|
||||
uint32_t regs[41];
|
||||
uint32_t shader_size;
|
||||
void *shader_data;
|
||||
int32_t shader_mode;
|
||||
uint32_t uniform_blocks_count;
|
||||
GX2UniformBlock *uniform_block;
|
||||
uint32_t uniform_vars_count;
|
||||
GX2UniformVar *uniform_var;
|
||||
uint32_t initial_values_count;
|
||||
GX2UniformInitialValue *initial_value;
|
||||
uint32_t loops_count;
|
||||
void *loops_data;
|
||||
uint32_t sampler_vars_count;
|
||||
GX2SamplerVar *sampler_var;
|
||||
uint32_t shader_program_buffer[16];
|
||||
} GX2PixelShader;
|
||||
|
||||
static const uint32_t attribute_dest_comp_selector[20] = {
|
||||
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001,
|
||||
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
|
||||
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1,
|
||||
GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW
|
||||
};
|
||||
|
||||
static const uint32_t texture_comp_selector[54] = {
|
||||
GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001,
|
||||
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
|
||||
GX2_COMP_SEL_WZYX, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE,
|
||||
GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE,
|
||||
GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_WZYX, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01,
|
||||
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
|
||||
GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_X001,
|
||||
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1,
|
||||
GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01
|
||||
};
|
||||
|
||||
typedef struct _GX2Color {
|
||||
uint8_t r, g, b, a;
|
||||
} GX2Color;
|
||||
|
||||
typedef struct _GX2Colorfloat {
|
||||
float r, g, b, a;
|
||||
} GX2Colorfloat;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
118
src/dynamic_libs/socket_functions.c
Normal file
@ -0,0 +1,118 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "coreinit.h"
|
||||
#include "socket_functions.h"
|
||||
|
||||
uint32_t hostIpAddress = 0;
|
||||
|
||||
uint32_t nsysnet_handle __attribute__((section(".data"))) = 0;
|
||||
|
||||
EXPORT_DECL(int32_t, socket_lib_init, void);
|
||||
EXPORT_DECL(int32_t, socket_lib_finish, void);
|
||||
EXPORT_DECL(int32_t, socket, int32_t domain, int32_t type, int32_t protocol);
|
||||
EXPORT_DECL(int32_t, socketclose, int32_t s);
|
||||
EXPORT_DECL(int32_t, shutdown, int32_t s, int32_t how);
|
||||
EXPORT_DECL(int32_t, connect, int32_t s, void *addr, int32_t addrlen);
|
||||
EXPORT_DECL(int32_t, bind, int32_t s,struct sockaddr *name,int32_t namelen);
|
||||
EXPORT_DECL(int32_t, listen, int32_t s,uint32_t backlog);
|
||||
EXPORT_DECL(int32_t, accept, int32_t s,struct sockaddr *addr,int32_t *addrlen);
|
||||
EXPORT_DECL(int32_t, send, int32_t s, const void *buffer, int32_t size, int32_t flags);
|
||||
EXPORT_DECL(int32_t, recv, int32_t s, void *buffer, int32_t size, int32_t flags);
|
||||
EXPORT_DECL(int32_t, recvfrom,int32_t sockfd, void *buf, int32_t len, int32_t flags,struct sockaddr *src_addr, int32_t *addrlen);
|
||||
EXPORT_DECL(int32_t, sendto, int32_t s, const void *buffer, int32_t size, int32_t flags, const struct sockaddr *dest, int32_t dest_len);
|
||||
EXPORT_DECL(int32_t, setsockopt, int32_t s, int32_t level, int32_t optname, void *optval, int32_t optlen);
|
||||
EXPORT_DECL(char *, inet_ntoa, struct in_addr in);
|
||||
EXPORT_DECL(int32_t, inet_aton, const char *cp, struct in_addr *inp);
|
||||
EXPORT_DECL(const char *, inet_ntop, int32_t af, const void *src, char *dst, int32_t size);
|
||||
EXPORT_DECL(int32_t, inet_pton, int32_t af, const char *src, void *dst);
|
||||
EXPORT_DECL(int32_t, socketlasterr, void);
|
||||
|
||||
EXPORT_DECL(int32_t, NSSLInit, void);
|
||||
EXPORT_DECL(int32_t, NSSLFinish, void);
|
||||
EXPORT_DECL(int32_t, NSSLCreateContext, int32_t unkwn);
|
||||
EXPORT_DECL(int32_t, NSSLDestroyContext, int32_t context);
|
||||
EXPORT_DECL(int32_t, NSSLAddServerPKI, int32_t context, int32_t pki);
|
||||
EXPORT_DECL(int32_t, NSSLAddServerPKIExternal, int32_t context, const uint8_t* cert, int32_t length, int32_t unkwn);
|
||||
EXPORT_DECL(int32_t, NSSLWrite, int32_t connection, const void* buf, int32_t len,int32_t * written);
|
||||
EXPORT_DECL(int32_t, NSSLRead, int32_t connection, const void* buf, int32_t len,int32_t * read);
|
||||
EXPORT_DECL(int32_t, NSSLCreateConnection, int32_t context, const char* host, int32_t hotlen,int32_t options,int32_t sock,int32_t block);
|
||||
|
||||
void InitAcquireSocket(void) {
|
||||
OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle);
|
||||
}
|
||||
|
||||
void InitSocketFunctionPointers(void) {
|
||||
uint32_t *funcPointer = 0;
|
||||
|
||||
InitAcquireSocket();
|
||||
|
||||
uint32_t nn_ac_handle;
|
||||
int32_t(*ACInitialize)();
|
||||
int32_t(*ACGetStartupId) (uint32_t *id);
|
||||
int32_t(*ACConnectWithConfigId) (uint32_t id);
|
||||
int32_t(*ACGetAssignedAddress) (uint32_t * ip);
|
||||
OSDynLoad_Acquire("nn_ac.rpl", &nn_ac_handle);
|
||||
OSDynLoad_FindExport(nn_ac_handle, 0, "ACInitialize", &ACInitialize);
|
||||
OSDynLoad_FindExport(nn_ac_handle, 0, "ACGetStartupId", &ACGetStartupId);
|
||||
OSDynLoad_FindExport(nn_ac_handle, 0, "ACConnectWithConfigId",&ACConnectWithConfigId);
|
||||
OSDynLoad_FindExport(nn_ac_handle, 0, "ACGetAssignedAddress",&ACGetAssignedAddress);
|
||||
|
||||
OS_FIND_EXPORT(nsysnet_handle, socket_lib_init);
|
||||
OS_FIND_EXPORT(nsysnet_handle, socket_lib_finish);
|
||||
OS_FIND_EXPORT(nsysnet_handle, socketlasterr);
|
||||
OS_FIND_EXPORT(nsysnet_handle, socket);
|
||||
OS_FIND_EXPORT(nsysnet_handle, socketclose);
|
||||
OS_FIND_EXPORT(nsysnet_handle, shutdown);
|
||||
OS_FIND_EXPORT(nsysnet_handle, connect);
|
||||
OS_FIND_EXPORT(nsysnet_handle, bind);
|
||||
OS_FIND_EXPORT(nsysnet_handle, listen);
|
||||
OS_FIND_EXPORT(nsysnet_handle, accept);
|
||||
OS_FIND_EXPORT(nsysnet_handle, send);
|
||||
OS_FIND_EXPORT(nsysnet_handle, recv);
|
||||
OS_FIND_EXPORT(nsysnet_handle, recvfrom);
|
||||
OS_FIND_EXPORT(nsysnet_handle, sendto);
|
||||
OS_FIND_EXPORT(nsysnet_handle, setsockopt);
|
||||
OS_FIND_EXPORT(nsysnet_handle, inet_ntoa);
|
||||
OS_FIND_EXPORT(nsysnet_handle, inet_aton);
|
||||
OS_FIND_EXPORT(nsysnet_handle, inet_ntop);
|
||||
OS_FIND_EXPORT(nsysnet_handle, inet_pton);
|
||||
|
||||
OS_FIND_EXPORT(nsysnet_handle, NSSLInit);
|
||||
OS_FIND_EXPORT(nsysnet_handle, NSSLFinish);
|
||||
OS_FIND_EXPORT(nsysnet_handle, NSSLCreateContext);
|
||||
OS_FIND_EXPORT(nsysnet_handle, NSSLDestroyContext);
|
||||
OS_FIND_EXPORT(nsysnet_handle, NSSLAddServerPKI);
|
||||
OS_FIND_EXPORT(nsysnet_handle, NSSLAddServerPKIExternal);
|
||||
OS_FIND_EXPORT(nsysnet_handle, NSSLWrite);
|
||||
OS_FIND_EXPORT(nsysnet_handle, NSSLRead);
|
||||
OS_FIND_EXPORT(nsysnet_handle, NSSLCreateConnection);
|
||||
|
||||
uint32_t nn_startupid;
|
||||
ACInitialize();
|
||||
ACGetStartupId(&nn_startupid);
|
||||
ACConnectWithConfigId(nn_startupid);
|
||||
ACGetAssignedAddress(&hostIpAddress);
|
||||
|
||||
socket_lib_init();
|
||||
}
|
124
src/dynamic_libs/socket_functions.h
Normal file
@ -0,0 +1,124 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __SOCKET_FUNCTIONS_H_
|
||||
#define __SOCKET_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
extern uint32_t nsysnet_handle;
|
||||
|
||||
extern uint32_t hostIpAddress;
|
||||
|
||||
#define INADDR_ANY 0
|
||||
#define INADDR_BROADCAST 0xFFFFFFFF
|
||||
|
||||
#define AF_INET 2
|
||||
|
||||
#define SHUT_RD 0
|
||||
#define SHUT_WR 1
|
||||
#define SHUT_RDWR 2
|
||||
|
||||
#define SOCK_STREAM 1
|
||||
#define SOCK_DGRAM 2
|
||||
|
||||
#define IPPROTO_IP 0
|
||||
#define IPPROTO_TCP 6
|
||||
#define IPPROTO_UDP 17
|
||||
|
||||
#define TCP_NODELAY 0x2004
|
||||
|
||||
#define SOL_SOCKET -1
|
||||
#define SO_REUSEADDR 0x0004
|
||||
#define SO_BROADCAST 0x0020 // broadcast
|
||||
#define SO_NONBLOCK 0x1016
|
||||
#define SO_MYADDR 0x1013
|
||||
#define SO_RCVTIMEO 0x1006
|
||||
|
||||
#define SOL_SOCKET -1
|
||||
#define MSG_DONTWAIT 32
|
||||
|
||||
#define htonl(x) x
|
||||
#define htons(x) x
|
||||
#define ntohl(x) x
|
||||
#define ntohs(x) x
|
||||
|
||||
struct in_addr {
|
||||
uint32_t s_addr;
|
||||
};
|
||||
struct sockaddr_in {
|
||||
short sin_family;
|
||||
unsigned short sin_port;
|
||||
struct in_addr sin_addr;
|
||||
char sin_zero[8];
|
||||
};
|
||||
|
||||
struct sockaddr {
|
||||
unsigned short sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
|
||||
void InitSocketFunctionPointers(void);
|
||||
void InitAcquireSocket(void);
|
||||
|
||||
extern int32_t (*socket_lib_init)(void);
|
||||
extern int32_t (*socket_lib_finish)(void);
|
||||
extern int32_t (*socket)(int32_t domain, int32_t type, int32_t protocol);
|
||||
extern int32_t (*socketclose)(int32_t s);
|
||||
extern int32_t (*shutdown)(int32_t s, int32_t how);
|
||||
extern int32_t (*connect)(int32_t s, void *addr, int32_t addrlen);
|
||||
extern int32_t (*bind)(int32_t s,struct sockaddr *name,int32_t namelen);
|
||||
extern int32_t (*listen)(int32_t s,uint32_t backlog);
|
||||
extern int32_t (*accept)(int32_t s,struct sockaddr *addr,int32_t *addrlen);
|
||||
extern int32_t (*send)(int32_t s, const void *buffer, int32_t size, int32_t flags);
|
||||
extern int32_t (*recv)(int32_t s, void *buffer, int32_t size, int32_t flags);
|
||||
extern int32_t (*recvfrom)(int32_t sockfd, void *buf, int32_t len, int32_t flags,struct sockaddr *src_addr, int32_t *addrlen);
|
||||
extern int32_t (*socketlasterr)(void);
|
||||
|
||||
extern int32_t (*sendto)(int32_t s, const void *buffer, int32_t size, int32_t flags, const struct sockaddr *dest, int32_t dest_len);
|
||||
extern int32_t (*setsockopt)(int32_t s, int32_t level, int32_t optname, void *optval, int32_t optlen);
|
||||
|
||||
extern int32_t (* NSSLInit)(void);
|
||||
extern int32_t (* NSSLFinish)(void);
|
||||
extern int32_t (* NSSLCreateContext)(int32_t unkwn);
|
||||
extern int32_t (* NSSLDestroyContext)(int32_t context);
|
||||
extern int32_t (* NSSLAddServerPKIExternal)(int32_t context, const uint8_t* cert, int32_t length, int32_t unkwn);
|
||||
extern int32_t (* NSSLAddServerPKI)(int32_t context, int32_t pki);
|
||||
extern int32_t (* NSSLWrite)(int32_t connection, const void* buf, int32_t len,int32_t * written);
|
||||
extern int32_t (* NSSLRead)(int32_t connection, const void* buf, int32_t len,int32_t * read);
|
||||
extern int32_t (* NSSLCreateConnection)(int32_t context, const char* host, int32_t hotlen,int32_t options,int32_t sock,int32_t block);
|
||||
|
||||
extern char * (*inet_ntoa)(struct in_addr in);
|
||||
extern int32_t (*inet_aton)(const char *cp, struct in_addr *inp);
|
||||
extern const char * (*inet_ntop)(int32_t af, const void *src, char *dst, int32_t size);
|
||||
extern int32_t (*inet_pton)(int32_t af, const char *src, void *dst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __SOCKET_FUNCTIONS_H_
|
170
src/dynamic_libs/vpad_functions.c
Normal file
@ -0,0 +1,170 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "coreinit.h"
|
||||
#include "vpad_functions.h"
|
||||
|
||||
uint32_t vpad_handle __attribute__((section(".data"))) = 0;
|
||||
uint32_t vpadbase_handle __attribute__((section(".data"))) = 0;
|
||||
|
||||
EXPORT_DECL(void, VPADInit, void);
|
||||
EXPORT_DECL(void, VPADShutdown, void);
|
||||
EXPORT_DECL(int32_t, VPADRead, int32_t chan, VPADData *buffer, uint32_t buffer_size, int32_t *error);
|
||||
EXPORT_DECL(void, VPADSetAccParam, int32_t chan, float play_radius, float sensitivity);
|
||||
EXPORT_DECL(void, VPADGetAccParam, int32_t chan, float *play_radius, float *sensitivity);
|
||||
EXPORT_DECL(void, VPADSetBtnRepeat, int32_t chan, float delay_sec, float pulse_sec);
|
||||
EXPORT_DECL(void, VPADEnableStickCrossClamp, int32_t chan);
|
||||
EXPORT_DECL(void, VPADDisableStickCrossClamp, int32_t chan);
|
||||
EXPORT_DECL(void, VPADSetLStickClampThreshold, int32_t chan, int32_t max, int32_t min);
|
||||
EXPORT_DECL(void, VPADSetRStickClampThreshold, int32_t chan, int32_t max, int32_t min);
|
||||
EXPORT_DECL(void, VPADGetLStickClampThreshold, int32_t chan, int32_t* max, int32_t* min);
|
||||
EXPORT_DECL(void, VPADGetRStickClampThreshold, int32_t chan, int32_t* max, int32_t* min);
|
||||
EXPORT_DECL(void, VPADSetStickOrigin, int32_t chan);
|
||||
EXPORT_DECL(void, VPADDisableLStickZeroClamp, int32_t chan);
|
||||
EXPORT_DECL(void, VPADDisableRStickZeroClamp, int32_t chan);
|
||||
EXPORT_DECL(void, VPADEnableLStickZeroClamp, int32_t chan);
|
||||
EXPORT_DECL(void, VPADEnableRStickZeroClamp, int32_t chan);
|
||||
EXPORT_DECL(void, VPADSetCrossStickEmulationParamsL, int32_t chan, float rot_deg, float xy_deg, float radius);
|
||||
EXPORT_DECL(void, VPADSetCrossStickEmulationParamsR, int32_t chan, float rot_deg, float xy_deg, float radius);
|
||||
EXPORT_DECL(void, VPADGetCrossStickEmulationParamsL, int32_t chan, float* rot_deg, float* xy_deg, float* radius);
|
||||
EXPORT_DECL(void, VPADGetCrossStickEmulationParamsR, int32_t chan, float* rot_deg, float* xy_deg, float* radius);
|
||||
EXPORT_DECL(void, VPADSetGyroAngle, int32_t chan, float ax, float ay, float az);
|
||||
EXPORT_DECL(void, VPADSetGyroDirection, int32_t chan, VPADDir *dir);
|
||||
EXPORT_DECL(void, VPADSetGyroDirectionMag, int32_t chan, float mag);
|
||||
EXPORT_DECL(void, VPADSetGyroMagnification, int32_t chan, float pitch, float yaw, float roll);
|
||||
EXPORT_DECL(void, VPADEnableGyroZeroPlay, int32_t chan);
|
||||
EXPORT_DECL(void, VPADEnableGyroDirRevise, int32_t chan);
|
||||
EXPORT_DECL(void, VPADEnableGyroAccRevise, int32_t chan);
|
||||
EXPORT_DECL(void, VPADDisableGyroZeroPlay, int32_t chan);
|
||||
EXPORT_DECL(void, VPADDisableGyroDirRevise, int32_t chan);
|
||||
EXPORT_DECL(void, VPADDisableGyroAccRevise, int32_t chan);
|
||||
EXPORT_DECL(float, VPADIsEnableGyroZeroPlay, int32_t chan);
|
||||
EXPORT_DECL(float, VPADIsEnableGyroZeroDrift, int32_t chan);
|
||||
EXPORT_DECL(float, VPADIsEnableGyroDirRevise, int32_t chan);
|
||||
EXPORT_DECL(float, VPADIsEnableGyroAccRevise, int32_t chan);
|
||||
EXPORT_DECL(void, VPADSetGyroZeroPlayParam, int32_t chan, float radius);
|
||||
EXPORT_DECL(void, VPADSetGyroDirReviseParam, int32_t chan, float revis_pw);
|
||||
EXPORT_DECL(void, VPADSetGyroAccReviseParam, int32_t chan, float revise_pw, float revise_range);
|
||||
EXPORT_DECL(void, VPADSetGyroDirReviseBase, int32_t chan, VPADDir *base);
|
||||
EXPORT_DECL(void, VPADGetGyroZeroPlayParam, int32_t chan, float *radius);
|
||||
EXPORT_DECL(void, VPADGetGyroDirReviseParam, int32_t chan, float *revise_pw);
|
||||
EXPORT_DECL(void, VPADGetGyroAccReviseParam, int32_t chan, float *revise_pw, float *revise_range);
|
||||
EXPORT_DECL(void, VPADInitGyroZeroPlayParam, int32_t chan);
|
||||
EXPORT_DECL(void, VPADInitGyroDirReviseParam, int32_t chan);
|
||||
EXPORT_DECL(void, VPADInitGyroAccReviseParam, int32_t chan);
|
||||
EXPORT_DECL(void, VPADInitGyroZeroDriftMode, int32_t chan);
|
||||
EXPORT_DECL(void, VPADSetGyroZeroDriftMode, int32_t chan, VPADGyroZeroDriftMode mode);
|
||||
EXPORT_DECL(void, VPADGetGyroZeroDriftMode, int32_t chan, VPADGyroZeroDriftMode *mode);
|
||||
EXPORT_DECL(int16_t, VPADCalcTPCalibrationParam, VPADTPCalibrationParam* param, uint16_t rawX1, uint16_t rawY1, uint16_t x1, uint16_t y1, uint16_t rawX2, uint16_t rawY2, uint16_t x2, uint16_t y2);
|
||||
EXPORT_DECL(void, VPADSetTPCalibrationParam, int32_t chan, const VPADTPCalibrationParam param);
|
||||
EXPORT_DECL(void, VPADGetTPCalibrationParam, int32_t chan, VPADTPCalibrationParam* param);
|
||||
EXPORT_DECL(void, VPADGetTPCalibratedPoint, int32_t chan, VPADTPData *disp, const VPADTPData *raw);
|
||||
EXPORT_DECL(void, VPADGetTPCalibratedPointEx, int32_t chan, VPADTPResolution tpReso, VPADTPData *disp, const VPADTPData *raw);
|
||||
EXPORT_DECL(int32_t, VPADControlMotor, int32_t chan, uint8_t* pattern, uint8_t length);
|
||||
EXPORT_DECL(void, VPADStopMotor, int32_t chan);
|
||||
EXPORT_DECL(int32_t, VPADSetLcdMode, int32_t chan, int32_t lcdmode);
|
||||
EXPORT_DECL(int32_t, VPADGetLcdMode, int32_t chan, int32_t *lcdmode);
|
||||
EXPORT_DECL(int32_t, VPADBASEGetMotorOnRemainingCount, int32_t lcdmode);
|
||||
EXPORT_DECL(int32_t, VPADBASESetMotorOnRemainingCount, int32_t lcdmode, int32_t counter);
|
||||
EXPORT_DECL(void, VPADBASESetSensorBarSetting, int32_t chan, char setting);
|
||||
EXPORT_DECL(void, VPADBASEGetSensorBarSetting, int32_t chan, char *setting);
|
||||
EXPORT_DECL(int32_t, VPADSetSensorBar, int32_t chan, int32_t on);
|
||||
EXPORT_DECL(samplingCallback, VPADSetSamplingCallback, int32_t chan, samplingCallback callbackn);
|
||||
|
||||
void InitAcquireVPad(void) {
|
||||
if(coreinit_handle == 0) {
|
||||
InitAcquireOS();
|
||||
};
|
||||
OSDynLoad_Acquire("vpad.rpl", &vpad_handle);
|
||||
OSDynLoad_Acquire("vpadbase.rpl", &vpadbase_handle);
|
||||
}
|
||||
|
||||
void InitVPadFunctionPointers(void) {
|
||||
uint32_t *funcPointer = 0;
|
||||
|
||||
InitAcquireVPad();
|
||||
|
||||
OS_FIND_EXPORT(vpad_handle, VPADInit);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADShutdown);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADRead);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetAccParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetAccParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetBtnRepeat);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADEnableStickCrossClamp);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADDisableStickCrossClamp);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetLStickClampThreshold);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetRStickClampThreshold);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetLStickClampThreshold);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetRStickClampThreshold);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetStickOrigin);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADDisableLStickZeroClamp);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADDisableRStickZeroClamp);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADEnableLStickZeroClamp);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADEnableRStickZeroClamp);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetCrossStickEmulationParamsL);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetCrossStickEmulationParamsR);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetCrossStickEmulationParamsL);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetCrossStickEmulationParamsR);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetGyroAngle);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetGyroDirection);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetGyroDirectionMag);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetGyroMagnification);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADEnableGyroZeroPlay);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADEnableGyroDirRevise);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADEnableGyroAccRevise);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADDisableGyroZeroPlay);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADDisableGyroDirRevise);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADDisableGyroAccRevise);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADIsEnableGyroZeroPlay);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADIsEnableGyroZeroDrift);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADIsEnableGyroDirRevise);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADIsEnableGyroAccRevise);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetGyroZeroPlayParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetGyroDirReviseParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetGyroAccReviseParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetGyroDirReviseBase);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetGyroZeroPlayParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetGyroDirReviseParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetGyroAccReviseParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADInitGyroZeroPlayParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADInitGyroDirReviseParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADInitGyroAccReviseParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADInitGyroZeroDriftMode);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetGyroZeroDriftMode);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetGyroZeroDriftMode);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADCalcTPCalibrationParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetTPCalibrationParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetTPCalibrationParam);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetTPCalibratedPoint);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetTPCalibratedPointEx);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADControlMotor);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADStopMotor);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetLcdMode);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADGetLcdMode);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetSensorBar);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADSetSamplingCallback);
|
||||
OS_FIND_EXPORT(vpadbase_handle, VPADBASEGetMotorOnRemainingCount);
|
||||
OS_FIND_EXPORT(vpadbase_handle, VPADBASESetMotorOnRemainingCount);
|
||||
OS_FIND_EXPORT(vpadbase_handle, VPADBASESetSensorBarSetting);
|
||||
OS_FIND_EXPORT(vpadbase_handle, VPADBASEGetSensorBarSetting);
|
||||
}
|
207
src/dynamic_libs/vpad_functions.h
Normal file
@ -0,0 +1,207 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __VPAD_FUNCTIONS_H_
|
||||
#define __VPAD_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern uint32_t vpad_handle;
|
||||
extern uint32_t vpadbase_handle;
|
||||
|
||||
#define VPAD_BUTTON_A 0x8000
|
||||
#define VPAD_BUTTON_B 0x4000
|
||||
#define VPAD_BUTTON_X 0x2000
|
||||
#define VPAD_BUTTON_Y 0x1000
|
||||
#define VPAD_BUTTON_LEFT 0x0800
|
||||
#define VPAD_BUTTON_RIGHT 0x0400
|
||||
#define VPAD_BUTTON_UP 0x0200
|
||||
#define VPAD_BUTTON_DOWN 0x0100
|
||||
#define VPAD_BUTTON_ZL 0x0080
|
||||
#define VPAD_BUTTON_ZR 0x0040
|
||||
#define VPAD_BUTTON_L 0x0020
|
||||
#define VPAD_BUTTON_R 0x0010
|
||||
#define VPAD_BUTTON_PLUS 0x0008
|
||||
#define VPAD_BUTTON_MINUS 0x0004
|
||||
#define VPAD_BUTTON_HOME 0x0002
|
||||
#define VPAD_BUTTON_SYNC 0x0001
|
||||
#define VPAD_BUTTON_STICK_R 0x00020000
|
||||
#define VPAD_BUTTON_STICK_L 0x00040000
|
||||
#define VPAD_BUTTON_TV 0x00010000
|
||||
|
||||
#define VPAD_STICK_R_EMULATION_LEFT 0x04000000
|
||||
#define VPAD_STICK_R_EMULATION_RIGHT 0x02000000
|
||||
#define VPAD_STICK_R_EMULATION_UP 0x01000000
|
||||
#define VPAD_STICK_R_EMULATION_DOWN 0x00800000
|
||||
|
||||
#define VPAD_STICK_L_EMULATION_LEFT 0x40000000
|
||||
#define VPAD_STICK_L_EMULATION_RIGHT 0x20000000
|
||||
#define VPAD_STICK_L_EMULATION_UP 0x10000000
|
||||
#define VPAD_STICK_L_EMULATION_DOWN 0x08000000
|
||||
|
||||
//! Own definitions
|
||||
#define VPAD_BUTTON_TOUCH 0x00080000
|
||||
#define VPAD_MASK_EMULATED_STICKS 0x7F800000
|
||||
#define VPAD_MASK_BUTTONS ~VPAD_MASK_EMULATED_STICKS
|
||||
|
||||
typedef enum VPADTPResolution {
|
||||
VPAD_TP_1920x1080,
|
||||
VPAD_TP_1280x720,
|
||||
VPAD_TP_854x480
|
||||
} VPADTPResolution;
|
||||
|
||||
typedef enum VPADGyroZeroDriftMode {
|
||||
VPAD_GYRO_ZERODRIFT_LOOSE,
|
||||
VPAD_GYRO_ZERODRIFT_STANDARD,
|
||||
VPAD_GYRO_ZERODRIFT_TIGHT
|
||||
} VPADGyroZeroDriftMode;
|
||||
|
||||
typedef struct {
|
||||
float x,y;
|
||||
} Vec2D;
|
||||
|
||||
typedef struct {
|
||||
float x,y,z;
|
||||
} Vec3D;
|
||||
|
||||
typedef struct {
|
||||
Vec3D X,Y,Z;
|
||||
} VPADDir;
|
||||
|
||||
typedef struct {
|
||||
uint16_t x, y; /* Touch coordinates */
|
||||
uint16_t touched; /* 1 = Touched, 0 = Not touched */
|
||||
uint16_t invalid; /* 0 = All valid, 1 = X invalid, 2 = Y invalid, 3 = Both invalid? */
|
||||
} VPADTPData;
|
||||
|
||||
typedef struct {
|
||||
int16_t offsetX;
|
||||
int16_t offsetY;
|
||||
float scaleX;
|
||||
float scaleY;
|
||||
} VPADTPCalibrationParam;
|
||||
|
||||
typedef struct {
|
||||
uint32_t btns_h; /* Held buttons */
|
||||
uint32_t btns_d; /* Buttons that are pressed at that instant */
|
||||
uint32_t btns_r; /* Released buttons */
|
||||
Vec2D lstick, rstick; /* Each contains 4-byte X and Y components */
|
||||
Vec3D acc; /* Status of DRC accelerometer */
|
||||
float acc_magnitude; /* Accelerometer magnitude */
|
||||
float acc_variation; /* Accelerometer variation */
|
||||
Vec2D acc_vertical; /* Vertical */
|
||||
Vec3D gyro; /* Gyro data */
|
||||
Vec3D angle; /* Angle data */
|
||||
char error; /* Error */
|
||||
VPADTPData tpdata; /* Normal touchscreen data */
|
||||
VPADTPData tpdata1; /* Modified touchscreen data 1 */
|
||||
VPADTPData tpdata2; /* Modified touchscreen data 2 */
|
||||
VPADDir dir; /* Orientation in three-dimensional space */
|
||||
int32_t headphone; /* Set to TRUE if headphones are plugged in, FALSE otherwise */
|
||||
Vec3D mag; /* Magnetometer data */
|
||||
uint8_t volume; /* 0 to 255 */
|
||||
uint8_t battery; /* 0 to 6 */
|
||||
uint8_t mic; /* Microphone status */
|
||||
uint8_t unk_volume; /* One less than volume */
|
||||
uint8_t paddings[7];
|
||||
} VPADData;
|
||||
|
||||
void InitVPadFunctionPointers(void);
|
||||
void InitAcquireVPad(void);
|
||||
|
||||
extern void (* VPADInit)(void);
|
||||
extern void (* VPADShutdown)(void);
|
||||
extern int32_t (* VPADRead)(int32_t chan, VPADData *buffer, uint32_t buffer_size, int32_t *error);
|
||||
extern void (* VPADSetAccParam)(int32_t chan, float play_radius, float sensitivity);
|
||||
extern void (* VPADGetAccParam)(int32_t chan, float *play_radius, float *sensitivity);
|
||||
extern void (* VPADSetBtnRepeat)(int32_t chan, float delay_sec, float pulse_sec);
|
||||
extern void (* VPADEnableStickCrossClamp)(int32_t chan);
|
||||
extern void (* VPADDisableStickCrossClamp)(int32_t chan);
|
||||
extern void (* VPADSetLStickClampThreshold)(int32_t chan, int32_t max, int32_t min);
|
||||
extern void (* VPADSetRStickClampThreshold)(int32_t chan, int32_t max, int32_t min);
|
||||
extern void (* VPADGetLStickClampThreshold)(int32_t chan, int32_t* max, int32_t* min);
|
||||
extern void (* VPADGetRStickClampThreshold)(int32_t chan, int32_t* max, int32_t* min);
|
||||
extern void (* VPADSetStickOrigin)(int32_t chan);
|
||||
extern void (* VPADDisableLStickZeroClamp)(int32_t chan);
|
||||
extern void (* VPADDisableRStickZeroClamp)(int32_t chan);
|
||||
extern void (* VPADEnableLStickZeroClamp)(int32_t chan);
|
||||
extern void (* VPADEnableRStickZeroClamp)(int32_t chan);
|
||||
extern void (* VPADSetCrossStickEmulationParamsL)(int32_t chan, float rot_deg, float xy_deg, float radius);
|
||||
extern void (* VPADSetCrossStickEmulationParamsR)(int32_t chan, float rot_deg, float xy_deg, float radius);
|
||||
extern void (* VPADGetCrossStickEmulationParamsL)(int32_t chan, float* rot_deg, float* xy_deg, float* radius);
|
||||
extern void (* VPADGetCrossStickEmulationParamsR)(int32_t chan, float* rot_deg, float* xy_deg, float* radius);
|
||||
extern void (* VPADSetGyroAngle)(int32_t chan, float ax, float ay, float az);
|
||||
extern void (* VPADSetGyroDirection)(int32_t chan, VPADDir *dir);
|
||||
extern void (* VPADSetGyroDirectionMag)(int32_t chan, float mag);
|
||||
extern void (* VPADSetGyroMagnification)(int32_t chan, float pitch, float yaw, float roll);
|
||||
extern void (* VPADEnableGyroZeroPlay)(int32_t chan);
|
||||
extern void (* VPADEnableGyroDirRevise)(int32_t chan);
|
||||
extern void (* VPADEnableGyroAccRevise)(int32_t chan);
|
||||
extern void (* VPADDisableGyroZeroPlay)(int32_t chan);
|
||||
extern void (* VPADDisableGyroDirRevise)(int32_t chan);
|
||||
extern void (* VPADDisableGyroAccRevise)(int32_t chan);
|
||||
extern float (* VPADIsEnableGyroZeroPlay)(int32_t chan);
|
||||
extern float (* VPADIsEnableGyroZeroDrift)(int32_t chan);
|
||||
extern float (* VPADIsEnableGyroDirRevise)(int32_t chan);
|
||||
extern float (* VPADIsEnableGyroAccRevise)(int32_t chan);
|
||||
extern void (* VPADSetGyroZeroPlayParam)(int32_t chan, float radius);
|
||||
extern void (* VPADSetGyroDirReviseParam)(int32_t chan, float revis_pw);
|
||||
extern void (* VPADSetGyroAccReviseParam)(int32_t chan, float revise_pw, float revise_range);
|
||||
extern void (* VPADSetGyroDirReviseBase)(int32_t chan, VPADDir *base);
|
||||
extern void (* VPADGetGyroZeroPlayParam)(int32_t chan, float *radius);
|
||||
extern void (* VPADGetGyroDirReviseParam)(int32_t chan, float *revise_pw);
|
||||
extern void (* VPADGetGyroAccReviseParam)(int32_t chan, float *revise_pw, float *revise_range);
|
||||
extern void (* VPADInitGyroZeroPlayParam)(int32_t chan);
|
||||
extern void (* VPADInitGyroDirReviseParam)(int32_t chan);
|
||||
extern void (* VPADInitGyroAccReviseParam)(int32_t chan);
|
||||
extern void (* VPADInitGyroZeroDriftMode)(int32_t chan);
|
||||
extern void (* VPADSetGyroZeroDriftMode)(int32_t chan, VPADGyroZeroDriftMode mode);
|
||||
extern void (* VPADGetGyroZeroDriftMode)(int32_t chan, VPADGyroZeroDriftMode *mode);
|
||||
extern int16_t (* VPADCalcTPCalibrationParam)(VPADTPCalibrationParam* param, uint16_t rawX1, uint16_t rawY1, uint16_t x1, uint16_t y1, uint16_t rawX2, uint16_t rawY2, uint16_t x2, uint16_t y2);
|
||||
extern void (* VPADSetTPCalibrationParam)(int32_t chan, const VPADTPCalibrationParam param);
|
||||
extern void (* VPADGetTPCalibrationParam)(int32_t chan, VPADTPCalibrationParam* param);
|
||||
extern void (* VPADGetTPCalibratedPoint)(int32_t chan, VPADTPData *disp, const VPADTPData *raw);
|
||||
extern void (* VPADGetTPCalibratedPointEx)(int32_t chan, VPADTPResolution tpReso, VPADTPData *disp, const VPADTPData *raw);
|
||||
extern int32_t (* VPADControlMotor)(int32_t chan, uint8_t* pattern, uint8_t length);
|
||||
extern void (* VPADStopMotor)(int32_t chan);
|
||||
extern int32_t (* VPADSetLcdMode)(int32_t chan, int32_t lcdmode);
|
||||
extern int32_t (* VPADGetLcdMode)(int32_t chan, int32_t *lcdmode);
|
||||
extern int32_t (* VPADBASEGetMotorOnRemainingCount)(int32_t lcdmode);
|
||||
extern int32_t (* VPADBASESetMotorOnRemainingCount)(int32_t lcdmode, int32_t counter);
|
||||
extern void (* VPADBASESetSensorBarSetting)(int32_t chan, char setting);
|
||||
extern void (* VPADBASEGetSensorBarSetting)(int32_t chan, char *setting);
|
||||
extern int32_t (*VPADSetSensorBar)(int32_t chan, int32_t on);
|
||||
|
||||
typedef void(*samplingCallback)(int32_t chan);
|
||||
extern samplingCallback ( *VPADSetSamplingCallback)(int32_t chan, samplingCallback callback);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __VPAD_FUNCTIONS_H_
|
@ -1,9 +0,0 @@
|
||||
#include <string.h>
|
||||
#include "main.h"
|
||||
|
||||
int32_t __entry_menu(int32_t argc, char **argv) {
|
||||
//! *******************************************************************
|
||||
//! * Jump to our application *
|
||||
//! *******************************************************************
|
||||
return Menu_Main(argc,argv);
|
||||
}
|
214
src/entry.cpp
Normal file
@ -0,0 +1,214 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "dynamic_libs/coreinit.h"
|
||||
#include "dynamic_libs/socket_functions.h"
|
||||
#include "dynamic_libs/fs_functions.h"
|
||||
#include "dynamic_libs/gx2_functions.h"
|
||||
#include "dynamic_libs/vpad_functions.h"
|
||||
#include "kernel/kernel_utils.h"
|
||||
#include "memory/memory_mapping.h"
|
||||
#include "memory/memory.h"
|
||||
#include "utils/ConfigUtils.h"
|
||||
#include "utils/function_patcher.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/ipc.h"
|
||||
#include "utils.h"
|
||||
#include "system/CThread.h"
|
||||
#include "common/retain_vars.h"
|
||||
#include "plugin/PluginLoader.h"
|
||||
#include "plugin/DynamicLinkingHelper.h"
|
||||
|
||||
#include <fs/sd_fat_devoptab.h>
|
||||
|
||||
#include "patcher/function_patcher.h"
|
||||
#include "patcher/hooks_patcher.h"
|
||||
#include "patcher/hooks_patcher_static.h"
|
||||
|
||||
int SplashScreen(int32_t time,const char * message,uint8_t pos,uint32_t button) {
|
||||
//Call the Screen initilzation function.
|
||||
OSScreenInit();
|
||||
|
||||
|
||||
int result = 0;
|
||||
// Prepare screen
|
||||
int32_t screen_buf0_size = 0;
|
||||
|
||||
// Init screen and screen buffers
|
||||
OSScreenInit();
|
||||
screen_buf0_size = OSScreenGetBufferSizeEx(0);
|
||||
OSScreenSetBufferEx(0, (void *)0xF4000000);
|
||||
OSScreenSetBufferEx(1, (void *)(0xF4000000 + screen_buf0_size));
|
||||
|
||||
OSScreenEnableEx(0, 1);
|
||||
OSScreenEnableEx(1, 1);
|
||||
|
||||
// Clear screens
|
||||
OSScreenClearBufferEx(0, 0);
|
||||
OSScreenClearBufferEx(1, 0);
|
||||
|
||||
// Flip buffers
|
||||
OSScreenFlipBuffersEx(0);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
|
||||
OSScreenPutFontEx(0, 0, pos, message);
|
||||
OSScreenPutFontEx(1, 0, pos, message);
|
||||
|
||||
OSScreenFlipBuffersEx(0);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
|
||||
int32_t tickswait = time * 1000*1000;
|
||||
int32_t times = 1000;
|
||||
int32_t sleepingtime = tickswait / 1000;
|
||||
int32_t i=0;
|
||||
|
||||
void(*OSSleepTicks)(uint64_t x);
|
||||
OSDynLoad_FindExport(coreinit_handle, 0, "OSSleepTicks", &OSSleepTicks);
|
||||
|
||||
while(i<times) {
|
||||
i++;
|
||||
|
||||
OSSleepTicks(OSMicrosecondsToTicks(sleepingtime));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void readAndPrintSegmentRegister(CThread *thread, void *arg);
|
||||
|
||||
|
||||
void ApplyPatchesAndCallHookStartingApp() {
|
||||
PatchInvidualMethodHooks(method_hooks_hooks_static, method_hooks_size_hooks_static, method_calls_hooks_static);
|
||||
PatchInvidualMethodHooks(method_hooks_hooks, method_hooks_size_hooks, method_calls_hooks);
|
||||
for(int32_t plugin_index=0; plugin_index<gbl_replacement_data.number_used_plugins; plugin_index++) {
|
||||
CallHookEx(WUPS_LOADER_HOOK_STARTING_APPLICATION,plugin_index);
|
||||
new_PatchInvidualMethodHooks(&gbl_replacement_data.plugin_data[plugin_index]);
|
||||
CallHookEx(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED,plugin_index);
|
||||
}
|
||||
}
|
||||
|
||||
void RestorePatches() {
|
||||
for(int32_t plugin_index=gbl_replacement_data.number_used_plugins-1; plugin_index>=0; plugin_index--) {
|
||||
DEBUG_FUNCTION_LINE("Restoring function for plugin: %d\n",plugin_index);
|
||||
new_RestoreInvidualInstructions(&gbl_replacement_data.plugin_data[plugin_index]);
|
||||
}
|
||||
RestoreInvidualInstructions(method_hooks_hooks, method_hooks_size_hooks);
|
||||
RestoreInvidualInstructions(method_hooks_hooks_static, method_hooks_size_hooks_static);
|
||||
}
|
||||
|
||||
void RestoreEverything() {
|
||||
CallHook(WUPS_LOADER_HOOK_DEINIT_PLUGIN);
|
||||
uint32_t old = gAppStatus;
|
||||
gAppStatus = 3;
|
||||
CallHook(WUPS_LOADER_HOOK_APP_STATUS_CHANGED);
|
||||
gAppStatus = old;
|
||||
CallHook(WUPS_LOADER_HOOK_ENDING_APPLICATION);
|
||||
// Restore patches as the patched functions could change.
|
||||
RestorePatches();
|
||||
DynamicLinkingHelper::getInstance()->clearAll();
|
||||
}
|
||||
|
||||
|
||||
void ResolveRelocations() {
|
||||
std::vector<dyn_linking_relocation_entry_t *> relocations = DynamicLinkingHelper::getInstance()->getAllValidDynamicLinkingRelocations();
|
||||
DEBUG_FUNCTION_LINE("Found relocation information for %d functions\n",relocations.size());
|
||||
|
||||
if(!DynamicLinkingHelper::getInstance()->fillRelocations(relocations)) {
|
||||
OSFatal("fillRelocations failed.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void afterLoadAndLink() {
|
||||
ResolveRelocations();
|
||||
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_VID_MEM);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_KERNEL);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_FS);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_OVERLAY);
|
||||
ConfigUtils::loadConfigFromSD();
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_PLUGIN);
|
||||
}
|
||||
|
||||
|
||||
extern "C" int _start(int argc, char **argv) {
|
||||
if(gAppStatus == 2) {
|
||||
//"No, we don't want to patch stuff again.");
|
||||
return ( (int (*)(int, char **))(*(unsigned int*)0x1005E040) )(argc, argv);
|
||||
}
|
||||
coreinit_handle = 0;
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
InitFSFunctionPointers();
|
||||
InitVPadFunctionPointers();
|
||||
InitGX2FunctionPointers();
|
||||
|
||||
// is called once.
|
||||
kernelInitialize();
|
||||
|
||||
gGameTitleID = OSGetTitleID();
|
||||
|
||||
memset(&tv_store,0,sizeof(tv_store));
|
||||
memset(&drc_store,0,sizeof(drc_store));
|
||||
|
||||
|
||||
if(!MemoryMapping::isMemoryMapped()) {
|
||||
MemoryMapping::setupMemoryMapping();
|
||||
// Switch to custom heap
|
||||
|
||||
//Does not work =(
|
||||
//initMemory();
|
||||
//SplashScreen(1, "Memory mapping was completed!", 0,0);
|
||||
|
||||
|
||||
// Init space
|
||||
DynamicLinkingHelper::getInstance()->clearAll();
|
||||
|
||||
// Init IPC
|
||||
uint32_t* ipcFunction = (uint32_t*)(MEMORY_START_PLUGIN_SPACE);
|
||||
*ipcFunction = (uint32_t) &ipc_ioctl;
|
||||
DCFlushRange(ipcFunction,4);
|
||||
ICInvalidateRange(ipcFunction,4);
|
||||
|
||||
log_init();
|
||||
|
||||
DEBUG_FUNCTION_LINE("log init done\n");
|
||||
|
||||
DEBUG_FUNCTION_LINE("Patch own stuff\n");
|
||||
|
||||
// Do patches so memmory mapping works fine with some functions.
|
||||
PatchInvidualMethodHooks(method_hooks_hooks_static, method_hooks_size_hooks_static, method_calls_hooks_static);
|
||||
|
||||
// mount sd card.
|
||||
mount_sd_fat("sd");
|
||||
|
||||
PluginLoader * pluginLoader = new PluginLoader((void*)PLUGIN_LOCATION_START_ADDRESS, (void*)PLUGIN_LOCATION_END_ADDRESS);
|
||||
|
||||
std::vector<PluginInformation *> pluginList = pluginLoader->getPluginInformation("sd:/wiiu/autoboot_plugins/");
|
||||
pluginLoader->loadAndLinkPlugins(pluginList);
|
||||
pluginLoader->clearPluginInformation(pluginList);
|
||||
delete pluginLoader;
|
||||
|
||||
afterLoadAndLink();
|
||||
} else {
|
||||
log_init();
|
||||
DEBUG_FUNCTION_LINE("Mapping was already done\n");
|
||||
//unmount_sd_fat("sd");
|
||||
mount_sd_fat("sd");
|
||||
|
||||
//SplashScreen(5, "Memory mapping was already done!!", 0,0);
|
||||
//readAndPrintSegmentRegister(NULL,NULL);
|
||||
//MemoryMapping::writeTestValuesToMemory();
|
||||
//MemoryMapping::readTestValuesFromMemory();
|
||||
}
|
||||
|
||||
std::vector<dyn_linking_relocation_entry_t *> relocations = DynamicLinkingHelper::getInstance()->getAllValidDynamicLinkingRelocations();
|
||||
DEBUG_FUNCTION_LINE("Found relocation information for %d functions\n",relocations.size());
|
||||
|
||||
if(!DynamicLinkingHelper::getInstance()->fillRelocations(relocations)) {
|
||||
OSFatal("fillRelocations failed.");
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Apply patches.\n");
|
||||
ApplyPatchesAndCallHookStartingApp();
|
||||
|
||||
return ( (int (*)(int, char **))(*(unsigned int*)0x1005E040) )(argc, argv);
|
||||
}
|
174
src/fs/CFile.cpp
Normal file
@ -0,0 +1,174 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "CFile.hpp"
|
||||
|
||||
CFile::CFile() {
|
||||
iFd = -1;
|
||||
mem_file = NULL;
|
||||
filesize = 0;
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
CFile::CFile(const std::string & filepath, eOpenTypes mode) {
|
||||
iFd = -1;
|
||||
this->open(filepath, mode);
|
||||
}
|
||||
|
||||
CFile::CFile(const uint8_t * mem, int32_t size) {
|
||||
iFd = -1;
|
||||
this->open(mem, size);
|
||||
}
|
||||
|
||||
CFile::~CFile() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
int32_t CFile::open(const std::string & filepath, eOpenTypes mode) {
|
||||
this->close();
|
||||
|
||||
int32_t openMode = 0;
|
||||
|
||||
switch(mode) {
|
||||
default:
|
||||
case ReadOnly:
|
||||
openMode = O_RDONLY;
|
||||
break;
|
||||
case WriteOnly:
|
||||
openMode = O_WRONLY;
|
||||
break;
|
||||
case ReadWrite:
|
||||
openMode = O_RDWR;
|
||||
break;
|
||||
case Append:
|
||||
openMode = O_APPEND | O_WRONLY;
|
||||
break;
|
||||
}
|
||||
|
||||
//! Using fopen works only on the first launch as expected
|
||||
//! on the second launch it causes issues because we don't overwrite
|
||||
//! the .data sections which is needed for a normal application to re-init
|
||||
//! this will be added with launching as RPX
|
||||
iFd = ::open(filepath.c_str(), openMode);
|
||||
if(iFd < 0)
|
||||
return iFd;
|
||||
|
||||
|
||||
filesize = ::lseek(iFd, 0, SEEK_END);
|
||||
::lseek(iFd, 0, SEEK_SET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CFile::open(const uint8_t * mem, int32_t size) {
|
||||
this->close();
|
||||
|
||||
mem_file = mem;
|
||||
filesize = size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CFile::close() {
|
||||
if(iFd >= 0)
|
||||
::close(iFd);
|
||||
|
||||
iFd = -1;
|
||||
mem_file = NULL;
|
||||
filesize = 0;
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
int32_t CFile::read(uint8_t * ptr, size_t size) {
|
||||
if(iFd >= 0) {
|
||||
int32_t ret = ::read(iFd, ptr,size);
|
||||
if(ret > 0)
|
||||
pos += ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t readsize = size;
|
||||
|
||||
if(readsize > (int64_t) (filesize-pos))
|
||||
readsize = filesize-pos;
|
||||
|
||||
if(readsize <= 0)
|
||||
return readsize;
|
||||
|
||||
if(mem_file != NULL) {
|
||||
memcpy(ptr, mem_file+pos, readsize);
|
||||
pos += readsize;
|
||||
return readsize;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t CFile::write(const uint8_t * ptr, size_t size) {
|
||||
if(iFd >= 0) {
|
||||
size_t done = 0;
|
||||
while(done < size) {
|
||||
int32_t ret = ::write(iFd, ptr, size - done);
|
||||
if(ret <= 0)
|
||||
return ret;
|
||||
|
||||
ptr += ret;
|
||||
done += ret;
|
||||
pos += ret;
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t CFile::seek(long int offset, int32_t origin) {
|
||||
int32_t ret = 0;
|
||||
int64_t newPos = pos;
|
||||
|
||||
if(origin == SEEK_SET) {
|
||||
newPos = offset;
|
||||
} else if(origin == SEEK_CUR) {
|
||||
newPos += offset;
|
||||
} else if(origin == SEEK_END) {
|
||||
newPos = filesize+offset;
|
||||
}
|
||||
|
||||
if(newPos < 0) {
|
||||
pos = 0;
|
||||
} else {
|
||||
pos = newPos;
|
||||
}
|
||||
|
||||
if(iFd >= 0)
|
||||
ret = ::lseek(iFd, pos, SEEK_SET);
|
||||
|
||||
if(mem_file != NULL) {
|
||||
if(pos > filesize) {
|
||||
pos = filesize;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t CFile::fwrite(const char *format, ...) {
|
||||
int32_t result = -1;
|
||||
char * tmp = NULL;
|
||||
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
if((vasprintf(&tmp, format, va) >= 0) && tmp) {
|
||||
result = this->write((uint8_t *)tmp, strlen(tmp));
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
if(tmp) {
|
||||
free(tmp);
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
61
src/fs/CFile.hpp
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef CFILE_HPP_
|
||||
#define CFILE_HPP_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
class CFile {
|
||||
public:
|
||||
enum eOpenTypes {
|
||||
ReadOnly,
|
||||
WriteOnly,
|
||||
ReadWrite,
|
||||
Append
|
||||
};
|
||||
|
||||
CFile();
|
||||
CFile(const std::string & filepath, eOpenTypes mode);
|
||||
CFile(const uint8_t * memory, int32_t memsize);
|
||||
virtual ~CFile();
|
||||
|
||||
int32_t open(const std::string & filepath, eOpenTypes mode);
|
||||
int32_t open(const uint8_t * memory, int32_t memsize);
|
||||
|
||||
bool isOpen() const {
|
||||
if(iFd >= 0)
|
||||
return true;
|
||||
|
||||
if(mem_file)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void close();
|
||||
|
||||
int32_t read(uint8_t * ptr, size_t size);
|
||||
int32_t write(const uint8_t * ptr, size_t size);
|
||||
int32_t fwrite(const char *format, ...);
|
||||
int32_t seek(long int offset, int32_t origin);
|
||||
uint64_t tell() {
|
||||
return pos;
|
||||
};
|
||||
uint64_t size() {
|
||||
return filesize;
|
||||
};
|
||||
void rewind() {
|
||||
this->seek(0, SEEK_SET);
|
||||
};
|
||||
|
||||
protected:
|
||||
int32_t iFd;
|
||||
const uint8_t * mem_file;
|
||||
uint64_t filesize;
|
||||
uint64_t pos;
|
||||
};
|
||||
|
||||
#endif
|
212
src/fs/DirList.cpp
Normal file
@ -0,0 +1,212 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2010
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*
|
||||
* DirList Class
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/dirent.h>
|
||||
|
||||
#include "DirList.h"
|
||||
#include "utils/StringTools.h"
|
||||
|
||||
DirList::DirList() {
|
||||
Flags = 0;
|
||||
Filter = 0;
|
||||
Depth = 0;
|
||||
}
|
||||
|
||||
DirList::DirList(const std::string & path, const char *filter, uint32_t flags, uint32_t maxDepth) {
|
||||
this->LoadPath(path, filter, flags, maxDepth);
|
||||
this->SortList();
|
||||
}
|
||||
|
||||
DirList::~DirList() {
|
||||
ClearList();
|
||||
}
|
||||
|
||||
bool DirList::LoadPath(const std::string & folder, const char *filter, uint32_t flags, uint32_t maxDepth) {
|
||||
if(folder.empty()) return false;
|
||||
|
||||
Flags = flags;
|
||||
Filter = filter;
|
||||
Depth = maxDepth;
|
||||
|
||||
std::string folderpath(folder);
|
||||
uint32_t length = folderpath.size();
|
||||
|
||||
//! clear path of double slashes
|
||||
StringTools::RemoveDoubleSlashs(folderpath);
|
||||
|
||||
//! remove last slash if exists
|
||||
if(length > 0 && folderpath[length-1] == '/')
|
||||
folderpath.erase(length-1);
|
||||
|
||||
//! add root slash if missing
|
||||
if(folderpath.find('/') == std::string::npos) {
|
||||
folderpath += '/';
|
||||
}
|
||||
|
||||
return InternalLoadPath(folderpath);
|
||||
}
|
||||
|
||||
bool DirList::InternalLoadPath(std::string &folderpath) {
|
||||
if(folderpath.size() < 3)
|
||||
return false;
|
||||
|
||||
struct dirent *dirent = NULL;
|
||||
DIR *dir = NULL;
|
||||
|
||||
dir = opendir(folderpath.c_str());
|
||||
if (dir == NULL)
|
||||
return false;
|
||||
|
||||
while ((dirent = readdir(dir)) != 0) {
|
||||
bool isDir = dirent->d_type & DT_DIR;
|
||||
const char *filename = dirent->d_name;
|
||||
|
||||
if(isDir) {
|
||||
if(strcmp(filename,".") == 0 || strcmp(filename,"..") == 0)
|
||||
continue;
|
||||
|
||||
if((Flags & CheckSubfolders) && (Depth > 0)) {
|
||||
int32_t length = folderpath.size();
|
||||
if(length > 2 && folderpath[length-1] != '/') {
|
||||
folderpath += '/';
|
||||
}
|
||||
folderpath += filename;
|
||||
|
||||
Depth--;
|
||||
InternalLoadPath(folderpath);
|
||||
folderpath.erase(length);
|
||||
Depth++;
|
||||
}
|
||||
|
||||
if(!(Flags & Dirs))
|
||||
continue;
|
||||
} else if(!(Flags & Files)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(Filter) {
|
||||
char * fileext = strrchr(filename, '.');
|
||||
if(!fileext)
|
||||
continue;
|
||||
|
||||
if(StringTools::strtokcmp(fileext, Filter, ",") == 0)
|
||||
AddEntrie(folderpath, filename, isDir);
|
||||
} else {
|
||||
AddEntrie(folderpath, filename, isDir);
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DirList::AddEntrie(const std::string &filepath, const char * filename, bool isDir) {
|
||||
if(!filename)
|
||||
return;
|
||||
|
||||
int32_t pos = FileInfo.size();
|
||||
|
||||
FileInfo.resize(pos+1);
|
||||
|
||||
FileInfo[pos].FilePath = (char *) malloc(filepath.size()+strlen(filename)+2);
|
||||
if(!FileInfo[pos].FilePath) {
|
||||
FileInfo.resize(pos);
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(FileInfo[pos].FilePath, "%s/%s", filepath.c_str(), filename);
|
||||
FileInfo[pos].isDir = isDir;
|
||||
}
|
||||
|
||||
void DirList::ClearList() {
|
||||
for(uint32_t i = 0; i < FileInfo.size(); ++i) {
|
||||
if(FileInfo[i].FilePath) {
|
||||
free(FileInfo[i].FilePath);
|
||||
FileInfo[i].FilePath = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
FileInfo.clear();
|
||||
std::vector<DirEntry>().swap(FileInfo);
|
||||
}
|
||||
|
||||
const char * DirList::GetFilename(int32_t ind) const {
|
||||
if (!valid(ind))
|
||||
return "";
|
||||
|
||||
return StringTools::FullpathToFilename(FileInfo[ind].FilePath);
|
||||
}
|
||||
|
||||
static bool SortCallback(const DirEntry & f1, const DirEntry & f2) {
|
||||
if(f1.isDir && !(f2.isDir)) return true;
|
||||
if(!(f1.isDir) && f2.isDir) return false;
|
||||
|
||||
if(f1.FilePath && !f2.FilePath) return true;
|
||||
if(!f1.FilePath) return false;
|
||||
|
||||
if(strcasecmp(f1.FilePath, f2.FilePath) > 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DirList::SortList() {
|
||||
if(FileInfo.size() > 1)
|
||||
std::sort(FileInfo.begin(), FileInfo.end(), SortCallback);
|
||||
}
|
||||
|
||||
void DirList::SortList(bool (*SortFunc)(const DirEntry &a, const DirEntry &b)) {
|
||||
if(FileInfo.size() > 1)
|
||||
std::sort(FileInfo.begin(), FileInfo.end(), SortFunc);
|
||||
}
|
||||
|
||||
uint64_t DirList::GetFilesize(int32_t index) const {
|
||||
struct stat st;
|
||||
const char *path = GetFilepath(index);
|
||||
|
||||
if(!path || stat(path, &st) != 0)
|
||||
return 0;
|
||||
|
||||
return st.st_size;
|
||||
}
|
||||
|
||||
int32_t DirList::GetFileIndex(const char *filename) const {
|
||||
if(!filename)
|
||||
return -1;
|
||||
|
||||
for (uint32_t i = 0; i < FileInfo.size(); ++i) {
|
||||
if (strcasecmp(GetFilename(i), filename) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
103
src/fs/DirList.h
Normal file
@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2010
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*
|
||||
* DirList Class
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#ifndef ___DIRLIST_H_
|
||||
#define ___DIRLIST_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
char * FilePath;
|
||||
bool isDir;
|
||||
} DirEntry;
|
||||
|
||||
class DirList {
|
||||
public:
|
||||
//!Constructor
|
||||
DirList(void);
|
||||
//!\param path Path from where to load the filelist of all files
|
||||
//!\param filter A fileext that needs to be filtered
|
||||
//!\param flags search/filter flags from the enum
|
||||
DirList(const std::string & path, const char *filter = NULL, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff);
|
||||
//!Destructor
|
||||
virtual ~DirList();
|
||||
//! Load all the files from a directory
|
||||
bool LoadPath(const std::string & path, const char *filter = NULL, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff);
|
||||
//! Get a filename of the list
|
||||
//!\param list index
|
||||
const char * GetFilename(int32_t index) const;
|
||||
//! Get the a filepath of the list
|
||||
//!\param list index
|
||||
const char *GetFilepath(int32_t index) const {
|
||||
if (!valid(index)) return "";
|
||||
else return FileInfo[index].FilePath;
|
||||
}
|
||||
//! Get the a filesize of the list
|
||||
//!\param list index
|
||||
uint64_t GetFilesize(int32_t index) const;
|
||||
//! Is index a dir or a file
|
||||
//!\param list index
|
||||
bool IsDir(int32_t index) const {
|
||||
if(!valid(index)) return false;
|
||||
return FileInfo[index].isDir;
|
||||
};
|
||||
//! Get the filecount of the whole list
|
||||
int32_t GetFilecount() const {
|
||||
return FileInfo.size();
|
||||
};
|
||||
//! Sort list by filepath
|
||||
void SortList();
|
||||
//! Custom sort command for custom sort functions definitions
|
||||
void SortList(bool (*SortFunc)(const DirEntry &a, const DirEntry &b));
|
||||
//! Get the index of the specified filename
|
||||
int32_t GetFileIndex(const char *filename) const;
|
||||
//! Enum for search/filter flags
|
||||
enum {
|
||||
Files = 0x01,
|
||||
Dirs = 0x02,
|
||||
CheckSubfolders = 0x08,
|
||||
};
|
||||
protected:
|
||||
// Internal parser
|
||||
bool InternalLoadPath(std::string &path);
|
||||
//!Add a list entrie
|
||||
void AddEntrie(const std::string &filepath, const char * filename, bool isDir);
|
||||
//! Clear the list
|
||||
void ClearList();
|
||||
//! Check if valid pos is requested
|
||||
inline bool valid(uint32_t pos) const {
|
||||
return (pos < FileInfo.size());
|
||||
};
|
||||
|
||||
uint32_t Flags;
|
||||
uint32_t Depth;
|
||||
const char *Filter;
|
||||
std::vector<DirEntry> FileInfo;
|
||||
};
|
||||
|
||||
#endif
|
56
src/fs/FSOSUtils.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "FSOSUtils.h"
|
||||
#include "dynamic_libs/coreinit.h"
|
||||
#include "dynamic_libs/fs_defs.h"
|
||||
#include "dynamic_libs/fs_functions.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
int32_t FSOSUtils::MountFS(void *pClient, void *pCmd, char **mount_path) {
|
||||
InitOSFunctionPointers();
|
||||
int32_t result = -1;
|
||||
|
||||
void *mountSrc = ((void * (*)(size_t))(*pMEMAllocFromDefaultHeap))(FS_MOUNT_SOURCE_SIZE);
|
||||
if(!mountSrc) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
char* mountPath = (char*) ((void * (*)(size_t))(*pMEMAllocFromDefaultHeap))(FS_MAX_MOUNTPATH_SIZE);
|
||||
if(!mountPath) {
|
||||
free(mountSrc);
|
||||
mountSrc = NULL;
|
||||
return -4;
|
||||
}
|
||||
|
||||
memset(mountSrc, 0, FS_MOUNT_SOURCE_SIZE);
|
||||
memset(mountPath, 0, FS_MAX_MOUNTPATH_SIZE);
|
||||
// Mount sdcard
|
||||
if (FSGetMountSource(pClient, pCmd, FS_SOURCETYPE_EXTERNAL, mountSrc, -1) == 0) {
|
||||
result = FSMount(pClient, pCmd, mountSrc, mountPath, FS_MAX_MOUNTPATH_SIZE, -1);
|
||||
if((result == 0) && mount_path) {
|
||||
*mount_path = (char*)malloc(strlen(mountPath) + 1);
|
||||
if(*mount_path)
|
||||
strcpy(*mount_path, mountPath);
|
||||
}
|
||||
}
|
||||
DEBUG_FUNCTION_LINE(".\n");
|
||||
((void (*)(void *))(*pMEMFreeToDefaultHeap))(mountPath);
|
||||
((void (*)(void *))(*pMEMFreeToDefaultHeap))(mountSrc);
|
||||
//free(mountPath);
|
||||
//free(mountSrc);
|
||||
|
||||
mountPath = NULL;
|
||||
mountSrc = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t FSOSUtils::UmountFS(void *pClient, void *pCmd, const char *mountPath) {
|
||||
int32_t result = -1;
|
||||
result = FSUnmount(pClient, pCmd, mountPath, -1);
|
||||
|
||||
return result;
|
||||
}
|
13
src/fs/FSOSUtils.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef __FS_OS_UTILS_H_
|
||||
#define __FS_OS_UTILS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class FSOSUtils {
|
||||
public:
|
||||
|
||||
static int32_t MountFS(void *pClient, void *pCmd, char **mount_path);
|
||||
static int32_t UmountFS(void *pClient, void *pCmd, const char *mountPath);
|
||||
};
|
||||
|
||||
#endif // __FS_OS_UTILS_H_
|
144
src/fs/FSUtils.cpp
Normal file
@ -0,0 +1,144 @@
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "FSUtils.h"
|
||||
#include "CFile.hpp"
|
||||
#include "utils/logger.h"
|
||||
|
||||
int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) {
|
||||
//! always initialze input
|
||||
*inbuffer = NULL;
|
||||
if(size)
|
||||
*size = 0;
|
||||
|
||||
int32_t iFd = open(filepath, O_RDONLY);
|
||||
if (iFd < 0)
|
||||
return -1;
|
||||
|
||||
uint32_t filesize = lseek(iFd, 0, SEEK_END);
|
||||
lseek(iFd, 0, SEEK_SET);
|
||||
|
||||
uint8_t *buffer = (uint8_t *) malloc(filesize);
|
||||
if (buffer == NULL) {
|
||||
close(iFd);
|
||||
return -2;
|
||||
}
|
||||
|
||||
uint32_t blocksize = 0x4000;
|
||||
uint32_t done = 0;
|
||||
int32_t readBytes = 0;
|
||||
|
||||
while(done < filesize) {
|
||||
if(done + blocksize > filesize) {
|
||||
blocksize = filesize - done;
|
||||
}
|
||||
readBytes = read(iFd, buffer + done, blocksize);
|
||||
if(readBytes <= 0)
|
||||
break;
|
||||
done += readBytes;
|
||||
}
|
||||
|
||||
close(iFd);
|
||||
|
||||
if (done != filesize) {
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
return -3;
|
||||
}
|
||||
|
||||
*inbuffer = buffer;
|
||||
|
||||
//! sign is optional input
|
||||
if(size) {
|
||||
*size = filesize;
|
||||
}
|
||||
|
||||
return filesize;
|
||||
}
|
||||
|
||||
int32_t FSUtils::CheckFile(const char * filepath) {
|
||||
if(!filepath)
|
||||
return 0;
|
||||
|
||||
struct stat filestat;
|
||||
|
||||
char dirnoslash[strlen(filepath)+2];
|
||||
snprintf(dirnoslash, sizeof(dirnoslash), "%s", filepath);
|
||||
|
||||
while(dirnoslash[strlen(dirnoslash)-1] == '/')
|
||||
dirnoslash[strlen(dirnoslash)-1] = '\0';
|
||||
|
||||
char * notRoot = strrchr(dirnoslash, '/');
|
||||
if(!notRoot) {
|
||||
strcat(dirnoslash, "/");
|
||||
}
|
||||
|
||||
if (stat(dirnoslash, &filestat) == 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t FSUtils::CreateSubfolder(const char * fullpath) {
|
||||
if(!fullpath)
|
||||
return 0;
|
||||
|
||||
int32_t result = 0;
|
||||
|
||||
char dirnoslash[strlen(fullpath)+1];
|
||||
strcpy(dirnoslash, fullpath);
|
||||
|
||||
int32_t pos = strlen(dirnoslash)-1;
|
||||
while(dirnoslash[pos] == '/') {
|
||||
dirnoslash[pos] = '\0';
|
||||
pos--;
|
||||
}
|
||||
|
||||
if(CheckFile(dirnoslash)) {
|
||||
return 1;
|
||||
} else {
|
||||
char parentpath[strlen(dirnoslash)+2];
|
||||
strcpy(parentpath, dirnoslash);
|
||||
char * ptr = strrchr(parentpath, '/');
|
||||
|
||||
if(!ptr) {
|
||||
//!Device root directory (must be with '/')
|
||||
strcat(parentpath, "/");
|
||||
struct stat filestat;
|
||||
if (stat(parentpath, &filestat) == 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ptr++;
|
||||
ptr[0] = '\0';
|
||||
|
||||
result = CreateSubfolder(parentpath);
|
||||
}
|
||||
|
||||
if(!result)
|
||||
return 0;
|
||||
|
||||
if (mkdir(dirnoslash, 0777) == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool FSUtils::saveBufferToFile(const char * path, void * buffer, uint32_t size) {
|
||||
int32_t res = open(path, O_CREAT | O_TRUNC | O_WRONLY);
|
||||
close(res);
|
||||
CFile file(path, CFile::WriteOnly);
|
||||
if (!file.isOpen()) {
|
||||
DEBUG_FUNCTION_LINE("Failed to open %s\n",path);
|
||||
return false;
|
||||
}
|
||||
file.write((const uint8_t*) buffer,size);
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
15
src/fs/FSUtils.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef __FS_UTILS_H_
|
||||
#define __FS_UTILS_H_
|
||||
#include <stdint.h>
|
||||
|
||||
class FSUtils {
|
||||
public:
|
||||
static int32_t LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size);
|
||||
|
||||
//! todo: C++ class
|
||||
static int32_t CreateSubfolder(const char * fullpath);
|
||||
static int32_t CheckFile(const char * filepath);
|
||||
static bool saveBufferToFile(const char * path, void * buffer, uint32_t size);
|
||||
};
|
||||
|
||||
#endif // __FS_UTILS_H_
|
67
src/fs/disc_io.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
disc_io.h
|
||||
Interface template for low level disc functions.
|
||||
|
||||
Copyright (c) 2006 Michael "Chishm" Chisholm
|
||||
Based on code originally written by MightyMax
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef OGC_DISC_IO_INCLUDE
|
||||
#define OGC_DISC_IO_INCLUDE
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#define FEATURE_MEDIUM_CANREAD 0x00000001
|
||||
#define FEATURE_MEDIUM_CANWRITE 0x00000002
|
||||
#define FEATURE_GAMECUBE_SLOTA 0x00000010
|
||||
#define FEATURE_GAMECUBE_SLOTB 0x00000020
|
||||
#define FEATURE_GAMECUBE_DVD 0x00000040
|
||||
#define FEATURE_WII_SD 0x00000100
|
||||
#define FEATURE_WII_USB 0x00000200
|
||||
#define FEATURE_WII_DVD 0x00000400
|
||||
|
||||
typedef uint32_t sec_t;
|
||||
|
||||
typedef bool (* FN_MEDIUM_STARTUP)(void) ;
|
||||
typedef bool (* FN_MEDIUM_ISINSERTED)(void) ;
|
||||
typedef bool (* FN_MEDIUM_READSECTORS)(sec_t sector, sec_t numSectors, void* buffer) ;
|
||||
typedef bool (* FN_MEDIUM_WRITESECTORS)(sec_t sector, sec_t numSectors, const void* buffer) ;
|
||||
typedef bool (* FN_MEDIUM_CLEARSTATUS)(void) ;
|
||||
typedef bool (* FN_MEDIUM_SHUTDOWN)(void) ;
|
||||
|
||||
struct DISC_INTERFACE_STRUCT {
|
||||
unsigned long ioType ;
|
||||
unsigned long features ;
|
||||
FN_MEDIUM_STARTUP startup ;
|
||||
FN_MEDIUM_ISINSERTED isInserted ;
|
||||
FN_MEDIUM_READSECTORS readSectors ;
|
||||
FN_MEDIUM_WRITESECTORS writeSectors ;
|
||||
FN_MEDIUM_CLEARSTATUS clearStatus ;
|
||||
FN_MEDIUM_SHUTDOWN shutdown ;
|
||||
} ;
|
||||
|
||||
typedef struct DISC_INTERFACE_STRUCT DISC_INTERFACE ;
|
||||
|
||||
#endif // define OGC_DISC_IO_INCLUDE
|
1035
src/fs/sd_fat_devoptab.cpp
Normal file
40
src/fs/sd_fat_devoptab.h
Normal file
@ -0,0 +1,40 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __SD_FAT_DEVOPTAB_H_
|
||||
#define __SD_FAT_DEVOPTAB_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t mount_sd_fat(const char *path);
|
||||
int32_t unmount_sd_fat(const char *path);
|
||||
int32_t mount_fake();
|
||||
int32_t unmount_fake();
|
||||
void deleteDevTabsNames();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __SD_FAT_DEVOPTAB_H_
|
40
src/kernel/kernel.S
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
.global SCKernelCopyData
|
||||
SCKernelCopyData:
|
||||
// Disable data address translation
|
||||
mfmsr %r6
|
||||
li %r7, 0x10
|
||||
andc %r6, %r6, %r7
|
||||
mtmsr %r6
|
||||
|
||||
// Copy data
|
||||
addi %r3, %r3, -1
|
||||
addi %r4, %r4, -1
|
||||
mtctr %r5
|
||||
SCKernelCopyData_loop:
|
||||
lbzu %r5, 1(%r4)
|
||||
stbu %r5, 1(%r3)
|
||||
bdnz SCKernelCopyData_loop
|
||||
|
||||
// Enable data address translation
|
||||
ori %r6, %r6, 0x10
|
||||
mtmsr %r6
|
||||
blr
|
||||
|
||||
.global KernelCopyData
|
||||
KernelCopyData:
|
||||
li %r0, 0x2500
|
||||
sc
|
||||
blr
|
||||
|
||||
.globl SC0x36_KernelReadSRs
|
||||
SC0x36_KernelReadSRs:
|
||||
li r0, 0x3600
|
||||
sc
|
||||
blr
|
||||
|
||||
.globl SC0x0A_KernelWriteSRs
|
||||
SC0x0A_KernelWriteSRs:
|
||||
li r0, 0x0A00
|
||||
sc
|
||||
blr
|
@ -1,8 +1,7 @@
|
||||
#ifndef __WUPS_KERNEL_DEFS_H_
|
||||
#define __WUPS_KERNEL_DEFS_H_
|
||||
#ifndef __KERNEL_DEFS_H_
|
||||
#define __KERNEL_DEFS_H_
|
||||
|
||||
#include <dynamic_libs/fs_functions.h>
|
||||
#include <dynamic_libs/os_types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
204
src/kernel/kernel_utils.c
Normal file
@ -0,0 +1,204 @@
|
||||
#include "kernel_utils.h"
|
||||
#include "kernel_defs.h"
|
||||
#include "dynamic_libs/coreinit.h"
|
||||
|
||||
#define KERN_SYSCALL_TBL1 0xFFE84C70 //Unknown
|
||||
#define KERN_SYSCALL_TBL2 0xFFE85070 //Games
|
||||
#define KERN_SYSCALL_TBL3 0xFFE85470 //Loader
|
||||
#define KERN_SYSCALL_TBL4 0xFFEAAA60 //Home menu
|
||||
#define KERN_SYSCALL_TBL5 0xFFEAAE60 //Browser
|
||||
|
||||
extern void SCKernelCopyData(uint32_t dst, uint32_t src, uint32_t len);
|
||||
|
||||
static void KernelReadSRs(sr_table_t * table) {
|
||||
uint32_t i = 0;
|
||||
|
||||
// calculate PT_size ((end-start)*8/4096)*4 or (end-start)/128
|
||||
// Minimum page table size is 64Kbytes.
|
||||
|
||||
asm volatile("eieio; isync");
|
||||
|
||||
asm volatile("mfspr %0, 25" : "=r" (table->sdr1));
|
||||
|
||||
asm volatile("mfsr %0, 0" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 1" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 2" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 3" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 4" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 5" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 6" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 7" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 8" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 9" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 10" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 11" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 12" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 13" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 14" : "=r" (table->value[i]));
|
||||
i++;
|
||||
asm volatile("mfsr %0, 15" : "=r" (table->value[i]));
|
||||
i++;
|
||||
|
||||
asm volatile("eieio; isync");
|
||||
}
|
||||
|
||||
static void KernelWriteSRs(sr_table_t * table) {
|
||||
uint32_t i = 0;
|
||||
|
||||
asm volatile("eieio; isync");
|
||||
|
||||
// Writing didn't work for all at once so we only write number 8.
|
||||
// TODO: fix this and change it if required.
|
||||
|
||||
/*asm volatile("mtsr 0, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 1, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 2, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 3, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 4, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 5, %0" : : "r" (table->value[i])); i++;*/
|
||||
//asm volatile("mtsr 6, %0" : : "r" (table->value[6])); i++;
|
||||
/*asm volatile("mtsr 7, %0" : : "r" (table->value[i])); i++;*/
|
||||
asm volatile("mtsr 8, %0" : : "r" (table->value[8]));
|
||||
//i++;
|
||||
/*asm volatile("mtsr 9, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 10, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 11, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 12, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 13, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 14, %0" : : "r" (table->value[i])); i++;
|
||||
asm volatile("mtsr 15, %0" : : "r" (table->value[i])); i++;*/
|
||||
|
||||
|
||||
asm volatile("isync");
|
||||
}
|
||||
|
||||
void KernelWrite(uint32_t addr, const void *data, uint32_t length) {
|
||||
uint32_t dst = (uint32_t) OSEffectiveToPhysical(addr);
|
||||
uint32_t src = (uint32_t) OSEffectiveToPhysical((uint32_t)data);
|
||||
KernelCopyData(dst, src, length);
|
||||
DCFlushRange((void *)addr, length);
|
||||
ICInvalidateRange((void *)addr, length);
|
||||
}
|
||||
|
||||
void KernelWriteU32(uint32_t addr, uint32_t value) {
|
||||
uint32_t dst = (uint32_t) OSEffectiveToPhysical(addr);
|
||||
uint32_t src = (uint32_t) OSEffectiveToPhysical((uint32_t)&value);
|
||||
KernelCopyData(dst, src, 4);
|
||||
DCFlushRange((void *)addr, 4);
|
||||
ICInvalidateRange((void *)addr, 4);
|
||||
}
|
||||
|
||||
/* Write a 32-bit word with kernel permissions */
|
||||
void __attribute__ ((noinline)) kern_write(void * addr, uint32_t value) {
|
||||
asm volatile (
|
||||
"li 3,1\n"
|
||||
"li 4,0\n"
|
||||
"mr 5,%1\n"
|
||||
"li 6,0\n"
|
||||
"li 7,0\n"
|
||||
"lis 8,1\n"
|
||||
"mr 9,%0\n"
|
||||
"mr %1,1\n"
|
||||
"li 0,0x3500\n"
|
||||
"sc\n"
|
||||
"nop\n"
|
||||
"mr 1,%1\n"
|
||||
:
|
||||
: "r"(addr), "r"(value)
|
||||
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
|
||||
"11", "12"
|
||||
);
|
||||
}
|
||||
|
||||
/* Read a 32-bit word with kernel permissions */
|
||||
uint32_t __attribute__ ((noinline)) kern_read(const void *addr)
|
||||
{
|
||||
uint32_t result;
|
||||
asm volatile (
|
||||
"li 3,1\n"
|
||||
"li 4,0\n"
|
||||
"li 5,0\n"
|
||||
"li 6,0\n"
|
||||
"li 7,0\n"
|
||||
"lis 8,1\n"
|
||||
"mr 9,%1\n"
|
||||
"li 0,0x3400\n"
|
||||
"mr %0,1\n"
|
||||
"sc\n"
|
||||
"nop\n"
|
||||
"mr 1,%0\n"
|
||||
"mr %0,3\n"
|
||||
: "=r"(result)
|
||||
: "b"(addr)
|
||||
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
|
||||
"11", "12"
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void PatchSyscall(int index, uint32_t addr) {
|
||||
//DEBUG_FUNCTION_LINE("Patching Syscall 0x%02X\n",index);
|
||||
kern_write(KERN_SYSCALL_TBL1 + index * 4, addr);
|
||||
kern_write(KERN_SYSCALL_TBL2 + index * 4, addr);
|
||||
kern_write(KERN_SYSCALL_TBL3 + index * 4, addr);
|
||||
kern_write(KERN_SYSCALL_TBL4 + index * 4, addr);
|
||||
kern_write(KERN_SYSCALL_TBL5 + index * 4, addr);
|
||||
}
|
||||
|
||||
void KernelReadPTE(uint32_t outputAddr, int32_t length) {
|
||||
uint32_t dst = (uint32_t) OSEffectiveToPhysical(outputAddr);
|
||||
uint32_t src = 0xFFE20000;
|
||||
ICInvalidateRange(&dst, 4);
|
||||
DCFlushRange(&dst, 4);
|
||||
DCFlushRange(&src, 4);
|
||||
KernelCopyData(dst, src, length);
|
||||
DCFlushRange((void *)outputAddr, length);
|
||||
ICInvalidateRange((void *)outputAddr, length);
|
||||
}
|
||||
|
||||
void KernelWritePTE(uint32_t inputAddr, int32_t length) {
|
||||
uint32_t dst = 0xFFE20000;
|
||||
uint32_t src = (uint32_t) OSEffectiveToPhysical(inputAddr);
|
||||
ICInvalidateRange(&src, 4);
|
||||
DCFlushRange(&src, 4);
|
||||
KernelCopyData(dst, src, length);
|
||||
}
|
||||
|
||||
static void NOPAtPhysicalAddress(uint32_t addr) {
|
||||
uint32_t dst = 0x60000000;
|
||||
ICInvalidateRange(&dst, 4);
|
||||
DCFlushRange(&dst, 4);
|
||||
KernelCopyData(addr,(uint32_t)OSEffectiveToPhysical((uint32_t)&dst),4);
|
||||
}
|
||||
|
||||
void kernelInitialize() {
|
||||
static uint8_t ucSyscallsSetupRequired = 1;
|
||||
if(!ucSyscallsSetupRequired)
|
||||
return;
|
||||
|
||||
ucSyscallsSetupRequired = 0;
|
||||
|
||||
PatchSyscall(0x25, (uint32_t)SCKernelCopyData);
|
||||
PatchSyscall(0x36, (uint32_t)KernelReadSRs);
|
||||
PatchSyscall(0x0A, (uint32_t)KernelWriteSRs);
|
||||
|
||||
// Override all writes to SR8 with nops.
|
||||
NOPAtPhysicalAddress(0xFFF1D754);
|
||||
NOPAtPhysicalAddress(0xFFF1D64C);
|
||||
NOPAtPhysicalAddress(0xFFE00638);
|
||||
}
|
30
src/kernel/kernel_utils.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef __KERNEL_UTILS_H_
|
||||
#define __KERNEL_UTILS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "kernel_defs.h"
|
||||
|
||||
extern void KernelCopyData(uint32_t dst, uint32_t src, uint32_t len);
|
||||
|
||||
void kern_write(void * addr, uint32_t value);
|
||||
|
||||
uint32_t kern_read(const void *addr);
|
||||
|
||||
void SC0x0A_KernelWriteSRs(sr_table_t * table);
|
||||
void SC0x36_KernelReadSRs(sr_table_t * table);
|
||||
|
||||
void KernelReadPTE(uint32_t addr, int32_t length);
|
||||
void KernelWritePTE(uint32_t addr, int32_t length);
|
||||
|
||||
void KernelWrite(uint32_t addr, const void *data, uint32_t length);
|
||||
void KernelWriteU32(uint32_t addr, uint32_t value);
|
||||
void kernelInitialize();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __KERNEL_UTILS_H_
|
29
src/kernel_hooks.S
Normal file
@ -0,0 +1,29 @@
|
||||
# This stuff may need a change in different kernel versions
|
||||
# This is only needed when launched directly through browser and not SD card.
|
||||
|
||||
.section ".kernel_code"
|
||||
.globl SaveAndResetDataBATs_And_SRs_hook
|
||||
SaveAndResetDataBATs_And_SRs_hook:
|
||||
# setup CTR to the position we need to return to
|
||||
mflr r5
|
||||
mtctr r5
|
||||
# set link register to its original value
|
||||
mtlr r7
|
||||
# setup us a nice DBAT for our code data with same region as our code
|
||||
mfspr r5, 560
|
||||
mtspr 570, r5
|
||||
mfspr r5, 561
|
||||
mtspr 571, r5
|
||||
# restore the original kernel instructions that we replaced
|
||||
lwz r5, 0x34(r3)
|
||||
lwz r6, 0x38(r3)
|
||||
lwz r7, 0x3C(r3)
|
||||
lwz r8, 0x40(r3)
|
||||
lwz r9, 0x44(r3)
|
||||
lwz r10, 0x48(r3)
|
||||
lwz r11, 0x4C(r3)
|
||||
lwz r3, 0x50(r3)
|
||||
isync
|
||||
mtsr 7, r5
|
||||
# jump back to the position in kernel after our patch (from LR)
|
||||
bctr
|
@ -212,7 +212,7 @@ struct name { \
|
||||
#define ELFTC_VCSID(ID) /**/
|
||||
#endif
|
||||
|
||||
#if defined(__wiiu__)
|
||||
#if defined(__WIIU__)
|
||||
#define ELFTC_VCSID(ID) /**/
|
||||
#endif
|
||||
|
||||
@ -315,7 +315,7 @@ extern const char *__progname;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__wiiu__)
|
||||
#if defined(__WIIU__)
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
|
@ -34,13 +34,13 @@
|
||||
|
||||
#endif /* GEKKO */
|
||||
|
||||
#ifdef __wiiu__
|
||||
#ifdef __WIIU__
|
||||
|
||||
#define LIBELF_ARCH EM_PPC
|
||||
#define LIBELF_BYTEORDER ELFDATA2MSB
|
||||
#define LIBELF_CLASS ELFCLASS32
|
||||
|
||||
#endif /* __wiiu__ */
|
||||
#endif /* __WIIU__ */
|
||||
|
||||
#ifdef __DragonFly__
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
|
||||
#include "_libelf.h"
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <limits.h>
|
||||
|
||||
#include "_libelf.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
|
||||
#include "_libelf.h"
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <limits.h>
|
||||
|
||||
#include "_libelf.h"
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
|
||||
#include "_libelf.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
|
||||
#include "_libelf.h"
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <limits.h>
|
||||
|
||||
#include "_libelf.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <limits.h>
|
||||
|
||||
#include "_libelf.h"
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <limits.h>
|
||||
|
||||
#include "_libelf.h"
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <limits.h>
|
||||
|
||||
#include "_libelf.h"
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
|
||||
#include "_libelf.h"
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
|
||||
#include "_libelf.h"
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <elfdefinitions.h>
|
||||
#include "elfdefinitions.h"
|
||||
|
||||
/* Library private data structures */
|
||||
typedef struct _Elf Elf;
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
|
||||
#include "_libelf.h"
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <gelf.h>
|
||||
#include "gelf.h"
|
||||
#include <libelf.h>
|
||||
|
||||
#include "_libelf.h"
|
||||
|
37
src/link.ld
@ -1,40 +1,33 @@
|
||||
OUTPUT(wiiupluginloader.elf);
|
||||
OUTPUT(loader.elf);
|
||||
|
||||
/* Tell linker where our application entry is so the garbage collect can work correct */
|
||||
ENTRY(__entry_menu);
|
||||
ENTRY(_start);
|
||||
|
||||
SECTIONS {
|
||||
. = 0x00802000;
|
||||
. = 0x00800000;
|
||||
.text : {
|
||||
*(.kernel_code*);
|
||||
*(.text*);
|
||||
/* Tell linker to not garbage collect this section as it is not referenced anywhere */
|
||||
KEEP(*(.kernel_code*));
|
||||
}
|
||||
.rodata : {
|
||||
*(.rodata*);
|
||||
.sdata : {
|
||||
*(.sdata*)
|
||||
}
|
||||
.data : {
|
||||
*(.data*);
|
||||
|
||||
__sdata_start = .;
|
||||
*(.sdata*);
|
||||
__sdata_end = .;
|
||||
|
||||
__sdata2_start = .;
|
||||
*(.sdata2*);
|
||||
__sdata2_end = .;
|
||||
*(.data*)
|
||||
}
|
||||
.rodata : {
|
||||
*(.rodata*)
|
||||
}
|
||||
.sbss : {
|
||||
*(.sbss*)
|
||||
}
|
||||
.bss : {
|
||||
__bss_start = .;
|
||||
*(.bss*);
|
||||
*(.sbss*);
|
||||
*(COMMON);
|
||||
__bss_end = .;
|
||||
*(.bss*)
|
||||
}
|
||||
__CODE_END = .;
|
||||
|
||||
/DISCARD/ : {
|
||||
*(*);
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT((SIZEOF(.text) + SIZEOF(.data)) < 0x800000, "Memory overlapping with main elf.");
|
||||
|
328
src/main.cpp
@ -1,328 +0,0 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/gx2_functions.h>
|
||||
#include <dynamic_libs/ax_functions.h>
|
||||
#include <dynamic_libs/socket_functions.h>
|
||||
#include <dynamic_libs/sys_functions.h>
|
||||
#include <dynamic_libs/fs_functions.h>
|
||||
#include <dynamic_libs/nn_nim_functions.h>
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <dynamic_libs/padscore_functions.h>
|
||||
#include <dynamic_libs/proc_ui_functions.h>
|
||||
|
||||
#include <fs/FSUtils.h>
|
||||
#include <fs/sd_fat_devoptab.h>
|
||||
#include <utils/logger.h>
|
||||
#include <utils/utils.h>
|
||||
#include <utils/function_patcher.h>
|
||||
#include <system/exception_handler.h>
|
||||
#include <system/memory.h>
|
||||
|
||||
#include <kernel/kernel_utils.h>
|
||||
#include <mykernel/kernel_utils.h>
|
||||
|
||||
#include "mymemory/memory_mapping.h"
|
||||
|
||||
#include "common/retain_vars.h"
|
||||
#include "common/common.h"
|
||||
#include "plugin/PluginLoader.h"
|
||||
#include "plugin/PluginInformation.h"
|
||||
#include "plugin/DynamicLinkingHelper.h"
|
||||
|
||||
#include <wups.h>
|
||||
#include <iosuhax.h>
|
||||
#include <fat.h>
|
||||
#include <ntfs.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "utils.h"
|
||||
#include "Application.h"
|
||||
#include "patcher/function_patcher.h"
|
||||
#include "patcher/hooks_patcher.h"
|
||||
#include "patcher/hooks_patcher_static.h"
|
||||
#include "plugin/dynamic_linking_defines.h"
|
||||
#include "myutils/mem_utils.h"
|
||||
#include "myutils/mocha.h"
|
||||
#include "myutils/libntfs.h"
|
||||
#include "myutils/libfat.h"
|
||||
#include "myutils/overlay_helper.h"
|
||||
#include "myutils/ConfigUtils.h"
|
||||
#include "version.h"
|
||||
#include "settings/CSettings.h"
|
||||
|
||||
static void ApplyPatchesAndCallHookStartingApp();
|
||||
static void RestorePatches();
|
||||
int32_t isInMiiMakerHBL();
|
||||
void readAndPrintSegmentRegister(CThread *thread, void *arg);
|
||||
|
||||
extern "C" int32_t Menu_Main(int32_t argc, char **argv) {
|
||||
if(gAppStatus == 2) {
|
||||
//"No, we don't want to patch stuff again.");
|
||||
return EXIT_RELAUNCH_ON_LOAD;
|
||||
}
|
||||
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers(); //For logging
|
||||
InitSysFunctionPointers();
|
||||
InitFSFunctionPointers();
|
||||
InitGX2FunctionPointers();
|
||||
InitSysFunctionPointers();
|
||||
InitVPadFunctionPointers();
|
||||
InitPadScoreFunctionPointers();
|
||||
InitAXFunctionPointers();
|
||||
InitProcUIFunctionPointers();
|
||||
|
||||
log_init();
|
||||
|
||||
DEBUG_FUNCTION_LINE("We have %d kb for plugins.\n",(PLUGIN_LOCATION_END_ADDRESS-getApplicationEndAddr())/1024);
|
||||
//setup_os_exceptions();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Wii U Plugin System Loader %s\n",APP_VERSION);
|
||||
DEBUG_FUNCTION_LINE("Sizeof dyn_linking_relocation_data_t %d\n",sizeof(dyn_linking_relocation_data_t));
|
||||
Init();
|
||||
|
||||
init_kernel_syscalls();
|
||||
wups_init_kernel_syscalls();
|
||||
|
||||
if(!MemoryMapping::isMemoryMapped()) {
|
||||
MemoryMapping::setupMemoryMapping();
|
||||
}
|
||||
|
||||
gGameTitleID = OSGetTitleID();
|
||||
|
||||
g_vid_ownContextState = NULL;
|
||||
g_vid_originalContextSave = NULL;
|
||||
|
||||
int32_t result = 0;
|
||||
|
||||
//Reset everything when were going back to the Mii Maker
|
||||
if(isInMiiMakerHBL()) {
|
||||
CallHook(WUPS_LOADER_HOOK_DEINIT_PLUGIN);
|
||||
// Restore patches as the patched functions could change.
|
||||
RestorePatches();
|
||||
|
||||
DynamicLinkingHelper::getInstance()->clearAll();
|
||||
|
||||
//PluginLoader * pluginLoader = PluginLoader::getInstance();
|
||||
//std::vector<PluginInformation *> pluginList = pluginLoader->getPluginInformation("sd:/wiiu/plugins/");
|
||||
//pluginLoader->loadAndLinkPlugins(pluginList);
|
||||
//pluginLoader->clearPluginInformation(pluginList);
|
||||
|
||||
//!*******************************************************************
|
||||
//! Initialize heap memory *
|
||||
//!*******************************************************************
|
||||
DEBUG_FUNCTION_LINE("Initialize memory management\n");
|
||||
memoryInitialize();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Start main application\n");
|
||||
result = Application::instance()->exec();
|
||||
DEBUG_FUNCTION_LINE("Main application stopped result: %d\n",result);
|
||||
|
||||
DEBUG_FUNCTION_LINE("Application::destroyInstance\n");
|
||||
Application::destroyInstance();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Release memory\n");
|
||||
memoryRelease();
|
||||
CSettings::destroyInstance();
|
||||
PluginLoader::destroyInstance();
|
||||
|
||||
MemoryUtils::init();
|
||||
|
||||
// Memory on custon heap is reset anyway so we don't need to free the image buffers.
|
||||
memset((void*)&g_vid_main_cbuf,0,sizeof(g_vid_main_cbuf));
|
||||
memset((void*)&g_vid_drcTex,0,sizeof(g_vid_drcTex));
|
||||
memset((void*)&g_vid_tvTex,0,sizeof(g_vid_tvTex));
|
||||
g_vid_originalContextSave = NULL;
|
||||
g_vid_ownContextState = NULL;
|
||||
g_NotInLoader = false;
|
||||
} else {
|
||||
g_NotInLoader = true;
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Patch own stuff\n");
|
||||
PatchInvidualMethodHooks(method_hooks_hooks_static, method_hooks_size_hooks_static, method_calls_hooks_static);
|
||||
|
||||
DEBUG_FUNCTION_LINE("Do relocations\n");
|
||||
|
||||
std::vector<dyn_linking_relocation_entry_t *> relocations = DynamicLinkingHelper::getInstance()->getAllValidDynamicLinkingRelocations();
|
||||
DEBUG_FUNCTION_LINE("Found relocation information for %d functions\n",relocations.size());
|
||||
|
||||
if(!DynamicLinkingHelper::getInstance()->fillRelocations(relocations)) {
|
||||
OSFatal("fillRelocations failed.");
|
||||
}
|
||||
|
||||
if(!isInMiiMakerHBL()) {
|
||||
DEBUG_FUNCTION_LINE("Apply patches.\n");
|
||||
ApplyPatchesAndCallHookStartingApp();
|
||||
|
||||
if(MemoryMapping::isMemoryMapped()) {
|
||||
DEBUG_FUNCTION_LINE("Mapping was already done. Running %016llX\n",gGameTitleID);
|
||||
readAndPrintSegmentRegister(NULL,NULL);
|
||||
//MemoryMapping::readTestValuesFromMemory();
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n");
|
||||
DEBUG_FUNCTION_LINE("<---------------- COPY PASTE ME START-----------------> \n");
|
||||
DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n");
|
||||
DEBUG_FUNCTION_LINE("Mapping was't done. Running %016llX\n",gGameTitleID);
|
||||
readAndPrintSegmentRegister(NULL,NULL);
|
||||
DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n");
|
||||
DEBUG_FUNCTION_LINE("<----------------- COPY PASTE ME END -----------------> \n");
|
||||
DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n");
|
||||
}
|
||||
return EXIT_RELAUNCH_ON_LOAD;
|
||||
}
|
||||
|
||||
if(result == APPLICATION_CLOSE_APPLY || result == APPLICATION_CLOSE_APPLY_MEMORY) {
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_VID_MEM);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_KERNEL);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_FS);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_OVERLAY);
|
||||
ConfigUtils::loadConfigFromSD();
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_PLUGIN);
|
||||
DEBUG_FUNCTION_LINE("Loading the system menu.\n");
|
||||
DeInit();
|
||||
SYSLaunchMenu();
|
||||
return EXIT_RELAUNCH_ON_LOAD;
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Let's go to back to the Homebrew Launcher\n");
|
||||
DEBUG_FUNCTION_LINE("Restoring the patched functions\n");
|
||||
RestorePatches();
|
||||
DEBUG_FUNCTION_LINE("Calling the plugin deinit hook\n");
|
||||
//CallHook(WUPS_LOADER_HOOK_DEINIT_PLUGIN);
|
||||
DEBUG_FUNCTION_LINE("Unmounting SD/USB devices\n");
|
||||
DeInit();
|
||||
DEBUG_FUNCTION_LINE("Bye bye!\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void ApplyPatchesAndCallHookStartingApp() {
|
||||
PatchInvidualMethodHooks(method_hooks_hooks_static, method_hooks_size_hooks_static, method_calls_hooks_static);
|
||||
PatchInvidualMethodHooks(method_hooks_hooks, method_hooks_size_hooks, method_calls_hooks);
|
||||
for(int32_t plugin_index=0; plugin_index<gbl_replacement_data.number_used_plugins; plugin_index++) {
|
||||
CallHookEx(WUPS_LOADER_HOOK_STARTING_APPLICATION,plugin_index);
|
||||
new_PatchInvidualMethodHooks(&gbl_replacement_data.plugin_data[plugin_index]);
|
||||
CallHookEx(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED,plugin_index);
|
||||
}
|
||||
}
|
||||
|
||||
void DeInit() {
|
||||
DeInit_SD_USB();
|
||||
}
|
||||
|
||||
void RestorePatches() {
|
||||
for(int32_t plugin_index=gbl_replacement_data.number_used_plugins-1; plugin_index>=0; plugin_index--) {
|
||||
DEBUG_FUNCTION_LINE("Restoring function for plugin: %d\n",plugin_index);
|
||||
new_RestoreInvidualInstructions(&gbl_replacement_data.plugin_data[plugin_index]);
|
||||
}
|
||||
RestoreInvidualInstructions(method_hooks_hooks, method_hooks_size_hooks);
|
||||
RestoreInvidualInstructions(method_hooks_hooks_static, method_hooks_size_hooks_static);
|
||||
}
|
||||
|
||||
int32_t isInMiiMakerHBL() {
|
||||
if (OSGetTitleID != 0 && (
|
||||
OSGetTitleID() == 0x000500101004A200 || // mii maker eur
|
||||
OSGetTitleID() == 0x000500101004A100 || // mii maker usa
|
||||
OSGetTitleID() == 0x000500101004A000 ||// mii maker jpn
|
||||
OSGetTitleID() == 0x0005000013374842)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Init() {
|
||||
memset(&tv_store,0,sizeof(tv_store));
|
||||
memset(&drc_store,0,sizeof(drc_store));
|
||||
DEBUG_FUNCTION_LINE("Mount SD partition\n");
|
||||
Init_SD_USB();
|
||||
}
|
||||
|
||||
void Init_SD_USB() {
|
||||
int32_t res = IOSUHAX_Open(NULL);
|
||||
if(res < 0) {
|
||||
ExecuteIOSExploitWithDefaultConfig();
|
||||
}
|
||||
deleteDevTabsNames();
|
||||
mount_fake();
|
||||
gSDInitDone |= WUPS_SDUSB_MOUNTED_FAKE;
|
||||
|
||||
if(res < 0) {
|
||||
DEBUG_FUNCTION_LINE("IOSUHAX_open failed\n");
|
||||
if((res = mount_sd_fat("sd")) >= 0) {
|
||||
DEBUG_FUNCTION_LINE("mount_sd_fat success\n");
|
||||
gSDInitDone |= WUPS_SDUSB_MOUNTED_OS_SD;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("mount_sd_fat failed %d\n",res);
|
||||
}
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Using IOSUHAX for SD/USB access\n");
|
||||
gSDInitDone |= WUPS_SDUSB_LIBIOSU_LOADED;
|
||||
int32_t ntfs_mounts = mountAllNTFS();
|
||||
if(ntfs_mounts > 0) {
|
||||
gSDInitDone |= WUPS_USB_MOUNTED_LIBNTFS;
|
||||
}
|
||||
|
||||
if(mount_libfatAll() == 0) {
|
||||
gSDInitDone |= WUPS_SD_MOUNTED_LIBFAT;
|
||||
gSDInitDone |= WUPS_USB_MOUNTED_LIBFAT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DeInit_SD_USB() {
|
||||
DEBUG_FUNCTION_LINE("Called this function.\n");
|
||||
|
||||
if(gSDInitDone & WUPS_SDUSB_MOUNTED_FAKE) {
|
||||
DEBUG_FUNCTION_LINE("Unmounting fake\n");
|
||||
unmount_fake();
|
||||
gSDInitDone &= ~WUPS_SDUSB_MOUNTED_FAKE;
|
||||
}
|
||||
if(gSDInitDone & WUPS_SDUSB_MOUNTED_OS_SD) {
|
||||
DEBUG_FUNCTION_LINE("Unmounting OS SD\n");
|
||||
unmount_sd_fat("sd");
|
||||
gSDInitDone &= ~WUPS_SDUSB_MOUNTED_OS_SD;
|
||||
}
|
||||
|
||||
if(gSDInitDone & WUPS_SD_MOUNTED_LIBFAT) {
|
||||
DEBUG_FUNCTION_LINE("Unmounting LIBFAT SD\n");
|
||||
unmount_libfat("sd");
|
||||
gSDInitDone &= ~WUPS_SD_MOUNTED_LIBFAT;
|
||||
}
|
||||
|
||||
if(gSDInitDone & WUPS_USB_MOUNTED_LIBFAT) {
|
||||
DEBUG_FUNCTION_LINE("Unmounting LIBFAT USB\n");
|
||||
unmount_libfat("usb");
|
||||
gSDInitDone &= ~WUPS_USB_MOUNTED_LIBFAT;
|
||||
}
|
||||
|
||||
if(gSDInitDone & WUPS_USB_MOUNTED_LIBNTFS) {
|
||||
DEBUG_FUNCTION_LINE("Unmounting LIBNTFS USB\n");
|
||||
unmountAllNTFS();
|
||||
gSDInitDone &= ~WUPS_USB_MOUNTED_LIBNTFS;
|
||||
}
|
||||
|
||||
if(gSDInitDone & WUPS_SDUSB_LIBIOSU_LOADED) {
|
||||
DEBUG_FUNCTION_LINE("Calling IOSUHAX_Close\n");
|
||||
IOSUHAX_Close();
|
||||
gSDInitDone &= ~WUPS_SDUSB_LIBIOSU_LOADED;
|
||||
|
||||
}
|
||||
deleteDevTabsNames();
|
||||
if(gSDInitDone != WUPS_SDUSB_MOUNTED_NONE) {
|
||||
DEBUG_FUNCTION_LINE("WARNING. Some devices are still mounted.\n");
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Function end.\n");
|
||||
}
|
137
src/memory/memory.cpp
Normal file
@ -0,0 +1,137 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
*
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include "dynamic_libs/coreinit.h"
|
||||
#include "memory_mapping.h"
|
||||
#include "memory.h"
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Memory functions
|
||||
//! This is the only place where those are needed so lets keep them more or less private
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
extern uint32_t * pMEMAllocFromDefaultHeapEx;
|
||||
extern uint32_t * pMEMAllocFromDefaultHeap;
|
||||
extern uint32_t * pMEMFreeToDefaultHeap;
|
||||
|
||||
int32_t memHandle __attribute__((section(".data"))) = -1;
|
||||
|
||||
void initMemory() {
|
||||
memHandle = MEMCreateExpHeapEx((void*)MemoryMapping::getHeapAddress(), MemoryMapping::getHeapSize(), 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
//! wraps
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
extern "C" void *__wrap_malloc(size_t size) {
|
||||
if(memHandle == -1) {
|
||||
return ((void * (*)(size_t))(*pMEMAllocFromDefaultHeap))(size);
|
||||
}
|
||||
// pointer to a function resolve
|
||||
return MEMAllocFromExpHeapEx(memHandle, size, 0x40);
|
||||
}
|
||||
|
||||
extern "C" void *__wrap_memalign(size_t align, size_t size) {
|
||||
if(memHandle == -1) {
|
||||
return ((void * (*)(size_t, size_t))(*pMEMAllocFromDefaultHeapEx))(size, align);
|
||||
}
|
||||
if (align < 4)
|
||||
align = 4;
|
||||
|
||||
// pointer to a function resolve
|
||||
return MEMAllocFromExpHeapEx(memHandle, size, align);
|
||||
}
|
||||
|
||||
extern "C" void __wrap_free(void *p) {
|
||||
if(memHandle == -1) {
|
||||
//OSFatal("__wrap_free");
|
||||
if(p != 0) {
|
||||
((void (*)(void *))(*pMEMFreeToDefaultHeap))(p);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// pointer to a function resolve
|
||||
if(p != 0) {
|
||||
MEMFreeToExpHeap(memHandle,p);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void *__wrap_calloc(size_t n, size_t size) {
|
||||
void *p = __wrap_malloc(n * size);
|
||||
if (p != 0) {
|
||||
memset(p, 0, n * size);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
extern "C" size_t __wrap_malloc_usable_size(void *p) {
|
||||
//! TODO: this is totally wrong and needs to be addressed
|
||||
return 0x7FFFFFFF;
|
||||
}
|
||||
|
||||
extern "C" void *__wrap_realloc(void *ptr, size_t size) {
|
||||
void *newPtr;
|
||||
|
||||
if (!ptr) {
|
||||
newPtr = __wrap_malloc(size);
|
||||
if (!newPtr) {
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
newPtr = __wrap_malloc(size);
|
||||
if (!newPtr) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
memcpy(newPtr, ptr, size);
|
||||
|
||||
__wrap_free(ptr);
|
||||
}
|
||||
|
||||
return newPtr;
|
||||
error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
//! reent versions
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
extern "C" void *__wrap__malloc_r(struct _reent *r, size_t size) {
|
||||
return __wrap_malloc(size);
|
||||
}
|
||||
|
||||
extern "C" void *__wrap__calloc_r(struct _reent *r, size_t n, size_t size) {
|
||||
return __wrap_calloc(n, size);
|
||||
}
|
||||
|
||||
extern "C" void *__wrap__memalign_r(struct _reent *r, size_t align, size_t size) {
|
||||
return __wrap_memalign(align, size);
|
||||
}
|
||||
|
||||
extern "C" void __wrap__free_r(struct _reent *r, void *p) {
|
||||
__wrap_free(p);
|
||||
}
|
||||
|
||||
extern "C" size_t __wrap__malloc_usable_size_r(struct _reent *r, void *p) {
|
||||
return __wrap_malloc_usable_size(p);
|
||||
}
|
||||
|
||||
extern "C" void *__wrap__realloc_r(struct _reent *r, void *p, size_t size) {
|
||||
return __wrap_realloc(p, size);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2016-2018 Maschell
|
||||
* Copyright (C) 2015 Dimok
|
||||
*
|
||||
* 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
|
||||
@ -14,10 +14,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#ifndef _MENU_COMMON_H_
|
||||
#define _MENU_COMMON_H_
|
||||
|
||||
#define SCREEN_WIDTH 1280
|
||||
#define SCREEN_HEIGHT 720
|
||||
#ifndef __MEMORY_H_
|
||||
#define __MEMORY_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
void initMemory();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __MEMORY_H_
|
@ -1,16 +1,15 @@
|
||||
#include "memory_mapping.h"
|
||||
#include "mykernel/syscalls.h"
|
||||
#include "common/retain_vars.h"
|
||||
#include <kernel/syscalls.h>
|
||||
#include <utils/logger.h>
|
||||
#include <utils/utils.h>
|
||||
#include <system/CThread.h>
|
||||
#include <fs/FSUtils.h>
|
||||
#include "kernel/kernel_utils.h"
|
||||
|
||||
#include <vector>
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include "dynamic_libs/coreinit.h"
|
||||
#include "system/CThread.h"
|
||||
#include "memory.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DEBUG_FUNCTION_LINE(x,...)
|
||||
|
||||
void runOnAllCores(CThread::Callback callback, void *callbackArg, int32_t iAttr = 0, int32_t iPriority = 16, int32_t iStackSize = 0x8000) {
|
||||
int32_t aff[] = {CThread::eAttributeAffCore2,CThread::eAttributeAffCore1,CThread::eAttributeAffCore0};
|
||||
|
||||
@ -47,9 +46,8 @@ void readAndPrintSegmentRegister(CThread *thread, void *arg) {
|
||||
|
||||
memset(pageTable,0,sizeof(pageTable));
|
||||
DEBUG_FUNCTION_LINE("Reading pageTable now.\n");
|
||||
SC0x37_KernelReadPTE(pageTable,sizeof(pageTable));
|
||||
KernelReadPTE((uint32_t) pageTable,sizeof(pageTable));
|
||||
DCFlushRange(pageTable,sizeof(pageTable));
|
||||
|
||||
DEBUG_FUNCTION_LINE("Reading pageTable done\n");
|
||||
|
||||
MemoryMapping::printPageTableTranslation(srTable,pageTable);
|
||||
@ -84,6 +82,14 @@ uint32_t MemoryMapping::getVideoMemorySize() {
|
||||
return getAreaSizeFromPageTable(MEMORY_START_VIDEO_SPACE,MEMORY_START_VIDEO_SPACE_END - MEMORY_START_VIDEO_SPACE);
|
||||
}
|
||||
|
||||
uint32_t MemoryMapping::getPluginSpaceMemoryAddress() {
|
||||
return MEMORY_START_PLUGIN_SPACE;
|
||||
}
|
||||
|
||||
uint32_t MemoryMapping::getPluginSpaceMemorySize() {
|
||||
return getAreaSizeFromPageTable(MEMORY_START_PLUGIN_SPACE,MEMORY_START_PLUGIN_SPACE_END - MEMORY_START_PLUGIN_SPACE);
|
||||
}
|
||||
|
||||
void MemoryMapping::searchEmptyMemoryRegions() {
|
||||
DEBUG_FUNCTION_LINE("Searching for empty memory.\n");
|
||||
|
||||
@ -186,7 +192,7 @@ void MemoryMapping::writeTestValuesToMemory() {
|
||||
DCFlushRange(&testBuffer,sizeof(testBuffer));
|
||||
DCInvalidateRange(&testBuffer,sizeof(testBuffer));
|
||||
uint32_t destination = pa_start_address + ((k*4) - sizeof(testBuffer));
|
||||
SC0x25_KernelCopyData(destination,(uint32_t)OSEffectiveToPhysical(testBuffer),sizeof(testBuffer));
|
||||
KernelCopyData(destination,(uint32_t)OSEffectiveToPhysical((uint32_t)testBuffer),sizeof(testBuffer));
|
||||
//DEBUG_FUNCTION_LINE("Copy testBuffer into %08X\n",destination);
|
||||
}
|
||||
if(k != pa_size/4) {
|
||||
@ -297,26 +303,26 @@ void MemoryMapping::memoryMappingForRegions(const memory_mapping_t * memory_mapp
|
||||
uint32_t pa_size = pa_end_address - pa_start_address;
|
||||
DEBUG_FUNCTION_LINE("Adding page table entry %d for mapping area %d. %08X-%08X => %08X-%08X...\n",j+1,i+1,cur_ea_start_address,memory_mapping[i].effective_start_address+pa_size,pa_start_address,pa_end_address);
|
||||
if(!mapMemory(pa_start_address,pa_end_address,cur_ea_start_address,SRTable,translation_table)) {
|
||||
log_print("error =(\n");
|
||||
//log_print("error =(\n");
|
||||
DEBUG_FUNCTION_LINE("Failed to map memory.\n");
|
||||
//OSFatal("Failed to map memory.");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
cur_ea_start_address += pa_size;
|
||||
log_print("done\n");
|
||||
//log_print("done\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryMapping::setupMemoryMapping() {
|
||||
//runOnAllCores(readAndPrintSegmentRegister,NULL,0,16,0x20000);
|
||||
//runOnAllCores(readAndPrintSegmentRegister,NULL,0,16,0x80000);
|
||||
|
||||
sr_table_t srTableCpy;
|
||||
uint32_t pageTableCpy[0x8000];
|
||||
|
||||
SC0x36_KernelReadSRs(&srTableCpy);
|
||||
SC0x37_KernelReadPTE(pageTableCpy,sizeof(pageTableCpy));
|
||||
KernelReadPTE((uint32_t) pageTableCpy,sizeof(pageTableCpy));
|
||||
|
||||
DCFlushRange(&srTableCpy,sizeof(srTableCpy));
|
||||
DCFlushRange(pageTableCpy,sizeof(pageTableCpy));
|
||||
@ -325,7 +331,7 @@ void MemoryMapping::setupMemoryMapping() {
|
||||
DEBUG_FUNCTION_LINE("SR[%d]=%08X\n",i,srTableCpy.value[i]);
|
||||
}
|
||||
|
||||
printPageTableTranslation(srTableCpy,pageTableCpy);
|
||||
//printPageTableTranslation(srTableCpy,pageTableCpy);
|
||||
|
||||
// According to
|
||||
// http://wiiubrew.org/wiki/Cafe_OS#Virtual_Memory_Map 0x80000000
|
||||
@ -341,26 +347,34 @@ void MemoryMapping::setupMemoryMapping() {
|
||||
|
||||
DEBUG_FUNCTION_LINE("Writing segment registers...\n",segment_index,segment_content);
|
||||
// Writing the segment registers to ALL cores.
|
||||
//
|
||||
//writeSegmentRegister(NULL, &srTableCpy);
|
||||
|
||||
runOnAllCores(writeSegmentRegister,&srTableCpy);
|
||||
|
||||
memoryMappingForRegions(mem_mapping,srTableCpy,pageTableCpy);
|
||||
|
||||
|
||||
|
||||
//printPageTableTranslation(srTableCpy,pageTableCpy);
|
||||
|
||||
DEBUG_FUNCTION_LINE("Writing PageTable... ");
|
||||
DCFlushRange(pageTableCpy,sizeof(pageTableCpy));
|
||||
SC0x09_KernelWritePTE(pageTableCpy,sizeof(pageTableCpy));
|
||||
KernelWritePTE((uint32_t) pageTableCpy,sizeof(pageTableCpy));
|
||||
DCFlushRange(pageTableCpy,sizeof(pageTableCpy));
|
||||
log_print("done\n");
|
||||
DEBUG_FUNCTION_LINE("done\n");
|
||||
|
||||
//printPageTableTranslation(srTableCpy,pageTableCpy);
|
||||
|
||||
runOnAllCores(readAndPrintSegmentRegister,NULL,0,16,0x80000);
|
||||
//runOnAllCores(readAndPrintSegmentRegister,NULL,0,16,0x80000);
|
||||
|
||||
//searchEmptyMemoryRegions();
|
||||
|
||||
//writeTestValuesToMemory();
|
||||
//readTestValuesFromMemory();
|
||||
|
||||
|
||||
//runOnAllCores(writeSegmentRegister,&srTableCpy);
|
||||
}
|
||||
|
||||
|
||||
@ -369,7 +383,7 @@ uint32_t MemoryMapping::getAreaSizeFromPageTable(uint32_t start, uint32_t maxSiz
|
||||
uint32_t pageTable[0x8000];
|
||||
|
||||
SC0x36_KernelReadSRs(&srTable);
|
||||
SC0x37_KernelReadPTE(pageTable,sizeof(pageTable));
|
||||
KernelReadPTE((uint32_t) pageTable,sizeof(pageTable));
|
||||
|
||||
uint32_t sr_start = start >> 28;
|
||||
uint32_t sr_end = (start + maxSize) >> 28;
|
||||
@ -684,6 +698,10 @@ bool MemoryMapping::mapMemory(uint32_t pa_start_address,uint32_t pa_end_address,
|
||||
}
|
||||
|
||||
uint32_t MemoryMapping::PhysicalToEffective(uint32_t phyiscalAddress) {
|
||||
if(phyiscalAddress >= 0x30800000 || phyiscalAddress < 0x31000000) {
|
||||
return phyiscalAddress - (0x30800000 - 0x00800000);
|
||||
}
|
||||
|
||||
uint32_t result = 0;
|
||||
const memory_values_t * curMemValues = NULL;
|
||||
int32_t curOffset = 0;
|
||||
@ -713,10 +731,14 @@ uint32_t MemoryMapping::PhysicalToEffective(uint32_t phyiscalAddress) {
|
||||
}
|
||||
|
||||
uint32_t MemoryMapping::EffectiveToPhysical(uint32_t effectiveAddress) {
|
||||
if(effectiveAddress >= 0x00800000 || effectiveAddress < 0x01000000) {
|
||||
return effectiveAddress + (0x30800000 - 0x00800000);
|
||||
}
|
||||
|
||||
uint32_t result = 0;
|
||||
// CAUTION: The data may be fragmented between multiple areas in PA.
|
||||
const memory_values_t * curMemValues = NULL;
|
||||
int32_t curOffset = 0;
|
||||
uint32_t curOffset = 0;
|
||||
|
||||
for(int32_t i = 0; true; i++) {
|
||||
if(mem_mapping[i].physical_addresses == NULL) {
|
||||
@ -737,7 +759,7 @@ uint32_t MemoryMapping::EffectiveToPhysical(uint32_t effectiveAddress) {
|
||||
if(curMemValues[i].end_address == 0) {
|
||||
break;
|
||||
}
|
||||
int32_t curChunkSize = curMemValues[i].end_address - curMemValues[i].start_address;
|
||||
uint32_t curChunkSize = curMemValues[i].end_address - curMemValues[i].start_address;
|
||||
if(effectiveAddress < (curOffset + curChunkSize)) {
|
||||
result = (effectiveAddress - curOffset) + curMemValues[i].start_address;
|
||||
break;
|
@ -1,12 +1,14 @@
|
||||
#ifndef __WUPS_MEMORY_MAPPING_H_
|
||||
#define __WUPS_MEMORY_MAPPING_H_
|
||||
#ifndef __MEMORY_MAPPING_H_
|
||||
#define __MEMORY_MAPPING_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <dynamic_libs/os_types.h>
|
||||
#include "mykernel/kernel_defs.h"
|
||||
#include <stdint.h>
|
||||
#include "kernel/kernel_defs.h"
|
||||
|
||||
typedef struct pageInformation_ {
|
||||
uint32_t addr;
|
||||
@ -102,7 +104,7 @@ const memory_values_t mem_vals_heap[] = {
|
||||
{0x28000000 + 0x09000000, 0x28000000 + 0x09E20000}, // size: 14464 kB
|
||||
{0x28000000 + 0x058E0000, 0x28000000 + 0x06000000}, // size: 7296 kB
|
||||
{0x28000000 + 0x053C0000, 0x28000000 + 0x05880000}, // size: 4864 kB
|
||||
{0x28000000 + 0x08C20000, 0x28000000 + 0x08F20000}, // size: 3072 kB
|
||||
//{0x28000000 + 0x08C20000, 0x28000000 + 0x08F20000}, // size: 3072 kB is part of BAT mapping.
|
||||
{0x28000000 + 0x00900000, 0x28000000 + 0x00B00000}, // size: 2048 kB
|
||||
{0x28000000 + 0x07E20000, 0x28000000 + 0x07F80000}, // size: 1408 kB
|
||||
{0x28000000 + 0x02060000, 0x28000000 + 0x021A0000}, // size: 1280 kB
|
||||
@ -171,6 +173,10 @@ public:
|
||||
|
||||
static uint32_t getVideoMemorySize();
|
||||
|
||||
static uint32_t getPluginSpaceMemoryAddress();
|
||||
|
||||
static uint32_t getPluginSpaceMemorySize();
|
||||
|
||||
static uint32_t getAreaSizeFromPageTable(uint32_t start, uint32_t maxSize);
|
||||
|
||||
// Caution when using the result. A chunk of memory in effective address may be split up
|
@ -1,255 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
* Modified by Maschell, 2018 for Wii U Plugin System loader
|
||||
*
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/socket_functions.h>
|
||||
#include <dynamic_libs/padscore_functions.h>
|
||||
#include <utils/StringTools.h>
|
||||
#include <utils/logger.h>
|
||||
#include "myutils/overlay_helper.h"
|
||||
#include "MainWindow.h"
|
||||
#include "MainWindowGUI.h"
|
||||
#include "Application.h"
|
||||
|
||||
MainWindow * MainWindow::instance = NULL;
|
||||
|
||||
MainWindow::MainWindow(int32_t w, int32_t h)
|
||||
: width(w)
|
||||
, height(h) {
|
||||
for(int32_t i = 0; i < 4; i++) {
|
||||
std::string filename = StringTools::strfmt("player%i_point.png", i+1);
|
||||
pointerImgData[i] = Resources::GetImageData(filename.c_str());
|
||||
pointerImg[i] = new GuiImage(pointerImgData[i]);
|
||||
pointerImg[i]->setScale(1.5f);
|
||||
pointerValid[i] = false;
|
||||
}
|
||||
|
||||
SetupMainView();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
|
||||
while(!tvElements.empty()) {
|
||||
delete tvElements[0];
|
||||
remove(tvElements[0]);
|
||||
}
|
||||
while(!drcElements.empty()) {
|
||||
delete drcElements[0];
|
||||
remove(drcElements[0]);
|
||||
}
|
||||
for(int32_t i = 0; i < 4; i++) {
|
||||
delete pointerImg[i];
|
||||
Resources::RemoveImageData(pointerImgData[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateEffects() {
|
||||
//! dont read behind the initial elements in case one was added
|
||||
uint32_t tvSize = tvElements.size();
|
||||
uint32_t drcSize = drcElements.size();
|
||||
|
||||
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
drcElements[i]->updateEffects();
|
||||
}
|
||||
|
||||
//! only update TV elements that are not updated yet because they are on DRC
|
||||
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
uint32_t n;
|
||||
for(n = 0; (n < drcSize) && (n < drcElements.size()); n++) {
|
||||
if(tvElements[i] == drcElements[n])
|
||||
break;
|
||||
}
|
||||
if(n == drcElements.size()) {
|
||||
tvElements[i]->updateEffects();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::process() {
|
||||
//! dont read behind the initial elements in case one was added
|
||||
uint32_t tvSize = tvElements.size();
|
||||
uint32_t drcSize = drcElements.size();
|
||||
|
||||
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
drcElements[i]->process();
|
||||
}
|
||||
|
||||
//! only update TV elements that are not updated yet because they are on DRC
|
||||
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
uint32_t n;
|
||||
for(n = 0; (n < drcSize) && (n < drcElements.size()); n++) {
|
||||
if(tvElements[i] == drcElements[n])
|
||||
break;
|
||||
}
|
||||
if(n == drcElements.size()) {
|
||||
tvElements[i]->process();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::update(GuiController *controller) {
|
||||
//! dont read behind the initial elements in case one was added
|
||||
//uint32_t tvSize = tvElements.size();
|
||||
|
||||
if(controller->chan & GuiTrigger::CHANNEL_1) {
|
||||
uint32_t drcSize = drcElements.size();
|
||||
|
||||
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
drcElements[i]->update(controller);
|
||||
}
|
||||
} else {
|
||||
uint32_t tvSize = tvElements.size();
|
||||
|
||||
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
tvElements[i]->update(controller);
|
||||
}
|
||||
}
|
||||
|
||||
// //! only update TV elements that are not updated yet because they are on DRC
|
||||
// for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||
// {
|
||||
// uint32_t n;
|
||||
// for(n = 0; (n < drcSize) && (n < drcElements.size()); n++)
|
||||
// {
|
||||
// if(tvElements[i] == drcElements[n])
|
||||
// break;
|
||||
// }
|
||||
// if(n == drcElements.size())
|
||||
// {
|
||||
// tvElements[i]->update(controller);
|
||||
// }
|
||||
// }
|
||||
|
||||
if(controller->chanIdx >= 1 && controller->chanIdx <= 4 && controller->data.validPointer) {
|
||||
int32_t wpadIdx = controller->chanIdx - 1;
|
||||
float posX = controller->data.x;
|
||||
float posY = controller->data.y;
|
||||
pointerImg[wpadIdx]->setPosition(posX, posY);
|
||||
pointerImg[wpadIdx]->setAngle(controller->data.pointerAngle);
|
||||
pointerValid[wpadIdx] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::drawDrc(CVideo *video) {
|
||||
for(uint32_t i = 0; i < drcElements.size(); ++i) {
|
||||
drcElements[i]->draw(video);
|
||||
}
|
||||
|
||||
for(int32_t i = 0; i < 4; i++) {
|
||||
if(pointerValid[i]) {
|
||||
pointerImg[i]->setAlpha(0.5f);
|
||||
pointerImg[i]->draw(video);
|
||||
pointerImg[i]->setAlpha(1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::drawTv(CVideo *video) {
|
||||
for(uint32_t i = 0; i < tvElements.size(); ++i) {
|
||||
tvElements[i]->draw(video);
|
||||
}
|
||||
|
||||
for(int32_t i = 0; i < 4; i++) {
|
||||
if(pointerValid[i]) {
|
||||
pointerImg[i]->draw(video);
|
||||
pointerValid[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::SetupMainView() {
|
||||
DrcFrame = new MainWindowGUI(width,height);
|
||||
TvFrame = DrcFrame;
|
||||
appendTv(TvFrame);
|
||||
appendDrc(DrcFrame);
|
||||
}
|
||||
|
||||
void MainWindow::OnOpenEffectFinish(GuiElement *element) {
|
||||
//! once the menu is open reset its state and allow it to be "clicked/hold"
|
||||
element->effectFinished.disconnect(this);
|
||||
element->clearState(GuiElement::STATE_DISABLED);
|
||||
}
|
||||
|
||||
void MainWindow::appendToAllElements(GuiElement * element) {
|
||||
uint32_t drcSize = drcElements.size();
|
||||
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
GuiFrame * realElement = dynamic_cast<GuiFrame*>(drcElements[i]);
|
||||
if(realElement != NULL) {
|
||||
realElement->append(element);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t tvSize = tvElements.size();
|
||||
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
GuiFrame * realElement = dynamic_cast<GuiFrame*>(tvElements[i]);
|
||||
if(realElement != NULL) {
|
||||
realElement->append(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::removeFromAllElements(GuiElement * element) {
|
||||
uint32_t drcSize = drcElements.size();
|
||||
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
GuiFrame * realElement = dynamic_cast<GuiFrame*>(drcElements[i]);
|
||||
if(realElement != NULL) {
|
||||
realElement->remove(element);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t tvSize = tvElements.size();
|
||||
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
GuiFrame * realElement = dynamic_cast<GuiFrame*>(tvElements[i]);
|
||||
if(realElement != NULL) {
|
||||
realElement->remove(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setState(int32_t val, int32_t c) {
|
||||
uint32_t drcSize = drcElements.size();
|
||||
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
drcElements[i]->setState(val,c);
|
||||
}
|
||||
|
||||
uint32_t tvSize = tvElements.size();
|
||||
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
tvElements[i]->setState(val,c);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::clearState(int32_t val, int32_t c) {
|
||||
uint32_t drcSize = drcElements.size();
|
||||
for(uint32_t i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
drcElements[i]->clearState(val,c);
|
||||
}
|
||||
|
||||
uint32_t tvSize = tvElements.size();
|
||||
for(uint32_t i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
tvElements[i]->clearState(val,c);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::OnCloseEffectFinish(GuiElement *element) {
|
||||
//! remove element from draw list and push to delete queue
|
||||
remove(element);
|
||||
|
||||
AsyncDeleter::pushForDelete(element);
|
||||
|
||||
clearState(GuiElement::STATE_DISABLE_INPUT);
|
||||
}
|
@ -1,158 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
*
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
#ifndef _MAIN_WINDOW_H_
|
||||
#define _MAIN_WINDOW_H_
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <gui/Gui.h>
|
||||
#include <system/CMutex.h>
|
||||
|
||||
class CVideo;
|
||||
|
||||
class MainWindow : public sigslot::has_slots<> {
|
||||
public:
|
||||
virtual ~MainWindow();
|
||||
|
||||
static MainWindow *instance;
|
||||
|
||||
static MainWindow *getInstance(int32_t w,int32_t h) {
|
||||
if(!instance) {
|
||||
instance = new MainWindow(w, h);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
static MainWindow *getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
static void destroyInstance() {
|
||||
if(instance) {
|
||||
delete instance;
|
||||
instance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void appendTv(GuiElement *e) {
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
removeTv(e);
|
||||
tvElements.push_back(e);
|
||||
}
|
||||
void appendDrc(GuiElement *e) {
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
removeDrc(e);
|
||||
drcElements.push_back(e);
|
||||
}
|
||||
|
||||
void append(GuiElement *e) {
|
||||
appendTv(e);
|
||||
appendDrc(e);
|
||||
}
|
||||
|
||||
void insertTv(uint32_t pos, GuiElement *e) {
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
removeTv(e);
|
||||
tvElements.insert(tvElements.begin() + pos, e);
|
||||
}
|
||||
void insertDrc(uint32_t pos, GuiElement *e) {
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
removeDrc(e);
|
||||
drcElements.insert(drcElements.begin() + pos, e);
|
||||
}
|
||||
|
||||
void insert(uint32_t pos, GuiElement *e) {
|
||||
insertTv(pos, e);
|
||||
insertDrc(pos, e);
|
||||
}
|
||||
|
||||
void removeTv(GuiElement *e) {
|
||||
for(uint32_t i = 0; i < tvElements.size(); ++i) {
|
||||
if(e == tvElements[i]) {
|
||||
tvElements.erase(tvElements.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void removeDrc(GuiElement *e) {
|
||||
for(uint32_t i = 0; i < drcElements.size(); ++i) {
|
||||
if(e == drcElements[i]) {
|
||||
drcElements.erase(drcElements.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void remove(GuiElement *e) {
|
||||
removeTv(e);
|
||||
removeDrc(e);
|
||||
}
|
||||
void removeAll() {
|
||||
tvElements.clear();
|
||||
drcElements.clear();
|
||||
}
|
||||
|
||||
void drawDrc(CVideo *video);
|
||||
void drawTv(CVideo *video);
|
||||
void update(GuiController *controller);
|
||||
void updateEffects();
|
||||
void process();
|
||||
|
||||
void appendToAllElements(GuiElement * element);
|
||||
void removeFromAllElements(GuiElement * element);
|
||||
void setState(int32_t i, int32_t c = -1 );
|
||||
void clearState(int32_t i, int32_t c = -1);
|
||||
|
||||
void lockGUI() {
|
||||
guiMutex.lock();
|
||||
}
|
||||
void unlockGUI() {
|
||||
guiMutex.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
MainWindow(int32_t w, int32_t h);
|
||||
void SetupMainView(void);
|
||||
|
||||
void OnOpenEffectFinish(GuiElement *element);
|
||||
void OnCloseEffectFinish(GuiElement *element);
|
||||
|
||||
int32_t width, height;
|
||||
std::vector<GuiElement *> drcElements;
|
||||
std::vector<GuiElement *> tvElements;
|
||||
|
||||
GuiSound *ClickSound;
|
||||
|
||||
GuiFrame * TvFrame;
|
||||
GuiFrame * DrcFrame;
|
||||
|
||||
GuiImageData *pointerImgData[4];
|
||||
GuiImage *pointerImg[4];
|
||||
bool pointerValid[4];
|
||||
|
||||
CMutex guiMutex;
|
||||
};
|
||||
|
||||
#endif //_MAIN_WINDOW_H_
|