forked from sin365/AxibugEmuOnline
上传客户端
This commit is contained in:
parent
7485f016a3
commit
b5d0d31b0c
13
AxibugEmuOnline.Client/Assets/Aya.UNes.asmdef
Normal file
13
AxibugEmuOnline.Client/Assets/Aya.UNes.asmdef
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "AxibugEmuOnline.Client.UNES",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": true,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
7
AxibugEmuOnline.Client/Assets/Aya.UNes.asmdef.meta
Normal file
7
AxibugEmuOnline.Client/Assets/Aya.UNes.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fe77f1eed9fc0847a86648f644fe815
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
674
AxibugEmuOnline.Client/Assets/LICENSE.md
Normal file
674
AxibugEmuOnline.Client/Assets/LICENSE.md
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
7
AxibugEmuOnline.Client/Assets/LICENSE.md.meta
Normal file
7
AxibugEmuOnline.Client/Assets/LICENSE.md.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b0730be05596c544807c9992169cb68
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
AxibugEmuOnline.Client/Assets/Plugins.meta
Normal file
8
AxibugEmuOnline.Client/Assets/Plugins.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69eb869b06dab98439f07da4549fb7cb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
AxibugEmuOnline.Client/Assets/Plugins/Google.Protobuf.dll
Normal file
BIN
AxibugEmuOnline.Client/Assets/Plugins/Google.Protobuf.dll
Normal file
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c61c2e567bd4e146b4c09946e815a55
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 324deac494a24a7499801349c7908062
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bba3137572a9a52478aa945ce387a192
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 208c5b5b9ca9139418ec61b89a1516ed
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
AxibugEmuOnline.Client/Assets/Plugins/NoSugarNet.DataHelper.dll
Normal file
BIN
AxibugEmuOnline.Client/Assets/Plugins/NoSugarNet.DataHelper.dll
Normal file
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d83e3c67ee8b794c97b5876ece7a16e
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
AxibugEmuOnline.Client/Assets/Plugins/System.Buffers.dll
Normal file
BIN
AxibugEmuOnline.Client/Assets/Plugins/System.Buffers.dll
Normal file
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3e5397cebfd55d4d950fc3d7fcafd8f
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
AxibugEmuOnline.Client/Assets/Plugins/System.Memory.dll
Normal file
BIN
AxibugEmuOnline.Client/Assets/Plugins/System.Memory.dll
Normal file
Binary file not shown.
33
AxibugEmuOnline.Client/Assets/Plugins/System.Memory.dll.meta
Normal file
33
AxibugEmuOnline.Client/Assets/Plugins/System.Memory.dll.meta
Normal file
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7079d9113f8bfda4db8a78fffdd414a9
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 677f64bf577a1724699f45841c5bcb04
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c92fb77cb5b063541bd04cb8a496013f
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
AxibugEmuOnline.Client/Assets/Resources.meta
Normal file
8
AxibugEmuOnline.Client/Assets/Resources.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 481be8b9dd1218749a75bf1bd4612c04
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
AxibugEmuOnline.Client/Assets/Resources/Mario.bytes
Normal file
BIN
AxibugEmuOnline.Client/Assets/Resources/Mario.bytes
Normal file
Binary file not shown.
7
AxibugEmuOnline.Client/Assets/Resources/Mario.bytes.meta
Normal file
7
AxibugEmuOnline.Client/Assets/Resources/Mario.bytes.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 040fea71e1812ce45bd2b72c8ad2e2ae
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
AxibugEmuOnline.Client/Assets/Resources/Texture.meta
Normal file
8
AxibugEmuOnline.Client/Assets/Resources/Texture.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b52033f7628c4346a6dd0b2806e75ee
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,39 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!84 &8400000
|
||||
RenderTexture:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: RenderTexture
|
||||
m_ImageContentsHash:
|
||||
serializedVersion: 2
|
||||
Hash: 00000000000000000000000000000000
|
||||
m_ForcedFallbackFormat: 4
|
||||
m_DownscaleFallback: 0
|
||||
m_IsAlphaChannelOptional: 0
|
||||
serializedVersion: 5
|
||||
m_Width: 256
|
||||
m_Height: 240
|
||||
m_AntiAliasing: 1
|
||||
m_MipCount: -1
|
||||
m_DepthStencilFormat: 92
|
||||
m_ColorFormat: 8
|
||||
m_MipMap: 0
|
||||
m_GenerateMips: 1
|
||||
m_SRGB: 0
|
||||
m_UseDynamicScale: 0
|
||||
m_BindMS: 0
|
||||
m_EnableCompatibleFormat: 1
|
||||
m_TextureSettings:
|
||||
serializedVersion: 2
|
||||
m_FilterMode: 1
|
||||
m_Aniso: 0
|
||||
m_MipBias: 0
|
||||
m_WrapU: 1
|
||||
m_WrapV: 1
|
||||
m_WrapW: 1
|
||||
m_Dimension: 2
|
||||
m_VolumeDepth: 1
|
||||
m_ShadowSamplingMode: 2
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6645567e4c11d9447b1aee2406f681c5
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
AxibugEmuOnline.Client/Assets/Runtime.meta
Normal file
8
AxibugEmuOnline.Client/Assets/Runtime.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca1eb074eb7f66946b0d974b802d7b8d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
AxibugEmuOnline.Client/Assets/Runtime/Controller.meta
Normal file
8
AxibugEmuOnline.Client/Assets/Runtime/Controller.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87f4900ceb2e3b24caa8eec8df6b34e7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES.Controller
|
||||
{
|
||||
public interface IController
|
||||
{
|
||||
void Strobe(bool on);
|
||||
|
||||
int ReadState();
|
||||
|
||||
void PressKey(KeyCode keyCode);
|
||||
|
||||
void ReleaseKey(KeyCode keyCode);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fde4f0c3566240b4fa824b147b019ff7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES.Controller
|
||||
{
|
||||
[Serializable]
|
||||
public class KeyConfig
|
||||
{
|
||||
public KeyCode Up = KeyCode.UpArrow;
|
||||
public KeyCode Down = KeyCode.DownArrow;
|
||||
public KeyCode Left = KeyCode.LeftArrow;
|
||||
public KeyCode Right = KeyCode.RightArrow;
|
||||
|
||||
public KeyCode A = KeyCode.A;
|
||||
public KeyCode B = KeyCode.S;
|
||||
|
||||
public KeyCode Start = KeyCode.Alpha1;
|
||||
public KeyCode Select = KeyCode.Alpha2;
|
||||
|
||||
public KeyCode Debug = KeyCode.P;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e51d74785e24fa4f972a1eb002a81d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,83 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using AxibugEmuOnline.Client.UNES.Input;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES.Controller
|
||||
{
|
||||
public class NesController : IController
|
||||
{
|
||||
private readonly UNESBehaviour _nes;
|
||||
private int _data;
|
||||
private int _serialData;
|
||||
private bool _strobing;
|
||||
|
||||
public bool Debug;
|
||||
|
||||
public KeyConfig Config => _nes.KeyConfig;
|
||||
|
||||
// bit: 7 6 5 4 3 2 1 0
|
||||
// button: A B Select Start Up Down Left
|
||||
|
||||
private readonly Dictionary<KeyCode, int> _keyMapping;
|
||||
|
||||
public NesController(UNESBehaviour nse)
|
||||
{
|
||||
_nes = nse;
|
||||
|
||||
_keyMapping = new Dictionary<KeyCode, int>
|
||||
{
|
||||
{Config.A, 7},
|
||||
{Config.B, 6},
|
||||
{Config.Select, 5},
|
||||
{Config.Start, 4},
|
||||
{Config.Up, 3},
|
||||
{Config.Down, 2},
|
||||
{Config.Left, 1},
|
||||
{Config.Right, 0},
|
||||
};
|
||||
}
|
||||
|
||||
public void Strobe(bool on)
|
||||
{
|
||||
_serialData = _data;
|
||||
_strobing = on;
|
||||
}
|
||||
|
||||
public int ReadState()
|
||||
{
|
||||
int ret = ((_serialData & 0x80) > 0).AsByte();
|
||||
if (!_strobing)
|
||||
{
|
||||
_serialData <<= 1;
|
||||
_serialData &= 0xFF;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void PressKey(KeyCode keyCode)
|
||||
{
|
||||
if (keyCode == Config.Debug)
|
||||
{
|
||||
Debug ^= true;
|
||||
}
|
||||
|
||||
if (!_keyMapping.ContainsKey(keyCode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_data |= 1 << _keyMapping[keyCode];
|
||||
}
|
||||
|
||||
public void ReleaseKey(KeyCode keyCode)
|
||||
{
|
||||
if (!_keyMapping.ContainsKey(keyCode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_data &= ~(1 << _keyMapping[keyCode]);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a6001b2b26e33144b77fe0b02e21dc0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
AxibugEmuOnline.Client/Assets/Runtime/Core.meta
Normal file
8
AxibugEmuOnline.Client/Assets/Runtime/Core.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f857291907b21142bc251146119762c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
62
AxibugEmuOnline.Client/Assets/Runtime/Core/Addressable.cs
Normal file
62
AxibugEmuOnline.Client/Assets/Runtime/Core/Addressable.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
public abstract class Addressable
|
||||
{
|
||||
public delegate uint ReadDelegate(uint address);
|
||||
|
||||
public delegate void WriteDelegate(uint address, byte val);
|
||||
|
||||
protected readonly Emulator _emulator;
|
||||
protected readonly ReadDelegate[] _readMap;
|
||||
protected readonly WriteDelegate[] _writeMap;
|
||||
protected readonly uint _addressSize;
|
||||
|
||||
protected Addressable(Emulator emulator, uint addressSpace)
|
||||
{
|
||||
_emulator = emulator;
|
||||
_addressSize = addressSpace;
|
||||
_readMap = new ReadDelegate[addressSpace + 1];
|
||||
_writeMap = new WriteDelegate[addressSpace + 1];
|
||||
}
|
||||
|
||||
protected virtual void InitializeMemoryMap()
|
||||
{
|
||||
_readMap.Fill(address => 0);
|
||||
|
||||
// Some games write to addresses not mapped and expect to continue afterwards
|
||||
_writeMap.Fill((address, val) => { });
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint ReadByte(uint address)
|
||||
{
|
||||
address &= _addressSize;
|
||||
return _readMap[address](address);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void WriteByte(uint address, uint val)
|
||||
{
|
||||
address &= _addressSize;
|
||||
_writeMap[address](address, (byte)val);
|
||||
}
|
||||
|
||||
public void MapReadHandler(uint start, uint end, CPU.ReadDelegate func)
|
||||
{
|
||||
for (uint i = start; i <= end; i++)
|
||||
{
|
||||
_readMap[i] = func;
|
||||
}
|
||||
}
|
||||
|
||||
public void MapWriteHandler(uint start, uint end, CPU.WriteDelegate func)
|
||||
{
|
||||
for (uint i = start; i <= end; i++)
|
||||
{
|
||||
_writeMap[i] = func;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8649a70e245ed1744aa620cb28504fb5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
81
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.Core.cs
Normal file
81
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.Core.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
sealed partial class CPU
|
||||
{
|
||||
public enum InterruptType
|
||||
{
|
||||
NMI,
|
||||
IRQ,
|
||||
RESET
|
||||
}
|
||||
|
||||
private readonly uint[] _interruptHandlerOffsets = { 0xFFFA, 0xFFFE, 0xFFFC };
|
||||
private readonly bool[] _interrupts = new bool[2];
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
A = 0;
|
||||
X = 0;
|
||||
Y = 0;
|
||||
SP = 0xFD;
|
||||
P = 0x24;
|
||||
|
||||
PC = ReadWord(_interruptHandlerOffsets[(int) InterruptType.RESET]);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
SP -= 3;
|
||||
F.InterruptsDisabled = true;
|
||||
}
|
||||
|
||||
public void TickFromPPU()
|
||||
{
|
||||
if (Cycle-- > 0) return;
|
||||
ExecuteSingleInstruction();
|
||||
}
|
||||
|
||||
public void ExecuteSingleInstruction()
|
||||
{
|
||||
for (var i = 0; i < _interrupts.Length; i++)
|
||||
{
|
||||
if (_interrupts[i])
|
||||
{
|
||||
PushWord(PC);
|
||||
Push(P);
|
||||
PC = ReadWord(_interruptHandlerOffsets[i]);
|
||||
F.InterruptsDisabled = true;
|
||||
_interrupts[i] = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_currentInstruction = NextByte();
|
||||
|
||||
Cycle += _opCodeDefs[_currentInstruction].Cycles;
|
||||
|
||||
ResetInstructionAddressingMode();
|
||||
// if (_numExecuted > 10000 && PC - 1 == 0xFF61)
|
||||
// if(_emulator.Controller.debug || 0x6E00 <= PC && PC <= 0x6EEF)
|
||||
// Console.WriteLine($"{(PC - 1).ToString("X4")} {_currentInstruction.ToString("X2")} {opcodeNames[_currentInstruction]}\t\t\tA:{A.ToString("X2")} X:{X.ToString("X2")} Y:{Y.ToString("X2")} P:{P.ToString("X2")} SP:{SP.ToString("X2")}");
|
||||
|
||||
var op = _opCodes[_currentInstruction];
|
||||
if (op == null)
|
||||
{
|
||||
throw new ArgumentException(_currentInstruction.ToString("X2"));
|
||||
}
|
||||
|
||||
op();
|
||||
}
|
||||
|
||||
public void TriggerInterrupt(InterruptType type)
|
||||
{
|
||||
if (!F.InterruptsDisabled || type == InterruptType.NMI)
|
||||
{
|
||||
_interrupts[(int)type] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.Core.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.Core.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63ec605962bce0e4899b19d49d4ed747
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
sealed partial class CPU
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void WriteIoRegister(uint reg, byte val)
|
||||
{
|
||||
switch (reg)
|
||||
{
|
||||
case 0x4014: // OAM DMA
|
||||
_emulator.PPU.PerformDMA(val);
|
||||
break;
|
||||
case 0x4016:
|
||||
_emulator.Controller.Strobe(val == 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (reg <= 0x401F)
|
||||
{
|
||||
return; // APU write
|
||||
}
|
||||
|
||||
throw new NotImplementedException($"{reg:X4} = {val:X2}");
|
||||
}
|
||||
|
||||
public uint ReadIORegister(uint reg)
|
||||
{
|
||||
switch (reg)
|
||||
{
|
||||
case 0x4016:
|
||||
return (uint) _emulator.Controller.ReadState() & 0x1;
|
||||
}
|
||||
return 0x00;
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ad8b3c04ef34de48b5cab3029811d9d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
463
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.Instructions.cs
Normal file
463
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.Instructions.cs
Normal file
@ -0,0 +1,463 @@
|
||||
using System;
|
||||
using static AxibugEmuOnline.Client.UNES.CPU.AddressingMode;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
public sealed partial class CPU
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)]
|
||||
public class OpCodeDef : Attribute
|
||||
{
|
||||
public int OpCode;
|
||||
public int Cycles = 1;
|
||||
public bool PageBoundary;
|
||||
public bool RMW;
|
||||
public AddressingMode Mode = None;
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x20, Cycles = 6)]
|
||||
private void JSR()
|
||||
{
|
||||
PushWord(PC + 1);
|
||||
PC = NextWord();
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x40, Cycles = 6)]
|
||||
private void RTI()
|
||||
{
|
||||
// TODO: this dummy fetch should happen for all single-byte instructions
|
||||
NextByte();
|
||||
P = Pop();
|
||||
PC = PopWord();
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x60, Cycles = 6)]
|
||||
private void RTS()
|
||||
{
|
||||
NextByte();
|
||||
PC = PopWord() + 1;
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0xC8, Cycles = 2)]
|
||||
private void INY() => Y++;
|
||||
|
||||
[OpCodeDef(OpCode = 0x88, Cycles = 2)]
|
||||
private void DEY() => Y--;
|
||||
|
||||
[OpCodeDef(OpCode = 0xE8, Cycles = 2)]
|
||||
private void INX() => X++;
|
||||
|
||||
[OpCodeDef(OpCode = 0xCA, Cycles = 2, RMW = true)]
|
||||
private void DEX() => X--;
|
||||
|
||||
[OpCodeDef(OpCode = 0xA8, Cycles = 2)]
|
||||
private void TAY() => Y = A;
|
||||
|
||||
[OpCodeDef(OpCode = 0x98, Cycles = 2)]
|
||||
private void TYA() => A = Y;
|
||||
|
||||
[OpCodeDef(OpCode = 0xAA, Cycles = 2, RMW = true)]
|
||||
private void TAX() => X = A;
|
||||
|
||||
[OpCodeDef(OpCode = 0x8A, Cycles = 2, RMW = true)]
|
||||
private void TXA() => A = X;
|
||||
|
||||
[OpCodeDef(OpCode = 0xBA, Cycles = 2)]
|
||||
private void TSX() => X = SP;
|
||||
|
||||
[OpCodeDef(OpCode = 0x9A, Cycles = 2, RMW = true)]
|
||||
private void TXS() => SP = X;
|
||||
|
||||
[OpCodeDef(OpCode = 0x08, Cycles = 3)]
|
||||
private void PHP() => Push(P | BreakSourceBit);
|
||||
|
||||
[OpCodeDef(OpCode = 0x28, Cycles = 4)]
|
||||
private void PLP() => P = (uint)(Pop() & ~BreakSourceBit);
|
||||
|
||||
[OpCodeDef(OpCode = 0x68, Cycles = 4)]
|
||||
private void PLA() => A = Pop();
|
||||
|
||||
[OpCodeDef(OpCode = 0x48, Cycles = 3)]
|
||||
private void PHA() => Push(A);
|
||||
|
||||
[OpCodeDef(OpCode = 0x24, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0x2C, Mode = Absolute, Cycles = 4)]
|
||||
private void BIT()
|
||||
{
|
||||
uint val = AddressRead();
|
||||
F.Overflow = (val & 0x40) > 0;
|
||||
F.Zero = (val & A) == 0;
|
||||
F.Negative = (val & 0x80) > 0;
|
||||
}
|
||||
|
||||
private void Branch(bool cond)
|
||||
{
|
||||
uint nPC = (uint)(PC + NextSByte() + 1);
|
||||
if (cond)
|
||||
{
|
||||
PC = nPC;
|
||||
Cycle++;
|
||||
}
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x4C, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0x6C, Cycles = 5)]
|
||||
private void JMP()
|
||||
{
|
||||
if (_currentInstruction == 0x4C)
|
||||
{
|
||||
PC = NextWord();
|
||||
}
|
||||
else if (_currentInstruction == 0x6C)
|
||||
{
|
||||
uint off = NextWord();
|
||||
// AN INDIRECT JUMP MUST NEVER USE A VECTOR BEGINNING ON THE LAST BYTE OF A PAGE
|
||||
//
|
||||
// If address $3000 contains $40, $30FF contains $80, and $3100 contains $50,
|
||||
// the result of JMP ($30FF) will be a transfer of control to $4080 rather than
|
||||
// $5080 as you intended i.e. the 6502 took the low byte of the address from
|
||||
// $30FF and the high byte from $3000.
|
||||
//
|
||||
// http://www.6502.org/tutorials/6502opcodes.html
|
||||
uint hi = (off & 0xFF) == 0xFF ? off - 0xFF : off + 1;
|
||||
uint oldPC = PC;
|
||||
PC = ReadByte(off) | (ReadByte(hi) << 8);
|
||||
|
||||
if ((oldPC & 0xFF00) != (PC & 0xFF00))
|
||||
{
|
||||
Cycle += 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0xB0, Cycles = 2)]
|
||||
private void BCS() => Branch(F.Carry);
|
||||
|
||||
[OpCodeDef(OpCode = 0x90, Cycles = 2)]
|
||||
private void BCC() => Branch(!F.Carry);
|
||||
|
||||
[OpCodeDef(OpCode = 0xF0, Cycles = 2)]
|
||||
private void BEQ() => Branch(F.Zero);
|
||||
|
||||
[OpCodeDef(OpCode = 0xD0, Cycles = 2)]
|
||||
private void BNE() => Branch(!F.Zero);
|
||||
|
||||
[OpCodeDef(OpCode = 0x70, Cycles = 2)]
|
||||
private void BVS() => Branch(F.Overflow);
|
||||
|
||||
[OpCodeDef(OpCode = 0x50, Cycles = 2)]
|
||||
private void BVC() => Branch(!F.Overflow);
|
||||
|
||||
[OpCodeDef(OpCode = 0x10, Cycles = 2)]
|
||||
private void BPL() => Branch(!F.Negative);
|
||||
|
||||
[OpCodeDef(OpCode = 0x30, Cycles = 2)]
|
||||
private void BMI() => Branch(F.Negative);
|
||||
|
||||
[OpCodeDef(OpCode = 0x81, Mode = IndirectX, Cycles = 6)]
|
||||
[OpCodeDef(OpCode = 0x91, Mode = IndirectY, Cycles = 6)]
|
||||
[OpCodeDef(OpCode = 0x95, Mode = ZeroPageX, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x99, Mode = AbsoluteY, Cycles = 5)]
|
||||
[OpCodeDef(OpCode = 0x9D, Mode = AbsoluteX, Cycles = 5)]
|
||||
[OpCodeDef(OpCode = 0x85, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0x8D, Mode = Absolute, Cycles = 4)]
|
||||
private void STA() => AddressWrite(A);
|
||||
|
||||
[OpCodeDef(OpCode = 0x96, Mode = ZeroPageY, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x86, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0x8E, Mode = Absolute, Cycles = 4)]
|
||||
private void STX() => AddressWrite(X);
|
||||
|
||||
[OpCodeDef(OpCode = 0x94, Mode = ZeroPageX, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x84, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0x8C, Mode = Absolute, Cycles = 4)]
|
||||
private void STY() => AddressWrite(Y);
|
||||
|
||||
[OpCodeDef(OpCode = 0x18, Cycles = 2)]
|
||||
private void CLC() => F.Carry = false;
|
||||
|
||||
[OpCodeDef(OpCode = 0x38, Cycles = 2)]
|
||||
private void SEC() => F.Carry = true;
|
||||
|
||||
[OpCodeDef(OpCode = 0x58, Cycles = 2)]
|
||||
private void CLI() => F.InterruptsDisabled = false;
|
||||
|
||||
[OpCodeDef(OpCode = 0x78, Cycles = 2)]
|
||||
private void SEI() => F.InterruptsDisabled = true;
|
||||
|
||||
[OpCodeDef(OpCode = 0xB8, Cycles = 2)]
|
||||
private void CLV() => F.Overflow = false;
|
||||
|
||||
[OpCodeDef(OpCode = 0xD8, Cycles = 2)]
|
||||
private void CLD() => F.DecimalMode = false;
|
||||
|
||||
[OpCodeDef(OpCode = 0xF8, Cycles = 2)]
|
||||
private void SED() => F.DecimalMode = true;
|
||||
|
||||
[OpCodeDef(OpCode = 0xEA, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0x1A, Cycles = 2)] // Unofficial
|
||||
[OpCodeDef(OpCode = 0x3A, Cycles = 2)] // Unofficial
|
||||
[OpCodeDef(OpCode = 0x5A, Cycles = 2)] // Unofficial
|
||||
[OpCodeDef(OpCode = 0x7A, Cycles = 2)] // Unofficial
|
||||
[OpCodeDef(OpCode = 0xDA, Cycles = 2)] // Unofficial
|
||||
[OpCodeDef(OpCode = 0xFA, Cycles = 2)] // Unofficial
|
||||
private void NOP() { }
|
||||
|
||||
[OpCodeDef(OpCode = 0xA1, Mode = IndirectX, Cycles = 6)]
|
||||
[OpCodeDef(OpCode = 0xA5, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0xA9, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0xAD, Mode = Absolute, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0xB1, Mode = IndirectY, Cycles = 5, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0xB5, Mode = ZeroPageX, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0xB9, Mode = AbsoluteY, Cycles = 4, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0xBD, Mode = AbsoluteX, Cycles = 4, PageBoundary = true)]
|
||||
private void LDA() => A = AddressRead();
|
||||
|
||||
[OpCodeDef(OpCode = 0xA0, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0xA4, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0xAC, Mode = Absolute, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0xB4, Mode = ZeroPageX, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0xBC, Mode = AbsoluteX, Cycles = 4, PageBoundary = true)]
|
||||
private void LDY() => Y = AddressRead();
|
||||
|
||||
[OpCodeDef(OpCode = 0xA2, Mode = Immediate, Cycles = 2, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0xA6, Mode = ZeroPage, Cycles = 3, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0xAE, Mode = Absolute, Cycles = 4, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0xB6, Mode = ZeroPageY, Cycles = 4, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0xBE, Mode = AbsoluteY, Cycles = 4, PageBoundary = true, RMW = true)]
|
||||
private void LDX() => X = AddressRead();
|
||||
|
||||
[OpCodeDef(OpCode = 0x01, Mode = IndirectX, Cycles = 6)]
|
||||
[OpCodeDef(OpCode = 0x05, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0x09, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0x0D, Mode = Absolute, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x11, Mode = IndirectY, Cycles = 5, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0x15, Mode = ZeroPageX, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x19, Mode = AbsoluteY, Cycles = 4, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0x1D, Mode = AbsoluteX, Cycles = 4, PageBoundary = true)]
|
||||
private void ORA() => A |= AddressRead();
|
||||
|
||||
[OpCodeDef(OpCode = 0x21, Mode = IndirectX, Cycles = 6)]
|
||||
[OpCodeDef(OpCode = 0x25, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0x29, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0x2D, Mode = Absolute, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x31, Mode = IndirectY, Cycles = 5, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0x35, Mode = ZeroPageX, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x39, Mode = AbsoluteY, Cycles = 4, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0x3D, Mode = AbsoluteX, Cycles = 4, PageBoundary = true)]
|
||||
private void AND() => A &= AddressRead();
|
||||
|
||||
[OpCodeDef(OpCode = 0x41, Mode = IndirectX, Cycles = 6)]
|
||||
[OpCodeDef(OpCode = 0x45, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0x49, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0x4D, Mode = Absolute, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x51, Mode = IndirectY, Cycles = 5, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0x55, Mode = ZeroPageX, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x59, Mode = AbsoluteY, Cycles = 4, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0x5D, Mode = AbsoluteX, Cycles = 4, PageBoundary = true)]
|
||||
private void EOR() => A ^= AddressRead();
|
||||
|
||||
[OpCodeDef(OpCode = 0xE1, Mode = IndirectX, Cycles = 6)]
|
||||
[OpCodeDef(OpCode = 0xE5, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0x69, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0xE9, Mode = Immediate, Cycles = 2)] // Official duplicate of $69
|
||||
[OpCodeDef(OpCode = 0xEB, Mode = Immediate, Cycles = 2)] // Unofficial duplicate of $69
|
||||
[OpCodeDef(OpCode = 0xED, Mode = Absolute, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0xF1, Mode = IndirectY, Cycles = 5, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0xF5, Mode = ZeroPageX, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0xF9, Mode = AbsoluteY, Cycles = 4, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0xFD, Mode = AbsoluteX, Cycles = 4, PageBoundary = true)]
|
||||
private void SBC() => ADCImpl((byte)~AddressRead());
|
||||
|
||||
[OpCodeDef(OpCode = 0x61, Mode = IndirectX, Cycles = 6)]
|
||||
[OpCodeDef(OpCode = 0x65, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0x69, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0x6D, Mode = Absolute, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x71, Mode = IndirectY, Cycles = 5, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0x75, Mode = ZeroPageX, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0x79, Mode = AbsoluteY, Cycles = 4, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0x7D, Mode = AbsoluteX, Cycles = 4, PageBoundary = true)]
|
||||
private void ADC() => ADCImpl(AddressRead());
|
||||
|
||||
private void ADCImpl(uint val)
|
||||
{
|
||||
int nA = (sbyte)A + (sbyte)val + (sbyte)(F.Carry ? 1 : 0);
|
||||
F.Overflow = nA < -128 || nA > 127;
|
||||
F.Carry = (A + val + (F.Carry ? 1 : 0)) > 0xFF;
|
||||
A = (byte)(nA & 0xFF);
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x00, Cycles = 7)]
|
||||
private void BRK()
|
||||
{
|
||||
NextByte();
|
||||
Push(P | BreakSourceBit);
|
||||
F.InterruptsDisabled = true;
|
||||
PC = ReadByte(0xFFFE) | (ReadByte(0xFFFF) << 8);
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0xC1, Mode = IndirectX, Cycles = 6)]
|
||||
[OpCodeDef(OpCode = 0xC5, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0xC9, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0xCD, Mode = Absolute, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0xD1, Mode = IndirectY, Cycles = 5, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0xD5, Mode = ZeroPageX, Cycles = 4)]
|
||||
[OpCodeDef(OpCode = 0xD9, Mode = AbsoluteY, Cycles = 4, PageBoundary = true)]
|
||||
[OpCodeDef(OpCode = 0xDD, Mode = AbsoluteX, Cycles = 4, PageBoundary = true)]
|
||||
private void CMP() => CMPImpl(A);
|
||||
|
||||
[OpCodeDef(OpCode = 0xE0, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0xE4, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0xEC, Mode = Absolute, Cycles = 4)]
|
||||
private void CPX() => CMPImpl(X);
|
||||
|
||||
[OpCodeDef(OpCode = 0xC0, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0xC4, Mode = ZeroPage, Cycles = 3)]
|
||||
[OpCodeDef(OpCode = 0xCC, Mode = Absolute, Cycles = 4)]
|
||||
private void CPY() => CMPImpl(Y);
|
||||
|
||||
private void CMPImpl(uint reg)
|
||||
{
|
||||
long d = reg - (int)AddressRead();
|
||||
|
||||
F.Negative = (d & 0x80) > 0 && d != 0;
|
||||
F.Carry = d >= 0;
|
||||
F.Zero = d == 0;
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x46, Mode = ZeroPage, Cycles = 5, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x4E, Mode = Absolute, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x56, Mode = ZeroPageX, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x5E, Mode = AbsoluteX, Cycles = 7, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x4A, Mode = Direct, Cycles = 2, RMW = true)]
|
||||
private void LSR()
|
||||
{
|
||||
uint D = AddressRead();
|
||||
F.Carry = (D & 0x1) > 0;
|
||||
D >>= 1;
|
||||
_F(D);
|
||||
AddressWrite(D);
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x06, Mode = ZeroPage, Cycles = 5, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x0E, Mode = Absolute, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x16, Mode = ZeroPageX, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x1E, Mode = AbsoluteX, Cycles = 7, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x0A, Mode = Direct, Cycles = 2, RMW = true)]
|
||||
private void ASL()
|
||||
{
|
||||
uint D = AddressRead();
|
||||
F.Carry = (D & 0x80) > 0;
|
||||
D <<= 1;
|
||||
_F(D);
|
||||
AddressWrite(D);
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x66, Mode = ZeroPage, Cycles = 5, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x6E, Mode = Absolute, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x76, Mode = ZeroPageX, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x7E, Mode = AbsoluteX, Cycles = 7, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x6A, Mode = Direct, Cycles = 2, RMW = true)]
|
||||
private void ROR()
|
||||
{
|
||||
uint D = AddressRead();
|
||||
bool c = F.Carry;
|
||||
F.Carry = (D & 0x1) > 0;
|
||||
D >>= 1;
|
||||
if (c) D |= 0x80;
|
||||
_F(D);
|
||||
AddressWrite(D);
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x26, Mode = ZeroPage, Cycles = 5, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x2E, Mode = Absolute, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x36, Mode = ZeroPageX, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x3E, Mode = AbsoluteX, Cycles = 7, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0x2A, Mode = Direct, Cycles = 2, RMW = true)]
|
||||
private void ROL()
|
||||
{
|
||||
uint D = AddressRead();
|
||||
bool c = F.Carry;
|
||||
F.Carry = (D & 0x80) > 0;
|
||||
D <<= 1;
|
||||
if (c) D |= 0x1;
|
||||
_F(D);
|
||||
AddressWrite(D);
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0xE6, Mode = ZeroPage, Cycles = 5, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0xEE, Mode = Absolute, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0xF6, Mode = ZeroPageX, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0xFE, Mode = AbsoluteX, Cycles = 7, RMW = true)]
|
||||
private void INC()
|
||||
{
|
||||
byte D = (byte)(AddressRead() + 1);
|
||||
_F(D);
|
||||
AddressWrite(D);
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0xC6, Mode = ZeroPage, Cycles = 5, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0xCE, Mode = Absolute, Cycles = 3, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0xD6, Mode = ZeroPageX, Cycles = 6, RMW = true)]
|
||||
[OpCodeDef(OpCode = 0xDE, Mode = AbsoluteX, Cycles = 7, RMW = true)]
|
||||
private void DEC()
|
||||
{
|
||||
byte D = (byte)(AddressRead() - 1);
|
||||
_F(D);
|
||||
AddressWrite(D);
|
||||
}
|
||||
|
||||
#region Unofficial Opcodes
|
||||
|
||||
[OpCodeDef(OpCode = 0x80, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0x82, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0x89, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0xC2, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0xE2, Cycles = 2)]
|
||||
private void SKB() => NextByte(); // Essentially a 2-byte NOP
|
||||
|
||||
[OpCodeDef(OpCode = 0x0B, Mode = Immediate, Cycles = 2)]
|
||||
[OpCodeDef(OpCode = 0x2B, Mode = Immediate, Cycles = 2)]
|
||||
private void ANC()
|
||||
{
|
||||
A &= AddressRead();
|
||||
F.Carry = F.Negative;
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x4B, Mode = Immediate, Cycles = 2)]
|
||||
private void ALR()
|
||||
{
|
||||
A &= AddressRead();
|
||||
F.Carry = (A & 0x1) > 0;
|
||||
A >>= 1;
|
||||
_F(A);
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0x6B, Mode = Immediate, Cycles = 2)]
|
||||
private void ARR()
|
||||
{
|
||||
A &= AddressRead();
|
||||
bool c = F.Carry;
|
||||
F.Carry = (A & 0x1) > 0;
|
||||
A >>= 1;
|
||||
if (c) A |= 0x80;
|
||||
_F(A);
|
||||
}
|
||||
|
||||
[OpCodeDef(OpCode = 0xAB, Mode = Immediate, Cycles = 2)]
|
||||
private void ATX()
|
||||
{
|
||||
// This opcode ORs the A register with #$EE, ANDs the result with an immediate
|
||||
// value, and then stores the result in both A and X.
|
||||
A |= ReadByte(0xEE);
|
||||
A &= AddressRead();
|
||||
X = A;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cae8846694d75f04a8214a484032d533
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
165
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.Memory.cs
Normal file
165
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.Memory.cs
Normal file
@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using static AxibugEmuOnline.Client.UNES.CPU.AddressingMode;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
sealed partial class CPU
|
||||
{
|
||||
public enum AddressingMode
|
||||
{
|
||||
None,
|
||||
Direct,
|
||||
Immediate,
|
||||
ZeroPage,
|
||||
Absolute,
|
||||
ZeroPageX,
|
||||
ZeroPageY,
|
||||
AbsoluteX,
|
||||
AbsoluteY,
|
||||
IndirectX,
|
||||
IndirectY
|
||||
}
|
||||
|
||||
private uint? _currentMemoryAddress;
|
||||
private uint _rmwValue;
|
||||
|
||||
private void ResetInstructionAddressingMode() => _currentMemoryAddress = null;
|
||||
|
||||
private uint _Address()
|
||||
{
|
||||
var def = _opCodeDefs[_currentInstruction];
|
||||
switch (def.Mode)
|
||||
{
|
||||
case Immediate:
|
||||
return PC++;
|
||||
case ZeroPage:
|
||||
return NextByte();
|
||||
case Absolute:
|
||||
return NextWord();
|
||||
case ZeroPageX:
|
||||
return (NextByte() + X) & 0xFF;
|
||||
case ZeroPageY:
|
||||
return (NextByte() + Y) & 0xFF;
|
||||
case AbsoluteX:
|
||||
var address = NextWord();
|
||||
if (def.PageBoundary && (address & 0xFF00) != ((address + X) & 0xFF00))
|
||||
{
|
||||
Cycle += 1;
|
||||
}
|
||||
|
||||
return address + X;
|
||||
case AbsoluteY:
|
||||
address = NextWord();
|
||||
if (def.PageBoundary && (address & 0xFF00) != ((address + Y) & 0xFF00))
|
||||
{
|
||||
Cycle += 1;
|
||||
}
|
||||
|
||||
return address + Y;
|
||||
case IndirectX:
|
||||
var off = (NextByte() + X) & 0xFF;
|
||||
return ReadByte(off) | (ReadByte((off + 1) & 0xFF) << 8);
|
||||
case IndirectY:
|
||||
off = NextByte() & 0xFF;
|
||||
address = ReadByte(off) | (ReadByte((off + 1) & 0xFF) << 8);
|
||||
if (def.PageBoundary && (address & 0xFF00) != ((address + Y) & 0xFF00))
|
||||
{
|
||||
Cycle += 1;
|
||||
}
|
||||
|
||||
return (address + Y) & 0xFFFF;
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public uint AddressRead()
|
||||
{
|
||||
if (_opCodeDefs[_currentInstruction].Mode == Direct)
|
||||
{
|
||||
return _rmwValue = A;
|
||||
}
|
||||
|
||||
if (_currentMemoryAddress == null)
|
||||
{
|
||||
_currentMemoryAddress = _Address();
|
||||
}
|
||||
|
||||
return _rmwValue = ReadByte((uint)_currentMemoryAddress) & 0xFF;
|
||||
}
|
||||
|
||||
public void AddressWrite(uint val)
|
||||
{
|
||||
if (_opCodeDefs[_currentInstruction].Mode == Direct)
|
||||
{
|
||||
A = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_currentMemoryAddress == null)
|
||||
{
|
||||
_currentMemoryAddress = _Address();
|
||||
}
|
||||
|
||||
if (_opCodeDefs[_currentInstruction].RMW)
|
||||
{
|
||||
WriteByte((uint)_currentMemoryAddress, _rmwValue);
|
||||
}
|
||||
|
||||
WriteByte((uint)_currentMemoryAddress, val);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private uint ReadWord(uint address) => ReadByte(address) | (ReadByte(address + 1) << 8);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private uint NextByte() => ReadByte(PC++);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private uint NextWord() => NextByte() | (NextByte() << 8);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private sbyte NextSByte() => (sbyte)NextByte();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void Push(uint what)
|
||||
{
|
||||
WriteByte(0x100 + SP, what);
|
||||
SP--;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private uint Pop()
|
||||
{
|
||||
SP++;
|
||||
return ReadByte(0x100 + SP);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void PushWord(uint what)
|
||||
{
|
||||
Push(what >> 8);
|
||||
Push(what & 0xFF);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private uint PopWord() => Pop() | (Pop() << 8);
|
||||
|
||||
protected override void InitializeMemoryMap()
|
||||
{
|
||||
base.InitializeMemoryMap();
|
||||
|
||||
MapReadHandler(0x0000, 0x1FFF, address => _ram[address & 0x07FF]);
|
||||
MapReadHandler(0x2000, 0x3FFF, address => _emulator.PPU.ReadRegister((address & 0x7) - 0x2000));
|
||||
MapReadHandler(0x4000, 0x4017, ReadIORegister);
|
||||
|
||||
MapWriteHandler(0x0000, 0x1FFF, (address, val) => _ram[address & 0x07FF] = val);
|
||||
MapWriteHandler(0x2000, 0x3FFF, (address, val) => _emulator.PPU.WriteRegister((address & 0x7) - 0x2000, val));
|
||||
MapWriteHandler(0x4000, 0x401F, WriteIoRegister);
|
||||
|
||||
_emulator.Mapper.InitializeMemoryMap(this);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc18416f50415b74e96092e235a95f92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
89
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.Registers.cs
Normal file
89
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.Registers.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
sealed partial class CPU
|
||||
{
|
||||
private const int CarryBit = 0x1;
|
||||
private const int ZeroBit = 0x2;
|
||||
private const int InterruptDisabledBit = 0x4;
|
||||
private const int DecimalModeBit = 0x8;
|
||||
private const int BreakSourceBit = 0x10;
|
||||
private const int OverflowBit = 0x40;
|
||||
private const int NegativeBit = 0x80;
|
||||
|
||||
public class CPUFlags
|
||||
{
|
||||
public bool Negative;
|
||||
public bool Overflow;
|
||||
public bool BreakSource;
|
||||
public bool DecimalMode;
|
||||
public bool InterruptsDisabled;
|
||||
public bool Zero;
|
||||
public bool Carry;
|
||||
}
|
||||
|
||||
public readonly CPUFlags F = new CPUFlags();
|
||||
|
||||
public uint _A, _X, _Y, _SP;
|
||||
public uint PC;
|
||||
|
||||
public uint A
|
||||
{
|
||||
get => _A;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private set => _A = _F(value & 0xFF);
|
||||
}
|
||||
|
||||
public uint X
|
||||
{
|
||||
get => _X;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private set => _X = _F(value & 0xFF);
|
||||
}
|
||||
|
||||
public uint Y
|
||||
{
|
||||
get => _Y;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private set => _Y = _F(value & 0xFF);
|
||||
}
|
||||
|
||||
public uint SP
|
||||
{
|
||||
get => _SP;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private set => _SP = value & 0xFF;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private uint _F(uint val)
|
||||
{
|
||||
F.Zero = (val & 0xFF) == 0;
|
||||
F.Negative = (val & 0x80) > 0;
|
||||
return val;
|
||||
}
|
||||
|
||||
public uint P
|
||||
{
|
||||
get => (uint) ((F.Carry.AsByte() << 0) |
|
||||
(F.Zero.AsByte() << 1) |
|
||||
(F.InterruptsDisabled.AsByte() << 2) |
|
||||
(F.DecimalMode.AsByte() << 3) |
|
||||
(F.BreakSource.AsByte() << 4) |
|
||||
(1 << 5) |
|
||||
(F.Overflow.AsByte() << 6) |
|
||||
(F.Negative.AsByte() << 7));
|
||||
set
|
||||
{
|
||||
F.Carry = (value & CarryBit) > 0;
|
||||
F.Zero = (value & ZeroBit) > 0;
|
||||
F.InterruptsDisabled = (value & InterruptDisabledBit) > 0;
|
||||
F.DecimalMode = (value & DecimalModeBit) > 0;
|
||||
F.BreakSource = (value & BreakSourceBit) > 0;
|
||||
F.Overflow = (value & OverflowBit) > 0;
|
||||
F.Negative = (value & NegativeBit) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57750595bb8e0d24babf00d51e4624bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
65
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.cs
Normal file
65
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
sealed partial class CPU : Addressable
|
||||
{
|
||||
private readonly byte[] _ram = new byte[0x800];
|
||||
public int Cycle;
|
||||
private uint _currentInstruction;
|
||||
|
||||
public delegate void OpCode();
|
||||
|
||||
private readonly OpCode[] _opCodes = new OpCode[256];
|
||||
private readonly string[] _opCodeNames = new string[256];
|
||||
private readonly OpCodeDef[] _opCodeDefs = new OpCodeDef[256];
|
||||
|
||||
public CPU(Emulator emulator) : base(emulator, 0xFFFF)
|
||||
{
|
||||
InitializeOpCodes();
|
||||
InitializeMemoryMap();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void InitializeOpCodes()
|
||||
{
|
||||
var opCodeBindings = from opCode in GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
|
||||
let defs = opCode.GetCustomAttributes(typeof(OpCodeDef), false)
|
||||
where defs.Length > 0
|
||||
select new
|
||||
{
|
||||
binding = (OpCode)Delegate.CreateDelegate(typeof(OpCode), this, opCode.Name),
|
||||
name = opCode.Name,
|
||||
defs = (from d in defs select (OpCodeDef)d)
|
||||
};
|
||||
|
||||
foreach (var opCode in opCodeBindings)
|
||||
{
|
||||
foreach (var def in opCode.defs)
|
||||
{
|
||||
_opCodes[def.OpCode] = opCode.binding;
|
||||
_opCodeNames[def.OpCode] = opCode.name;
|
||||
_opCodeDefs[def.OpCode] = def;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
for (var i = 0; i < 5000; i++)
|
||||
{
|
||||
ExecuteSingleInstruction();
|
||||
}
|
||||
|
||||
uint w;
|
||||
ushort x = 6000;
|
||||
string z = "";
|
||||
while ((w = ReadByte(x)) != '\0')
|
||||
{
|
||||
z += (char)w;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Core/CPU.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa724afa42498dd4e80f44c3da2a5881
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
66
AxibugEmuOnline.Client/Assets/Runtime/Core/Cartridge.cs
Normal file
66
AxibugEmuOnline.Client/Assets/Runtime/Core/Cartridge.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
public class Cartridge
|
||||
{
|
||||
public readonly byte[] Raw;
|
||||
public readonly int PRGROMSize;
|
||||
public readonly int CHRROMSize;
|
||||
public readonly int PRGRAMSize;
|
||||
public readonly int PRGROMOffset;
|
||||
public readonly int MapperNumber;
|
||||
public readonly byte[] PRGROM;
|
||||
public readonly byte[] CHRROM;
|
||||
public VRAMMirroringMode MirroringMode;
|
||||
|
||||
public enum VRAMMirroringMode
|
||||
{
|
||||
Horizontal, Vertical, All, Upper, Lower
|
||||
}
|
||||
|
||||
public Cartridge(byte[] bytes)
|
||||
{
|
||||
Raw = bytes;
|
||||
|
||||
var header = BitConverter.ToInt32(Raw, 0);
|
||||
if (header != 0x1A53454E) // "NES<EOF>"
|
||||
{
|
||||
throw new FormatException("unexpected header value " + header.ToString("X"));
|
||||
}
|
||||
|
||||
PRGROMSize = Raw[4] * 0x4000; // 16kb units
|
||||
CHRROMSize = Raw[5] * 0x2000; // 8kb units
|
||||
PRGRAMSize = Raw[8] * 0x2000;
|
||||
|
||||
var hasTrainer = (Raw[6] & 0b100) > 0;
|
||||
PRGROMOffset = 16 + (hasTrainer ? 512 : 0);
|
||||
|
||||
MirroringMode = (Raw[6] & 0x1) > 0 ? VRAMMirroringMode.Vertical : VRAMMirroringMode.Horizontal;
|
||||
if ((Raw[6] & 0x8) > 0)
|
||||
{
|
||||
MirroringMode = VRAMMirroringMode.All;
|
||||
}
|
||||
|
||||
MapperNumber = (Raw[6] >> 4) | (Raw[7] & 0xF0);
|
||||
|
||||
PRGROM = new byte[PRGROMSize];
|
||||
Array.Copy(Raw, PRGROMOffset, PRGROM, 0, PRGROMSize);
|
||||
|
||||
if (CHRROMSize == 0)
|
||||
{
|
||||
CHRROM = new byte[0x2000];
|
||||
}
|
||||
else
|
||||
{
|
||||
CHRROM = new byte[CHRROMSize];
|
||||
Array.Copy(Raw, PRGROMOffset + PRGROMSize, CHRROM, 0, CHRROMSize);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Cartridge{{PRGROMSize={PRGROMSize}, CHRROMSize={CHRROMSize}, PRGROMOffset={PRGROMOffset}, MapperNumber={MapperNumber}}}";
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Core/Cartridge.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Core/Cartridge.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b45675095efbb224cad44ee16c2587ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
44
AxibugEmuOnline.Client/Assets/Runtime/Core/Emulator.cs
Normal file
44
AxibugEmuOnline.Client/Assets/Runtime/Core/Emulator.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using AxibugEmuOnline.Client.UNES.Controller;
|
||||
using AxibugEmuOnline.Client.UNES.Mapper;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
public class Emulator
|
||||
{
|
||||
private static readonly Dictionary<int, KeyValuePair<Type, MapperDef>> Mappers = (from type in Assembly.GetExecutingAssembly().GetTypes()
|
||||
let def = (MapperDef)type.GetCustomAttributes(typeof(MapperDef), true).FirstOrDefault()
|
||||
where def != null
|
||||
select new { def, type }).ToDictionary(a => a.def.Id, a => new KeyValuePair<Type, MapperDef>(a.type, a.def));
|
||||
|
||||
public IController Controller;
|
||||
|
||||
public readonly CPU CPU;
|
||||
|
||||
public readonly PPU PPU;
|
||||
|
||||
public readonly BaseMapper Mapper;
|
||||
|
||||
public readonly Cartridge Cartridge;
|
||||
|
||||
public Emulator(byte[] bytes, IController controller)
|
||||
{
|
||||
Cartridge = new Cartridge(bytes);
|
||||
if (!Mappers.ContainsKey(Cartridge.MapperNumber))
|
||||
{
|
||||
throw new NotImplementedException($"unsupported mapper {Cartridge.MapperNumber}");
|
||||
}
|
||||
|
||||
Mapper = (BaseMapper)Activator.CreateInstance(Mappers[Cartridge.MapperNumber].Key, this);
|
||||
CPU = new CPU(this);
|
||||
PPU = new PPU(this);
|
||||
Controller = controller;
|
||||
|
||||
// Load();
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Core/Emulator.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Core/Emulator.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c56d6518f6443745a10dd7dda0ac7f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
394
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.Core.cs
Normal file
394
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.Core.cs
Normal file
@ -0,0 +1,394 @@
|
||||
using System;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
partial class PPU
|
||||
{
|
||||
private const int GameWidth = 256, GameHeight = 240;
|
||||
|
||||
private uint _bufferPos;
|
||||
public readonly uint[] RawBitmap = new uint[GameWidth * GameHeight];
|
||||
//查找表的Idx网络缓存
|
||||
public readonly byte[] RawBitmap_paletteIdxCache = new byte[GameWidth * GameHeight];
|
||||
private readonly uint[] _priority = new uint[GameWidth * GameHeight];
|
||||
|
||||
// TODO: use real chroma/luma decoding
|
||||
private readonly uint[] _palette = {
|
||||
0x7C7C7C, 0x0000FC, 0x0000BC, 0x4428BC, 0x940084, 0xA80020, 0xA81000, 0x881400,
|
||||
0x503000, 0x007800, 0x006800, 0x005800, 0x004058, 0x000000, 0x000000, 0x000000,
|
||||
0xBCBCBC, 0x0078F8, 0x0058F8, 0x6844FC, 0xD800CC, 0xE40058, 0xF83800, 0xE45C10,
|
||||
0xAC7C00, 0x00B800, 0x00A800, 0x00A844, 0x008888, 0x000000, 0x000000, 0x000000,
|
||||
0xF8F8F8, 0x3CBCFC, 0x6888FC, 0x9878F8, 0xF878F8, 0xF85898, 0xF87858, 0xFCA044,
|
||||
0xF8B800, 0xB8F818, 0x58D854, 0x58F898, 0x00E8D8, 0x787878, 0x000000, 0x000000,
|
||||
0xFCFCFC, 0xA4E4FC, 0xB8B8F8, 0xD8B8F8, 0xF8B8F8, 0xF8A4C0, 0xF0D0B0, 0xFCE0A8,
|
||||
0xF8D878, 0xD8F878, 0xB8F8B8, 0xB8F8D8, 0x00FCFC, 0xF8D8F8, 0x000000, 0x000000
|
||||
};
|
||||
|
||||
private int _scanLineCount = 261;
|
||||
private int _cyclesPerLine = 341;
|
||||
private int _cpuSyncCounter;
|
||||
private readonly uint[] _scanLineOAM = new uint[8 * 4];
|
||||
private readonly bool[] _isSprite0 = new bool[8];
|
||||
private int _spriteCount;
|
||||
|
||||
private long _tileShiftRegister;
|
||||
private uint _currentNameTableByte;
|
||||
private uint _currentHighTile, _currentLowTile;
|
||||
private uint _currentColor;
|
||||
|
||||
public void ProcessPixel(int x, int y)
|
||||
{
|
||||
ProcessBackgroundForPixel(x, y);
|
||||
if (F.DrawSprites)
|
||||
{
|
||||
ProcessSpritesForPixel(x, y);
|
||||
}
|
||||
|
||||
if (y != -1)
|
||||
{
|
||||
_bufferPos++;
|
||||
}
|
||||
}
|
||||
|
||||
private void CountSpritesOnLine(int scanLine)
|
||||
{
|
||||
_spriteCount = 0;
|
||||
var height = F.TallSpritesEnabled ? 16 : 8;
|
||||
|
||||
for (var idx = 0; idx < _oam.Length; idx += 4)
|
||||
{
|
||||
var y = _oam[idx] + 1;
|
||||
if (scanLine >= y && scanLine < y + height)
|
||||
{
|
||||
_isSprite0[_spriteCount] = idx == 0;
|
||||
_scanLineOAM[_spriteCount * 4 + 0] = _oam[idx + 0];
|
||||
_scanLineOAM[_spriteCount * 4 + 1] = _oam[idx + 1];
|
||||
_scanLineOAM[_spriteCount * 4 + 2] = _oam[idx + 2];
|
||||
_scanLineOAM[_spriteCount * 4 + 3] = _oam[idx + 3];
|
||||
_spriteCount++;
|
||||
}
|
||||
|
||||
if (_spriteCount == 8)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NextNameTableByte()
|
||||
{
|
||||
_currentNameTableByte = ReadByte(0x2000 | (V & 0x0FFF));
|
||||
}
|
||||
|
||||
private void NextTileByte(bool hi)
|
||||
{
|
||||
var tileIdx = _currentNameTableByte * 16;
|
||||
var address = F.PatternTableAddress + tileIdx + FineY;
|
||||
|
||||
if (hi)
|
||||
{
|
||||
_currentHighTile = ReadByte(address + 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentLowTile = ReadByte(address);
|
||||
}
|
||||
}
|
||||
|
||||
private void NextAttributeByte()
|
||||
{
|
||||
// Bless nesdev
|
||||
var address = 0x23C0 | (V & 0x0C00) | ((V >> 4) & 0x38) | ((V >> 2) & 0x07);
|
||||
_currentColor = (ReadByte(address) >> (int)((CoarseX & 2) | ((CoarseY & 2) << 1))) & 0x3;
|
||||
}
|
||||
|
||||
private void ShiftTileRegister()
|
||||
{
|
||||
for (var x = 0; x < 8; x++)
|
||||
{
|
||||
uint palette = ((_currentHighTile & 0x80) >> 6) | ((_currentLowTile & 0x80) >> 7);
|
||||
_tileShiftRegister |= (palette + _currentColor * 4) << ((7 - x) * 4);
|
||||
_currentLowTile <<= 1;
|
||||
_currentHighTile <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessBackgroundForPixel(int cycle, int scanLine)
|
||||
{
|
||||
if (cycle < 8 && !F.DrawLeftBackground || !F.DrawBackground && scanLine != -1)
|
||||
{
|
||||
// Maximally sketchy: if current address is in the PPU palette, then it draws that palette entry if rendering is disabled
|
||||
// Otherwise, it draws $3F00 (universal bg color)
|
||||
// https://www.romhacking.net/forum/index.php?topic=20554.0
|
||||
// Don't know if any game actually uses it, but a test ROM I wrote unexpectedly showed this
|
||||
// corner case
|
||||
|
||||
//RawBitmap[_bufferPos] = _palette[ReadByte(0x3F00 + ((F.BusAddress & 0x3F00) == 0x3F00 ? F.BusAddress & 0x001F : 0)) & 0x3F];
|
||||
byte pIdx = (byte)(ReadByte(0x3F00 + ((F.BusAddress & 0x3F00) == 0x3F00 ? F.BusAddress & 0x001F : 0)) & 0x3F);
|
||||
//RawBitmap[_bufferPos] = _palette[pIdx];
|
||||
RawBitmap_paletteIdxCache[_bufferPos] = pIdx;
|
||||
return;
|
||||
}
|
||||
|
||||
var paletteEntry = (uint)(_tileShiftRegister >> 32 >> (int)((7 - X) * 4)) & 0x0F;
|
||||
if (paletteEntry % 4 == 0) paletteEntry = 0;
|
||||
|
||||
if (scanLine != -1)
|
||||
{
|
||||
_priority[_bufferPos] = paletteEntry;
|
||||
//RawBitmap[_bufferPos] = _palette[ReadByte(0x3F00u + paletteEntry) & 0x3F];
|
||||
byte pIdx = (byte)(ReadByte(0x3F00u + paletteEntry) & 0x3F);
|
||||
//RawBitmap[_bufferPos] = _palette[pIdx];
|
||||
RawBitmap_paletteIdxCache[_bufferPos] = pIdx;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessSpritesForPixel(int x, int scanLine)
|
||||
{
|
||||
for (var idx = _spriteCount * 4 - 4; idx >= 0; idx -= 4)
|
||||
{
|
||||
var spriteX = _scanLineOAM[idx + 3];
|
||||
var spriteY = _scanLineOAM[idx] + 1;
|
||||
|
||||
// Don't draw this sprite if...
|
||||
if (spriteY == 0 || // it's located at y = 0
|
||||
spriteY > 239 || // it's located past y = 239 ($EF)
|
||||
x >= spriteX + 8 || // it's behind the current dot
|
||||
x < spriteX || // it's ahead of the current dot
|
||||
x < 8 && !F.DrawLeftSprites) // it's in the clip area, and clipping is enabled
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// amusingly enough, the PPU's palette handling is basically identical
|
||||
// to that of the Gameboy / Gameboy Color, so I've sort of just copy/pasted
|
||||
// handling code wholesale from my GBC emulator at
|
||||
// https://github.com/Xyene/Nitrous-Emulator/blob/master/src/main/java/nitrous/lcd/LCD.java#L642
|
||||
var tileIdx = _scanLineOAM[idx + 1];
|
||||
if (F.TallSpritesEnabled)
|
||||
{
|
||||
tileIdx &= ~0x1u;
|
||||
}
|
||||
|
||||
tileIdx *= 16;
|
||||
|
||||
var attribute = _scanLineOAM[idx + 2] & 0xE3;
|
||||
|
||||
var palette = attribute & 0x3;
|
||||
var front = (attribute & 0x20) == 0;
|
||||
var flipX = (attribute & 0x40) > 0;
|
||||
var flipY = (attribute & 0x80) > 0;
|
||||
|
||||
var px = (int) (x - spriteX);
|
||||
var line = (int) (scanLine - spriteY);
|
||||
|
||||
var tableBase = F.TallSpritesEnabled ? (_scanLineOAM[idx + 1] & 1) * 0x1000 : F.SpriteTableAddress;
|
||||
|
||||
if (F.TallSpritesEnabled)
|
||||
{
|
||||
if (line >= 8)
|
||||
{
|
||||
line -= 8;
|
||||
if (!flipY)
|
||||
{
|
||||
tileIdx += 16;
|
||||
}
|
||||
|
||||
flipY = false;
|
||||
}
|
||||
|
||||
if (flipY)
|
||||
{
|
||||
tileIdx += 16;
|
||||
}
|
||||
}
|
||||
|
||||
// here we handle the x and y flipping by tweaking the indices we are accessing
|
||||
var logicalX = flipX ? 7 - px : px;
|
||||
var logicalLine = flipY ? 7 - line : line;
|
||||
|
||||
var address = (uint) (tableBase + tileIdx + logicalLine);
|
||||
|
||||
// this looks bad, but it's about as readable as it's going to get
|
||||
var color = (uint) (
|
||||
(
|
||||
(
|
||||
(
|
||||
// fetch upper bit from 2nd bit plane
|
||||
ReadByte(address + 8) & (0x80 >> logicalX)
|
||||
) >> (7 - logicalX)
|
||||
) << 1 // this is the upper bit of the color number
|
||||
) |
|
||||
(
|
||||
(
|
||||
ReadByte(address) & (0x80 >> logicalX)
|
||||
) >> (7 - logicalX)
|
||||
)); // << 0, this is the lower bit of the color number
|
||||
|
||||
if (color > 0)
|
||||
{
|
||||
var backgroundPixel = _priority[_bufferPos];
|
||||
// Sprite 0 hits...
|
||||
if (!(!_isSprite0[idx / 4] || // do not occur on not-0 sprite
|
||||
x < 8 && !F.DrawLeftSprites || // or if left clipping is enabled
|
||||
backgroundPixel == 0 || // or if bg pixel is transparent
|
||||
F.Sprite0Hit || // or if it fired this frame already
|
||||
x == 255)) // or if x is 255, "for an obscure reason related to the pixel pipeline"
|
||||
{
|
||||
F.Sprite0Hit = true;
|
||||
}
|
||||
|
||||
if (F.DrawBackground && (front || backgroundPixel == 0))
|
||||
{
|
||||
if (scanLine != -1)
|
||||
{
|
||||
//RawBitmap[_bufferPos] = _palette[ReadByte(0x3F10 + palette * 4 + color) & 0x3F];
|
||||
|
||||
byte pIdx = (byte)(ReadByte(0x3F10 + palette * 4 + color) & 0x3F);
|
||||
RawBitmap[_bufferPos] = _palette[pIdx];
|
||||
RawBitmap_paletteIdxCache[_bufferPos] = pIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessFrame()
|
||||
{
|
||||
RawBitmap.Fill(0u);
|
||||
RawBitmap_paletteIdxCache.Fill((byte)0);
|
||||
_priority.Fill(0u);
|
||||
_bufferPos = 0;
|
||||
|
||||
for (var i = -1; i < _scanLineCount; i++)
|
||||
{
|
||||
ProcessScanLine(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessScanLine(int line)
|
||||
{
|
||||
for (var i = 0; i < _cyclesPerLine; i++)
|
||||
{
|
||||
ProcessCycle(line, i);
|
||||
}
|
||||
}
|
||||
|
||||
private int _cpuClocksSinceVBL;
|
||||
private int _ppuClocksSinceVBL;
|
||||
|
||||
public void ProcessCycle(int scanLine, int cycle)
|
||||
{
|
||||
var visibleCycle = 1 <= cycle && cycle <= 256;
|
||||
var prefetchCycle = 321 <= cycle && cycle <= 336;
|
||||
var fetchCycle = visibleCycle || prefetchCycle;
|
||||
|
||||
if (F.VBlankStarted)
|
||||
{
|
||||
_ppuClocksSinceVBL++;
|
||||
}
|
||||
|
||||
if (0 <= scanLine && scanLine < 240 || scanLine == -1)
|
||||
{
|
||||
if (visibleCycle)
|
||||
{
|
||||
ProcessPixel(cycle - 1, scanLine);
|
||||
}
|
||||
|
||||
// During pixels 280 through 304 of this scanline, the vertical scroll bits are reloaded TODO: if rendering is enabled.
|
||||
if (scanLine == -1 && 280 <= cycle && cycle <= 304)
|
||||
{
|
||||
ReloadScrollY();
|
||||
}
|
||||
|
||||
if (fetchCycle)
|
||||
{
|
||||
_tileShiftRegister <<= 4;
|
||||
|
||||
// See https://wiki.nesdev.com/w/images/d/d1/Ntsc_timing.png
|
||||
// Takes 8 cycles for tile to be read, 2 per "step"
|
||||
switch (cycle & 7)
|
||||
{
|
||||
case 1: // NT
|
||||
NextNameTableByte();
|
||||
break;
|
||||
case 3: // AT
|
||||
NextAttributeByte();
|
||||
break;
|
||||
case 5: // Tile low
|
||||
NextTileByte(false);
|
||||
break;
|
||||
case 7: // Tile high
|
||||
NextTileByte(true);
|
||||
break;
|
||||
case 0: // 2nd cycle of tile high fetch
|
||||
if (cycle == 256)
|
||||
IncrementScrollY();
|
||||
else
|
||||
IncrementScrollX();
|
||||
// Begin rendering a brand new tile
|
||||
ShiftTileRegister();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cycle == 257)
|
||||
{
|
||||
ReloadScrollX();
|
||||
// 257 - 320
|
||||
// The tile data for the sprites on the next scanline are fetched here.
|
||||
// TODO: stagger this over all the cycles as opposed to only on 257
|
||||
CountSpritesOnLine(scanLine + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: this is a hack; VBlank should be cleared on dot 1 of the pre-render line,
|
||||
// but for some reason we're at 2272-2273 CPU clocks at that time
|
||||
// (i.e., our PPU timing is off somewhere by 6-9 PPU cycles per frame)
|
||||
if (F.VBlankStarted && _cpuClocksSinceVBL == 2270)
|
||||
{
|
||||
F.VBlankStarted = false;
|
||||
_cpuClocksSinceVBL = 0;
|
||||
}
|
||||
|
||||
if (cycle == 1)
|
||||
{
|
||||
if (scanLine == 241)
|
||||
{
|
||||
F.VBlankStarted = true;
|
||||
if (F.NMIEnabled)
|
||||
{
|
||||
_emulator.CPU.TriggerInterrupt(CPU.InterruptType.NMI);
|
||||
}
|
||||
}
|
||||
|
||||
// Happens at the same time as 1st cycle of NT byte fetch
|
||||
if (scanLine == -1)
|
||||
{
|
||||
// Console.WriteLine(_ppuClocksSinceVBL);
|
||||
_ppuClocksSinceVBL = 0;
|
||||
F.VBlankStarted = false;
|
||||
F.Sprite0Hit = false;
|
||||
F.SpriteOverflow = false;
|
||||
}
|
||||
}
|
||||
|
||||
_emulator.Mapper.ProcessCycle(scanLine, cycle);
|
||||
|
||||
if (_cpuSyncCounter + 1 == 3)
|
||||
{
|
||||
if (F.VBlankStarted)
|
||||
{
|
||||
_cpuClocksSinceVBL++;
|
||||
}
|
||||
|
||||
_emulator.CPU.TickFromPPU();
|
||||
_cpuSyncCounter = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_cpuSyncCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.Core.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.Core.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6d671ac51126cd43981be89a0309422
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
130
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.Memory.cs
Normal file
130
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.Memory.cs
Normal file
@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
partial class PPU
|
||||
{
|
||||
private readonly byte[] _oam = new byte[0x100];
|
||||
private readonly byte[] _vRam = new byte[0x2000];
|
||||
private readonly byte[] _paletteRAM = new byte[0x20];
|
||||
|
||||
private static readonly uint[][] _vRamMirrorLookup =
|
||||
{
|
||||
new uint[]{0, 0, 1, 1}, // H
|
||||
new uint[]{0, 1, 0, 1}, // V
|
||||
new uint[]{0, 1, 2, 3}, // All
|
||||
new uint[]{0, 0, 0, 0}, // Upper
|
||||
new uint[]{1, 1, 1, 1}, // Lower
|
||||
};
|
||||
|
||||
private int _lastWrittenRegister;
|
||||
|
||||
public void WriteRegister(uint reg, byte val)
|
||||
{
|
||||
reg &= 0xF;
|
||||
_lastWrittenRegister = val & 0xFF;
|
||||
switch (reg)
|
||||
{
|
||||
case 0x0000:
|
||||
PPUCTRL = val;
|
||||
return;
|
||||
case 0x0001:
|
||||
PPUMASK = val;
|
||||
return;
|
||||
case 0x0002: return;
|
||||
case 0x0003:
|
||||
OAMADDR = val;
|
||||
return;
|
||||
case 0x0004:
|
||||
OAMDATA = val;
|
||||
return;
|
||||
case 0x005:
|
||||
PPUSCROLL = val;
|
||||
return;
|
||||
case 0x0006:
|
||||
PPUADDR = val;
|
||||
return;
|
||||
case 0x0007:
|
||||
PPUDATA = val;
|
||||
return;
|
||||
}
|
||||
|
||||
throw new NotImplementedException($"{reg:X4} = {val:X2}");
|
||||
}
|
||||
|
||||
public byte ReadRegister(uint reg)
|
||||
{
|
||||
reg &= 0xF;
|
||||
switch (reg)
|
||||
{
|
||||
case 0x0000: return (byte)_lastWrittenRegister;
|
||||
case 0x0001: return (byte)_lastWrittenRegister;
|
||||
case 0x0002:
|
||||
return (byte)PPUSTATUS;
|
||||
case 0x0003:
|
||||
return (byte)OAMADDR;
|
||||
case 0x0004:
|
||||
return (byte)OAMDATA;
|
||||
case 0x0005: return (byte)_lastWrittenRegister;
|
||||
case 0x0006: return (byte)_lastWrittenRegister;
|
||||
case 0x0007:
|
||||
return (byte)PPUDATA;
|
||||
}
|
||||
throw new NotImplementedException(reg.ToString("X2"));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint GetVRamMirror(long address)
|
||||
{
|
||||
long entry;
|
||||
var table = Math.DivRem(address - 0x2000, 0x400, out entry);
|
||||
return _vRamMirrorLookup[(int)_emulator.Cartridge.MirroringMode][table] * 0x400 + (uint)entry;
|
||||
}
|
||||
|
||||
protected override void InitializeMemoryMap()
|
||||
{
|
||||
base.InitializeMemoryMap();
|
||||
|
||||
MapReadHandler(0x2000, 0x2FFF, address => _vRam[GetVRamMirror(address)]);
|
||||
MapReadHandler(0x3000, 0x3EFF, address => _vRam[GetVRamMirror(address - 0x1000)]);
|
||||
MapReadHandler(0x3F00, 0x3FFF, address =>
|
||||
{
|
||||
if (address == 0x3F10 || address == 0x3F14 || address == 0x3F18 || address == 0x3F0C)
|
||||
{
|
||||
address -= 0x10;
|
||||
}
|
||||
|
||||
return _paletteRAM[(address - 0x3F00) & 0x1F];
|
||||
});
|
||||
|
||||
MapWriteHandler(0x2000, 0x2FFF, (address, val) => _vRam[GetVRamMirror(address)] = val);
|
||||
MapWriteHandler(0x3000, 0x3EFF, (address, val) => _vRam[GetVRamMirror(address - 0x1000)] = val);
|
||||
MapWriteHandler(0x3F00, 0x3FFF, (address, val) =>
|
||||
{
|
||||
if (address == 0x3F10 || address == 0x3F14 || address == 0x3F18 || address == 0x3F0C)
|
||||
{
|
||||
address -= 0x10;
|
||||
}
|
||||
|
||||
_paletteRAM[(address - 0x3F00) & 0x1F] = val;
|
||||
});
|
||||
|
||||
_emulator.Mapper.InitializeMemoryMap(this);
|
||||
}
|
||||
|
||||
public void PerformDMA(uint from)
|
||||
{
|
||||
//Console.WriteLine("OAM DMA");
|
||||
from <<= 8;
|
||||
for (uint i = 0; i <= 0xFF; i++)
|
||||
{
|
||||
_oam[F.OAMAddress] = (byte)_emulator.CPU.ReadByte(from);
|
||||
from++;
|
||||
F.OAMAddress++;
|
||||
}
|
||||
|
||||
_emulator.CPU.Cycle += 513 + _emulator.CPU.Cycle % 2;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa442177f52c5ff4a805fb4e1a30703b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
261
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.Registers.cs
Normal file
261
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.Registers.cs
Normal file
@ -0,0 +1,261 @@
|
||||
using System;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
partial class PPU
|
||||
{
|
||||
public class PPUFlags
|
||||
{
|
||||
/* PPUCTRL register */
|
||||
public bool NMIEnabled;
|
||||
public bool IsMaster;
|
||||
public bool TallSpritesEnabled;
|
||||
public uint PatternTableAddress;
|
||||
public uint SpriteTableAddress;
|
||||
public uint VRAMIncrement;
|
||||
|
||||
/* PPUMASK register */
|
||||
public bool GrayscaleEnabled;
|
||||
public bool DrawLeftBackground;
|
||||
public bool DrawLeftSprites;
|
||||
public bool DrawBackground;
|
||||
public bool DrawSprites;
|
||||
// Flipped for PAL/Dendy
|
||||
public bool EmphasizeRed;
|
||||
public bool EmphasizeGreen;
|
||||
public bool EmphasizeBlue;
|
||||
|
||||
/* PPUSTATUS register */
|
||||
public bool VBlankStarted;
|
||||
public bool Sprite0Hit;
|
||||
public bool SpriteOverflow;
|
||||
public bool AddressLatch;
|
||||
|
||||
/* PPUADDR register */
|
||||
private uint _busAddress;
|
||||
public uint BusAddress
|
||||
{
|
||||
get => _busAddress;
|
||||
set => _busAddress = value & 0x3FFF;
|
||||
}
|
||||
|
||||
/* PPUDATA register */
|
||||
public uint BusData;
|
||||
|
||||
/* OAMADDR register */
|
||||
private uint _oamAddress;
|
||||
public uint OAMAddress
|
||||
{
|
||||
get => _oamAddress;
|
||||
set => _oamAddress = value & 0xFF;
|
||||
}
|
||||
|
||||
/* PPUSCROLL registers */
|
||||
[Obsolete]
|
||||
public uint ScrollX;
|
||||
[Obsolete]
|
||||
public uint ScrollY;
|
||||
|
||||
public bool RenderingEnabled => DrawBackground || DrawSprites;
|
||||
}
|
||||
|
||||
public PPUFlags F = new PPUFlags();
|
||||
|
||||
private uint _v;
|
||||
public uint V
|
||||
{
|
||||
get => _v;
|
||||
set => _v = value & 0x7FFF;
|
||||
}
|
||||
public uint T, X;
|
||||
|
||||
public uint CoarseX => V & 0x1F;
|
||||
|
||||
public uint CoarseY => (V >> 5) & 0x1F;
|
||||
|
||||
public uint FineY => (V >> 12) & 0x7;
|
||||
|
||||
public void ReloadScrollX() => V = (V & 0xFBE0) | (T & 0x041F);
|
||||
|
||||
public void ReloadScrollY() => V = (V & 0x841F) | (T & 0x7BE0);
|
||||
|
||||
public void IncrementScrollX()
|
||||
{
|
||||
if ((V & 0x001F) == 31) // if coarse X == 31
|
||||
{
|
||||
V &= ~0x001Fu; // coarse X = 0
|
||||
V ^= 0x0400; // switch horizontal nametable
|
||||
}
|
||||
else
|
||||
{
|
||||
V += 1; // increment coarse X
|
||||
}
|
||||
}
|
||||
|
||||
public void IncrementScrollY()
|
||||
{
|
||||
if ((V & 0x7000) != 0x7000) // if fine Y < 7
|
||||
{
|
||||
V += 0x1000; // increment fine Y
|
||||
}
|
||||
else
|
||||
{
|
||||
V &= ~0x7000u; // fine Y = 0
|
||||
|
||||
uint y = (V & 0x03E0) >> 5; // let y = coarse Y
|
||||
if (y == 29)
|
||||
{
|
||||
y = 0; // coarse Y = 0
|
||||
V ^= 0x0800;
|
||||
}
|
||||
// switch vertical nametable
|
||||
else if (y == 31)
|
||||
{
|
||||
y = 0; // coarse Y = 0, nametable not switched
|
||||
}
|
||||
else
|
||||
{
|
||||
y += 1; // increment coarse Y
|
||||
}
|
||||
|
||||
V = (V & ~0x03E0u) | (y << 5); // put coarse Y back into v
|
||||
}
|
||||
}
|
||||
|
||||
public uint PPUCTRL
|
||||
{
|
||||
set
|
||||
{
|
||||
F.NMIEnabled = (value & 0x80) > 0;
|
||||
F.IsMaster = (value & 0x40) > 0;
|
||||
F.TallSpritesEnabled = (value & 0x20) > 0;
|
||||
F.PatternTableAddress = (value & 0x10) > 0 ? 0x1000u : 0x0000;
|
||||
F.SpriteTableAddress = (value & 0x08) > 0 ? 0x1000u : 0x0000;
|
||||
F.VRAMIncrement = (value & 0x04) > 0 ? 32u : 1;
|
||||
// yyy NN YYYYY XXXXX
|
||||
// ||| || ||||| +++++--coarse X scroll
|
||||
// ||| || +++++--------coarse Y scroll
|
||||
// ||| ++--------------nametable select
|
||||
// +++-----------------fine Y scroll
|
||||
T = (T & 0xF3FF) | ((value & 0x3) << 10); // Bits 10-11 hold the base address of the nametable minus $2000
|
||||
}
|
||||
}
|
||||
|
||||
public uint PPUMASK
|
||||
{
|
||||
set
|
||||
{
|
||||
F.GrayscaleEnabled = (value & 0x1) > 0;
|
||||
F.DrawLeftBackground = (value & 0x2) > 0;
|
||||
F.DrawLeftSprites = (value & 0x4) > 0;
|
||||
F.DrawBackground = (value & 0x8) > 0;
|
||||
F.DrawSprites = (value & 0x10) > 0;
|
||||
F.EmphasizeRed = (value & 0x20) > 0;
|
||||
F.EmphasizeGreen = (value & 0x40) > 0;
|
||||
F.EmphasizeBlue = (value & 0x80) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** $2002 **/
|
||||
public uint PPUSTATUS
|
||||
{
|
||||
get
|
||||
{
|
||||
F.AddressLatch = false;
|
||||
var ret = (F.VBlankStarted.AsByte() << 7) |
|
||||
(F.Sprite0Hit.AsByte() << 6) |
|
||||
(F.SpriteOverflow.AsByte() << 5) |
|
||||
(_lastWrittenRegister & 0x1F);
|
||||
F.VBlankStarted = false;
|
||||
return (uint)ret;
|
||||
}
|
||||
}
|
||||
|
||||
/** $2006 **/
|
||||
public uint PPUADDR
|
||||
{
|
||||
set
|
||||
{
|
||||
if (F.AddressLatch)
|
||||
{
|
||||
T = (T & 0xFF00) | value;
|
||||
F.BusAddress = T;
|
||||
V = T;
|
||||
}
|
||||
else
|
||||
{
|
||||
T = (T & 0x80FF) | ((value & 0x3F) << 8);
|
||||
}
|
||||
|
||||
F.AddressLatch ^= true;
|
||||
}
|
||||
}
|
||||
|
||||
/** $2005 **/
|
||||
public uint PPUSCROLL
|
||||
{
|
||||
set
|
||||
{
|
||||
if (F.AddressLatch)
|
||||
{
|
||||
F.ScrollY = value;
|
||||
T = (T & 0x8FFF) | ((value & 0x7) << 12);
|
||||
T = (T & 0xFC1F) | (value & 0xF8) << 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
F.ScrollX = value;
|
||||
X = value & 0x7;
|
||||
T = (T & 0xFFE0) | (value >> 3);
|
||||
}
|
||||
|
||||
F.AddressLatch ^= true;
|
||||
}
|
||||
}
|
||||
|
||||
private uint _readBuffer;
|
||||
public uint PPUDATA
|
||||
{
|
||||
get
|
||||
{
|
||||
uint ret = ReadByte(F.BusAddress);
|
||||
if (F.BusAddress < 0x3F00)
|
||||
{
|
||||
uint temp = _readBuffer;
|
||||
_readBuffer = ret;
|
||||
ret = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Palette read should also read VRAM into read buffer
|
||||
_readBuffer = ReadByte(F.BusAddress - 0x1000);
|
||||
}
|
||||
|
||||
F.BusAddress += F.VRAMIncrement;
|
||||
return ret;
|
||||
}
|
||||
set
|
||||
{
|
||||
F.BusData = value;
|
||||
WriteByte(F.BusAddress, value);
|
||||
F.BusAddress += F.VRAMIncrement;
|
||||
}
|
||||
}
|
||||
|
||||
public uint OAMADDR
|
||||
{
|
||||
get => F.OAMAddress;
|
||||
set => F.OAMAddress = value;
|
||||
}
|
||||
|
||||
public uint OAMDATA
|
||||
{
|
||||
get => _oam[F.OAMAddress];
|
||||
set
|
||||
{
|
||||
_oam[F.OAMAddress] = (byte)value;
|
||||
F.OAMAddress++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0db554be3f472c940bde6ce34fc9ed7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
10
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.cs
Normal file
10
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
public sealed partial class PPU : Addressable
|
||||
{
|
||||
public PPU(Emulator emulator) : base(emulator, 0x3FFF)
|
||||
{
|
||||
InitializeMemoryMap();
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Core/PPU.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd14757720b242e4b92425c9d6aae16a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
35
AxibugEmuOnline.Client/Assets/Runtime/Core/Utility.cs
Normal file
35
AxibugEmuOnline.Client/Assets/Runtime/Core/Utility.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES
|
||||
{
|
||||
public static class Utility
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static byte AsByte(this bool to)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
var result = *((byte*) &to);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Fill<T>(this T[] arr, T value)
|
||||
{
|
||||
for (var i = 0; i < arr.Length; i++)
|
||||
{
|
||||
arr[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Map<T>(this IEnumerable<T> enumerator, Action<T> go)
|
||||
{
|
||||
foreach (var e in enumerator)
|
||||
{
|
||||
go(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Core/Utility.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Core/Utility.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b326828d1b42abc419d9fe125eed8205
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
AxibugEmuOnline.Client/Assets/Runtime/Input.meta
Normal file
8
AxibugEmuOnline.Client/Assets/Runtime/Input.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d2ce2c96b7d7ad4cb099e5ce0ea885d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
AxibugEmuOnline.Client/Assets/Runtime/Input/BaseInput.cs
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Input/BaseInput.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES.Input
|
||||
{
|
||||
public abstract class BaseInput
|
||||
{
|
||||
public abstract void HandlerKeyDown(Action<KeyCode> onKeyDown);
|
||||
public abstract void HandlerKeyUp(Action<KeyCode> onKeyUp);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b60ded3f5a662a14a8a50795bae8121b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
49
AxibugEmuOnline.Client/Assets/Runtime/Input/DefaultInput.cs
Normal file
49
AxibugEmuOnline.Client/Assets/Runtime/Input/DefaultInput.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES.Input
|
||||
{
|
||||
public class DefaultInput : BaseInput
|
||||
{
|
||||
private KeyCode[] _keyCodes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_keyCodeCache == null)
|
||||
{
|
||||
var array = Enum.GetValues(typeof(KeyCode));
|
||||
_keyCodeCache = new KeyCode[array.Length];
|
||||
for (var i = 0; i < array.Length; i++)
|
||||
{
|
||||
_keyCodeCache[i] = (KeyCode)array.GetValue(i);
|
||||
}
|
||||
}
|
||||
|
||||
return _keyCodeCache;
|
||||
}
|
||||
}
|
||||
private KeyCode[] _keyCodeCache;
|
||||
|
||||
public override void HandlerKeyDown(Action<KeyCode> onKeyDown)
|
||||
{
|
||||
foreach (var keyCode in _keyCodes)
|
||||
{
|
||||
if (UnityEngine.Input.GetKeyDown(keyCode))
|
||||
{
|
||||
onKeyDown(keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void HandlerKeyUp(Action<KeyCode> onKeyUp)
|
||||
{
|
||||
foreach (var keyCode in _keyCodes)
|
||||
{
|
||||
if (UnityEngine.Input.GetKeyUp(keyCode))
|
||||
{
|
||||
onKeyUp(keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 028fda8a78366f347b421062b3604d20
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
AxibugEmuOnline.Client/Assets/Runtime/Mapper.meta
Normal file
8
AxibugEmuOnline.Client/Assets/Runtime/Mapper.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d22acc98b0a7fa042bb19b9894899fb7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
AxibugEmuOnline.Client/Assets/Runtime/Mapper/AxROM.cs
Normal file
26
AxibugEmuOnline.Client/Assets/Runtime/Mapper/AxROM.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using static AxibugEmuOnline.Client.UNES.Cartridge.VRAMMirroringMode;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(7)]
|
||||
public class AxROM : BaseMapper
|
||||
{
|
||||
protected int _bankOffset;
|
||||
private readonly Cartridge.VRAMMirroringMode[] _mirroringModes = { Lower, Upper };
|
||||
|
||||
public AxROM(Emulator emulator) : base(emulator)
|
||||
{
|
||||
_emulator.Cartridge.MirroringMode = _mirroringModes[0];
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
cpu.MapReadHandler(0x8000, 0xFFFF, address => _prgROM[_bankOffset + (address - 0x8000)]);
|
||||
cpu.MapWriteHandler(0x8000, 0xFFFF, (address, val) =>
|
||||
{
|
||||
_bankOffset = (val & 0x7) * 0x8000;
|
||||
_emulator.Cartridge.MirroringMode = _mirroringModes[(val >> 4) & 0x1];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/AxROM.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/AxROM.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 632b907c0f30abb47b218545e40ff06d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
67
AxibugEmuOnline.Client/Assets/Runtime/Mapper/BaseMapper.cs
Normal file
67
AxibugEmuOnline.Client/Assets/Runtime/Mapper/BaseMapper.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
public class MapperDef : Attribute
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
public string Description;
|
||||
|
||||
public MapperDef()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MapperDef(int id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseMapper
|
||||
{
|
||||
protected readonly Emulator _emulator;
|
||||
protected readonly byte[] _prgROM;
|
||||
protected readonly byte[] _prgRAM = new byte[0x2000];
|
||||
protected readonly byte[] _chrROM;
|
||||
protected readonly uint _lastBankOffset;
|
||||
|
||||
protected BaseMapper(Emulator emulator)
|
||||
{
|
||||
_emulator = emulator;
|
||||
var cart = emulator.Cartridge;
|
||||
_prgROM = cart.PRGROM;
|
||||
_chrROM = cart.CHRROM;
|
||||
_lastBankOffset = (uint) _prgROM.Length - 0x4000;
|
||||
}
|
||||
|
||||
public virtual void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void InitializeMemoryMap(PPU ppu)
|
||||
{
|
||||
ppu.MapReadHandler(0x0000, 0x1FFF, address => _chrROM[address]);
|
||||
ppu.MapWriteHandler(0x0000, 0x1FFF, (address, val) => _chrROM[address] = val);
|
||||
}
|
||||
|
||||
public virtual void ProcessCycle(int scanLine, int cycle)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual byte[] GetSaveData()
|
||||
{
|
||||
return _prgRAM;
|
||||
}
|
||||
|
||||
public virtual void LoadSaveData(byte[] saveData)
|
||||
{
|
||||
Array.Copy(saveData, _prgRAM, saveData.Length);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a468573a1ef266542a055638aeef33cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
AxibugEmuOnline.Client/Assets/Runtime/Mapper/CNROM.cs
Normal file
32
AxibugEmuOnline.Client/Assets/Runtime/Mapper/CNROM.cs
Normal file
@ -0,0 +1,32 @@
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(3)]
|
||||
public class CNROM : BaseMapper
|
||||
{
|
||||
protected int _bankOffset;
|
||||
|
||||
public CNROM(Emulator emulator) : base(emulator)
|
||||
{
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(PPU ppu)
|
||||
{
|
||||
ppu.MapReadHandler(0x0000, 0x1FFF, address => _chrROM[_bankOffset + address]);
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
if (_prgROM.Length == 0x8000)
|
||||
{
|
||||
cpu.MapReadHandler(0x8000, 0xFFFF, address => _prgROM[address - 0x8000]);
|
||||
}
|
||||
else
|
||||
{
|
||||
cpu.MapReadHandler(0x8000, 0xBFFF, address => _prgROM[address - 0x8000]);
|
||||
cpu.MapReadHandler(0xC000, 0xFFFF, address => _prgROM[address - 0xC000]);
|
||||
}
|
||||
|
||||
cpu.MapWriteHandler(0x8000, 0xFFFF, (address, val) => _bankOffset = (val & 0x3) * 0x2000);
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/CNROM.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/CNROM.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fdaa43625af49e54aacf69d2ed92544f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
27
AxibugEmuOnline.Client/Assets/Runtime/Mapper/Camerica.cs
Normal file
27
AxibugEmuOnline.Client/Assets/Runtime/Mapper/Camerica.cs
Normal file
@ -0,0 +1,27 @@
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(71)]
|
||||
public class Camerica : BaseMapper
|
||||
{
|
||||
protected int _prgBankOffset;
|
||||
|
||||
public Camerica(Emulator emulator) : base(emulator)
|
||||
{
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
cpu.MapReadHandler(0x8000, 0xBFFF, address => _prgROM[_prgBankOffset + (address - 0x8000)]);
|
||||
cpu.MapReadHandler(0xC000, 0xFFFF, address => _prgROM[_prgROM.Length - 0x4000 + (address - 0xC000)]);
|
||||
|
||||
// Actually starts at 0x8000, but use 0x9000 for compatibility w/o submapper
|
||||
cpu.MapWriteHandler(0x9000, 0x9FFF, (address, val) =>
|
||||
{
|
||||
// TODO: Fire Hawk mirroring
|
||||
});
|
||||
|
||||
// The number of bits available vary: 4 for the BF9093, 3 for the BF9097, and 2 for the BF9096.
|
||||
cpu.MapWriteHandler(0xC000, 0xFFFF, (address, val) => _prgBankOffset = (val & 0xF) * 0x4000 % _prgROM.Length);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a879b12017bd97949a00317043b96f54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
AxibugEmuOnline.Client/Assets/Runtime/Mapper/ColorDreams.cs
Normal file
29
AxibugEmuOnline.Client/Assets/Runtime/Mapper/ColorDreams.cs
Normal file
@ -0,0 +1,29 @@
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(11)]
|
||||
public class ColorDreams : BaseMapper
|
||||
{
|
||||
protected int _prgBankOffset;
|
||||
protected int _chrBankOffset;
|
||||
|
||||
public ColorDreams(Emulator emulator) : base(emulator)
|
||||
{
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(PPU ppu)
|
||||
{
|
||||
ppu.MapReadHandler(0x0000, 0x1FFF, address => _chrROM[_chrBankOffset + address]);
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
cpu.MapReadHandler(0x8000, 0xFFFF, address => _prgROM[_prgBankOffset + (address - 0x8000)]);
|
||||
|
||||
cpu.MapWriteHandler(0x8000, 0xFFFF, (address, val) =>
|
||||
{
|
||||
_prgBankOffset = (val & 0x3) * 0x8000;
|
||||
_chrBankOffset = (val >> 4) * 0x2000;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50a4c8ff195db574585c43ba079d8195
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
39
AxibugEmuOnline.Client/Assets/Runtime/Mapper/DxROM.cs
Normal file
39
AxibugEmuOnline.Client/Assets/Runtime/Mapper/DxROM.cs
Normal file
@ -0,0 +1,39 @@
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(206)]
|
||||
public class DxROM : MMC3
|
||||
{
|
||||
public DxROM(Emulator emulator) : base(emulator)
|
||||
{
|
||||
_prgBankingMode = PRGBankingMode.SwitchFix;
|
||||
_chrBankingMode = CHRBankingMode.TwoFour;
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
cpu.MapReadHandler(0x8000, 0xFFFF, address => _prgROM[_prgBankOffsets[(address - 0x8000) / 0x2000] + address % 0x2000]);
|
||||
|
||||
cpu.MapWriteHandler(0x8000, 0x9FFF, (address, val) =>
|
||||
{
|
||||
if ((address & 0x1) == 0)
|
||||
{
|
||||
_currentBank = val & 0x7u;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_currentBank <= 1) val &= 0x1F;
|
||||
else if (_currentBank <= 5) val &= 0x3F;
|
||||
else val &= 0xF;
|
||||
|
||||
_banks[_currentBank] = val;
|
||||
UpdateOffsets();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(PPU ppu)
|
||||
{
|
||||
ppu.MapReadHandler(0x0000, 0x1FFF, address => _chrROM[_chrBankOffsets[address / 0x400] + address % 0x400]);
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/DxROM.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/DxROM.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8ae98e170ab70143bc7284dc01b9627
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
AxibugEmuOnline.Client/Assets/Runtime/Mapper/GxROM.cs
Normal file
29
AxibugEmuOnline.Client/Assets/Runtime/Mapper/GxROM.cs
Normal file
@ -0,0 +1,29 @@
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(66)]
|
||||
public class GxROM : BaseMapper
|
||||
{
|
||||
protected int _prgBankOffset;
|
||||
protected int _chrBankOffset;
|
||||
|
||||
public GxROM(Emulator emulator) : base(emulator)
|
||||
{
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(PPU ppu)
|
||||
{
|
||||
ppu.MapReadHandler(0x0000, 0x1FFF, address => _chrROM[_chrBankOffset + address]);
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
cpu.MapReadHandler(0x8000, 0xFFFF, address => _prgROM[_prgBankOffset + (address - 0x8000)]);
|
||||
|
||||
cpu.MapWriteHandler(0x8000, 0xFFFF, (address, val) =>
|
||||
{
|
||||
_prgBankOffset = ((val >> 4) & 0x3) * 0x8000;
|
||||
_chrBankOffset = (val & 0x3) * 0x2000;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/GxROM.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/GxROM.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a06e1a753215b64886b90ecde825cec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
AxibugEmuOnline.Client/Assets/Runtime/Mapper/Jaleco.cs
Normal file
29
AxibugEmuOnline.Client/Assets/Runtime/Mapper/Jaleco.cs
Normal file
@ -0,0 +1,29 @@
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(140)]
|
||||
public class Jaleco : BaseMapper
|
||||
{
|
||||
protected int _prgBankOffset;
|
||||
protected int _chrBankOffset;
|
||||
|
||||
public Jaleco(Emulator emulator) : base(emulator)
|
||||
{
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(PPU ppu)
|
||||
{
|
||||
ppu.MapReadHandler(0x0000, 0x1FFF, address => _chrROM[_chrBankOffset + address]);
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
cpu.MapReadHandler(0x8000, 0xFFFF, address => _prgROM[_prgBankOffset + (address - 0x8000)]);
|
||||
|
||||
cpu.MapWriteHandler(0x6000, 0x7FFF, (address, val) =>
|
||||
{
|
||||
_prgBankOffset = ((val >> 4) & 0x3) * 0x8000;
|
||||
_chrBankOffset = (val & 0x3) * 0x2000;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/Jaleco.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/Jaleco.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac2f62d216cf70643919c921900c6e70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
170
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC1.cs
Normal file
170
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC1.cs
Normal file
@ -0,0 +1,170 @@
|
||||
using static AxibugEmuOnline.Client.UNES.Cartridge.VRAMMirroringMode;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(1)]
|
||||
public class MMC1 : BaseMapper
|
||||
{
|
||||
// TODO: are MMC1 and MMC1A even different chip types?
|
||||
public enum ChipType { MMC1, MMC1A, MMC1B, MMC1C }
|
||||
public enum CHRBankingMode { Single, Double }
|
||||
public enum PRGBankingMode { Switch32Kb, Switch16KbFixFirst, Switch16KbFixLast }
|
||||
|
||||
private readonly Cartridge.VRAMMirroringMode[] _mirroringModes = { Lower, Upper, Vertical, Horizontal };
|
||||
|
||||
private readonly ChipType _type;
|
||||
private CHRBankingMode _chrBankingMode;
|
||||
private PRGBankingMode _prgBankingMode;
|
||||
|
||||
private uint _serialData;
|
||||
private int _serialPos;
|
||||
|
||||
private uint _control;
|
||||
|
||||
private readonly uint[] _chrBankOffsets = new uint[2];
|
||||
private readonly uint[] _chrBanks = new uint[2];
|
||||
|
||||
private readonly uint[] _prgBankOffsets = new uint[2];
|
||||
private uint _prgBank;
|
||||
|
||||
private bool _prgRAMEnabled;
|
||||
|
||||
private uint? _lastWritePC;
|
||||
|
||||
public MMC1(Emulator emulator) : this(emulator, ChipType.MMC1B)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MMC1(Emulator emulator, ChipType chipType) : base(emulator)
|
||||
{
|
||||
_type = chipType;
|
||||
if (chipType == ChipType.MMC1B) _prgRAMEnabled = true;
|
||||
UpdateControl(0x0F);
|
||||
_emulator.Cartridge.MirroringMode = Horizontal;
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
cpu.MapReadHandler(0x6000, 0x7FFF, address => _prgRAM[address - 0x6000]);
|
||||
cpu.MapReadHandler(0x8000, 0xFFFF, address => _prgROM[_prgBankOffsets[(address - 0x8000) / 0x4000] + address % 0x4000]);
|
||||
|
||||
cpu.MapWriteHandler(0x6000, 0x7FFF, (address, val) =>
|
||||
{
|
||||
// PRG RAM is always enabled on MMC1A
|
||||
if (_type == ChipType.MMC1A || _prgRAMEnabled)
|
||||
_prgRAM[address - 0x6000] = val;
|
||||
});
|
||||
|
||||
cpu.MapWriteHandler(0x8000, 0xFFFF, (address, val) =>
|
||||
{
|
||||
// Explicitly ignore the second write happening on consecutive cycles
|
||||
// of an RMW instruction
|
||||
var cycle = _emulator.CPU.PC;
|
||||
if (cycle == _lastWritePC)
|
||||
return;
|
||||
_lastWritePC = cycle;
|
||||
|
||||
if ((val & 0x80) > 0)
|
||||
{
|
||||
_serialData = 0;
|
||||
_serialPos = 0;
|
||||
UpdateControl(_control | 0x0C);
|
||||
}
|
||||
else
|
||||
{
|
||||
_serialData |= (uint)((val & 0x1) << _serialPos);
|
||||
_serialPos++;
|
||||
|
||||
if (_serialPos == 5)
|
||||
{
|
||||
// Address is incompletely decoded
|
||||
address &= 0x6000;
|
||||
if (address == 0x0000)
|
||||
UpdateControl(_serialData);
|
||||
else if (address == 0x2000)
|
||||
UpdateCHRBank(0, _serialData);
|
||||
else if (address == 0x4000)
|
||||
UpdateCHRBank(1, _serialData);
|
||||
else if (address == 0x6000)
|
||||
UpdatePRGBank(_serialData);
|
||||
|
||||
_serialData = 0;
|
||||
_serialPos = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(PPU ppu)
|
||||
{
|
||||
ppu.MapReadHandler(0x0000, 0x1FFF, address => _chrROM[_chrBankOffsets[address / 0x1000] + address % 0x1000]);
|
||||
ppu.MapWriteHandler(0x0000, 0x1FFF, (address, val) => _chrROM[_chrBankOffsets[address / 0x1000] + address % 0x1000] = val);
|
||||
}
|
||||
|
||||
private void UpdateControl(uint value)
|
||||
{
|
||||
_control = value;
|
||||
|
||||
_emulator.Cartridge.MirroringMode = _mirroringModes[value & 0x3];
|
||||
|
||||
_chrBankingMode = (CHRBankingMode)((value >> 4) & 0x1);
|
||||
|
||||
var prgMode = (value >> 2) & 0x3;
|
||||
// Both 0 and 1 are 32Kb switch
|
||||
if (prgMode == 0) prgMode = 1;
|
||||
_prgBankingMode = (PRGBankingMode)(prgMode - 1);
|
||||
|
||||
UpdateCHRBank(1, _chrBanks[1]);
|
||||
UpdateCHRBank(0, _chrBanks[0]);
|
||||
UpdatePRGBank(_prgBank);
|
||||
}
|
||||
|
||||
private void UpdatePRGBank(uint value)
|
||||
{
|
||||
_prgBank = value;
|
||||
|
||||
_prgRAMEnabled = (value & 0x10) == 0;
|
||||
value &= 0xF;
|
||||
|
||||
switch (_prgBankingMode)
|
||||
{
|
||||
case PRGBankingMode.Switch32Kb:
|
||||
value >>= 1;
|
||||
value *= 0x4000;
|
||||
_prgBankOffsets[0] = value;
|
||||
_prgBankOffsets[1] = value + 0x4000;
|
||||
break;
|
||||
case PRGBankingMode.Switch16KbFixFirst:
|
||||
_prgBankOffsets[0] = 0;
|
||||
_prgBankOffsets[1] = value * 0x4000;
|
||||
break;
|
||||
case PRGBankingMode.Switch16KbFixLast:
|
||||
_prgBankOffsets[0] = value * 0x4000;
|
||||
_prgBankOffsets[1] = _lastBankOffset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCHRBank(uint bank, uint value)
|
||||
{
|
||||
_chrBanks[bank] = value;
|
||||
|
||||
// TODO FIXME: I feel like this branch should only be taken
|
||||
// when bank == 0, but this breaks Final Fantasy
|
||||
// When can banking mode change without UpdateCHRBank being called?
|
||||
if (_chrBankingMode == CHRBankingMode.Single)
|
||||
{
|
||||
value = _chrBanks[0];
|
||||
value >>= 1;
|
||||
value *= 0x1000;
|
||||
_chrBankOffsets[0] = value;
|
||||
_chrBankOffsets[1] = value + 0x1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
_chrBankOffsets[bank] = value * 0x1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC1.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC1.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3ab06f7819df254491a7afa6a82bb43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC2.cs
Normal file
33
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC2.cs
Normal file
@ -0,0 +1,33 @@
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(Id = 9, Description = "Mike Tyson's Punch-Out!!")]
|
||||
public class MMC2 : MMC4
|
||||
{
|
||||
public MMC2(Emulator emulator) : base(emulator)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
base.InitializeMemoryMap(cpu);
|
||||
|
||||
cpu.MapReadHandler(0x8000, 0xBFFF, address => _prgROM[_prgBankOffset + (address - 0x8000)]);
|
||||
cpu.MapReadHandler(0xA000, 0xFFFF, address => _prgROM[_prgROM.Length - 0x4000 - 0x2000 + (address - 0xA000)]);
|
||||
|
||||
cpu.MapWriteHandler(0xA000, 0xAFFF, (address, val) => _prgBankOffset = (val & 0xF) * 0x2000);
|
||||
}
|
||||
|
||||
protected override void GetLatch(uint address, out uint latch, out bool? on)
|
||||
{
|
||||
base.GetLatch(address, out latch, out on);
|
||||
|
||||
// For MMC2, only 0xFD8 and 0xFE8 trigger the latch,
|
||||
// not the whole range like in MMC4
|
||||
if (latch == 0 && (address & 0x3) != 0)
|
||||
{
|
||||
on = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC2.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC2.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 522a51dcf1b92d2498013b4d6f9accb0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
182
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC3.cs
Normal file
182
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC3.cs
Normal file
@ -0,0 +1,182 @@
|
||||
using static AxibugEmuOnline.Client.UNES.Cartridge.VRAMMirroringMode;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(4)]
|
||||
public class MMC3 : BaseMapper
|
||||
{
|
||||
// Different PRG RAM write/enable controls
|
||||
public enum ChipType { MMC3, MMC6 }
|
||||
public enum CHRBankingMode { TwoFour, FourTwo }
|
||||
public enum PRGBankingMode { SwitchFix, FixSwitch }
|
||||
|
||||
private readonly Cartridge.VRAMMirroringMode[] _mirroringModes = { Vertical, Horizontal };
|
||||
|
||||
private readonly ChipType _type;
|
||||
protected CHRBankingMode _chrBankingMode;
|
||||
protected PRGBankingMode _prgBankingMode;
|
||||
|
||||
|
||||
protected readonly uint[] _chrBankOffsets = new uint[8];
|
||||
protected uint[] _prgBankOffsets;
|
||||
protected readonly uint[] _banks = new uint[8];
|
||||
protected uint _currentBank;
|
||||
|
||||
private uint _irqReloadValue;
|
||||
private uint _irqCounter;
|
||||
protected bool _irqEnabled;
|
||||
|
||||
private bool _prgRAMEnabled;
|
||||
|
||||
public MMC3(Emulator emulator) : this(emulator, ChipType.MMC3)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MMC3(Emulator emulator, ChipType chipType) : base(emulator)
|
||||
{
|
||||
_type = chipType;
|
||||
_prgBankOffsets = new uint[] { 0, 0x2000, _lastBankOffset, _lastBankOffset + 0x2000 };
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
cpu.MapReadHandler(0x6000, 0x7FFF, address => _prgRAM[address - 0x6000]);
|
||||
cpu.MapReadHandler(0x8000, 0xFFFF, address => _prgROM[_prgBankOffsets[(address - 0x8000) / 0x2000] + address % 0x2000]);
|
||||
|
||||
cpu.MapWriteHandler(0x6000, 0xFFFF, WriteByte);
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(PPU ppu)
|
||||
{
|
||||
ppu.MapReadHandler(0x0000, 0x1FFF, address => _chrROM[_chrBankOffsets[address / 0x400] + address % 0x400]);
|
||||
ppu.MapWriteHandler(0x0000, 0x1FFF, (address, val) => _chrROM[_chrBankOffsets[address / 0x400] + address % 0x400] = val);
|
||||
}
|
||||
|
||||
public override void ProcessCycle(int scanLine, int cycle)
|
||||
{
|
||||
if (_emulator.PPU.F.RenderingEnabled && cycle == 260 && (0 <= scanLine && scanLine < 240 || scanLine == -1))
|
||||
{
|
||||
if (_irqCounter == 0)
|
||||
{
|
||||
_irqCounter = _irqReloadValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
_irqCounter--;
|
||||
if (_irqEnabled && _irqCounter == 0)
|
||||
{
|
||||
_emulator.CPU.TriggerInterrupt(CPU.InterruptType.IRQ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void WriteByte(uint addr, byte value)
|
||||
{
|
||||
bool even = (addr & 0x1) == 0;
|
||||
|
||||
if (addr < 0x8000)
|
||||
{
|
||||
if (_prgRAMEnabled)
|
||||
{
|
||||
_prgRAM[addr - 0x6000] = value;
|
||||
}
|
||||
}
|
||||
else if (addr < 0xA000)
|
||||
{
|
||||
if (even)
|
||||
{
|
||||
_currentBank = value & 0x7u;
|
||||
_prgBankingMode = (PRGBankingMode)((value >> 6) & 0x1);
|
||||
_chrBankingMode = (CHRBankingMode)((value >> 7) & 0x1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_banks[_currentBank] = value;
|
||||
}
|
||||
|
||||
UpdateOffsets();
|
||||
}
|
||||
else if (addr < 0xC000)
|
||||
{
|
||||
if (even)
|
||||
{
|
||||
_emulator.Cartridge.MirroringMode = _mirroringModes[value & 0x1];
|
||||
}
|
||||
else
|
||||
{
|
||||
_prgRAMEnabled = (value & 0xC0) == 0x80;
|
||||
}
|
||||
}
|
||||
else if (addr < 0xE000)
|
||||
{
|
||||
if (even)
|
||||
{
|
||||
_irqReloadValue = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_irqCounter = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_irqEnabled = !even;
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateOffsets()
|
||||
{
|
||||
switch (_prgBankingMode)
|
||||
{
|
||||
case PRGBankingMode.SwitchFix:
|
||||
_prgBankOffsets[0] = _banks[6] * 0x2000;
|
||||
_prgBankOffsets[1] = _banks[7] * 0x2000;
|
||||
_prgBankOffsets[2] = _lastBankOffset;
|
||||
_prgBankOffsets[3] = _lastBankOffset + 0x2000;
|
||||
break;
|
||||
case PRGBankingMode.FixSwitch:
|
||||
_prgBankOffsets[0] = _lastBankOffset;
|
||||
_prgBankOffsets[1] = _banks[7] * 0x2000;
|
||||
_prgBankOffsets[2] = _banks[6] * 0x2000;
|
||||
_prgBankOffsets[3] = _lastBankOffset + 0x2000;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (_chrBankingMode)
|
||||
{
|
||||
case CHRBankingMode.TwoFour:
|
||||
_chrBankOffsets[0] = _banks[0] & 0xFE;
|
||||
_chrBankOffsets[1] = _banks[0] | 0x01;
|
||||
_chrBankOffsets[2] = _banks[1] & 0xFE;
|
||||
_chrBankOffsets[3] = _banks[1] | 0x01;
|
||||
_chrBankOffsets[4] = _banks[2];
|
||||
_chrBankOffsets[5] = _banks[3];
|
||||
_chrBankOffsets[6] = _banks[4];
|
||||
_chrBankOffsets[7] = _banks[5];
|
||||
break;
|
||||
case CHRBankingMode.FourTwo:
|
||||
_chrBankOffsets[0] = _banks[2];
|
||||
_chrBankOffsets[1] = _banks[3];
|
||||
_chrBankOffsets[2] = _banks[4];
|
||||
_chrBankOffsets[3] = _banks[5];
|
||||
_chrBankOffsets[4] = _banks[0] & 0xFE;
|
||||
_chrBankOffsets[5] = _banks[0] | 0x01;
|
||||
_chrBankOffsets[6] = _banks[1] & 0xFE;
|
||||
_chrBankOffsets[7] = _banks[1] | 0x01;
|
||||
break;
|
||||
}
|
||||
|
||||
for (var i = 0; i < _prgBankOffsets.Length; i++)
|
||||
{
|
||||
_prgBankOffsets[i] %= (uint)_prgROM.Length;
|
||||
}
|
||||
|
||||
for (var i = 0; i < _chrBankOffsets.Length; i++)
|
||||
{
|
||||
_chrBankOffsets[i] = (uint) (_chrBankOffsets[i] * 0x400 % _chrROM.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC3.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC3.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82fb09fbeba58ae458f58e52898fedb1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
73
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC4.cs
Normal file
73
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC4.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using static AxibugEmuOnline.Client.UNES.Cartridge.VRAMMirroringMode;
|
||||
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(10)]
|
||||
public class MMC4 : BaseMapper
|
||||
{
|
||||
protected readonly Cartridge.VRAMMirroringMode[] _mirroringModes = { Vertical, Horizontal };
|
||||
|
||||
protected int _prgBankOffset;
|
||||
protected int[,] _chrBankOffsets = new int[2, 2];
|
||||
protected bool[] _latches = new bool[2];
|
||||
|
||||
public MMC4(Emulator emulator) : base(emulator)
|
||||
{
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
cpu.MapReadHandler(0x6000, 0x7FFF, address => _prgRAM[address - 0x6000]);
|
||||
cpu.MapReadHandler(0x8000, 0xBFFF, address => _prgROM[_prgBankOffset + (address - 0x8000)]);
|
||||
cpu.MapReadHandler(0xC000, 0xFFFF, address => _prgROM[_prgROM.Length - 0x4000 + (address - 0xC000)]);
|
||||
|
||||
cpu.MapWriteHandler(0x6000, 0x7FFF, (address, val) => _prgRAM[address - 0x6000] = val);
|
||||
cpu.MapWriteHandler(0xA000, 0xAFFF, (address, val) => _prgBankOffset = (val & 0xF) * 0x4000);
|
||||
cpu.MapWriteHandler(0xB000, 0xEFFF, (address, val) =>
|
||||
{
|
||||
var bank = (address - 0xB000) / 0x2000;
|
||||
var latch = ((address & 0x1FFF) == 0).AsByte();
|
||||
_chrBankOffsets[bank, latch] = (val & 0x1F) * 0x1000;
|
||||
});
|
||||
|
||||
cpu.MapWriteHandler(0xF000, 0xFFFF, (address, val) => _emulator.Cartridge.MirroringMode = _mirroringModes[val & 0x1]);
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(PPU ppu)
|
||||
{
|
||||
ppu.MapReadHandler(0x0000, 0x1FFF, address =>
|
||||
{
|
||||
var bank = address / 0x1000;
|
||||
var ret = _chrROM[_chrBankOffsets[bank, _latches[bank].AsByte()] + address % 0x1000];
|
||||
if ((address & 0x08) > 0)
|
||||
{
|
||||
GetLatch(address, out uint latch, out bool? on);
|
||||
|
||||
if (on != null)
|
||||
{
|
||||
_latches[latch] = (bool)on;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void GetLatch(uint address, out uint latch, out bool? on)
|
||||
{
|
||||
latch = (address >> 12) & 0x1;
|
||||
on = null;
|
||||
|
||||
address = (address >> 4) & 0xFF;
|
||||
|
||||
if (address == 0xFE)
|
||||
{
|
||||
on = true;
|
||||
}
|
||||
else if (address == 0xFD)
|
||||
{
|
||||
on = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC4.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/MMC4.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54d8f341641616d45b20c65ec4a75ff2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
AxibugEmuOnline.Client/Assets/Runtime/Mapper/Mapper094.cs
Normal file
17
AxibugEmuOnline.Client/Assets/Runtime/Mapper/Mapper094.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(Id = 94, Description = "Senjou no Ookami")]
|
||||
public class Mapper094 : UxROM
|
||||
{
|
||||
public Mapper094(Emulator emulator) : base(emulator)
|
||||
{
|
||||
}
|
||||
|
||||
public override void InitializeMemoryMap(CPU cpu)
|
||||
{
|
||||
base.InitializeMemoryMap(cpu);
|
||||
|
||||
cpu.MapWriteHandler(0x8000, 0xFFFF, (address, val) => _bankOffset = (val & 0x1C) << 12);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0abeb567769f715418ae9125bd029206
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/Mapper155.cs
Normal file
11
AxibugEmuOnline.Client/Assets/Runtime/Mapper/Mapper155.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace AxibugEmuOnline.Client.UNES.Mapper
|
||||
{
|
||||
[MapperDef(Id = 155, Description = "MMC1A")]
|
||||
public class Mapper155 : MMC1
|
||||
{
|
||||
// Mapper for games requiring MMC1A
|
||||
public Mapper155(Emulator emulator) : base(emulator, ChipType.MMC1A)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc90c4e04b12a134c884ca3431375aac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user