Trimmed whitespace, and set propper line endings for SVN.
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@68 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
5be56cdac5
commit
3c06fa079f
|
@ -1,20 +1,20 @@
|
|||
Developer Information File:
|
||||
|
||||
- Don't use the global optimization switch (/Og) because it causes a black screen in Metroid Prime.
|
||||
|
||||
- Project Configurations:
|
||||
- Debug: Debug ON | Optimizations OFF | UPX OFF
|
||||
- Release: Debug OFF | Optimizations OFF | UPX OFF
|
||||
- Optimized: Debug OFF | Optimizations ON | UPX ON
|
||||
|
||||
Software Used:
|
||||
OPTIONAL UPX 1.25 +/-
|
||||
NEEDED nasm 0.98.39 +/-
|
||||
INCLUDED zlib 1.2.3 +/-
|
||||
INCLUDED libpng 1.2.8 +/-
|
||||
NEEDED Microsoft Platform SDK 2003 SP1 +/-
|
||||
NEEDED Microsoft DirectX 9.0c SDK (June 2005) +
|
||||
NEEDED Microsoft Visual Studio .NET Professional 2003 German +
|
||||
|
||||
+ newer is ok
|
||||
Developer Information File:
|
||||
|
||||
- Don't use the global optimization switch (/Og) because it causes a black screen in Metroid Prime.
|
||||
|
||||
- Project Configurations:
|
||||
- Debug: Debug ON | Optimizations OFF | UPX OFF
|
||||
- Release: Debug OFF | Optimizations OFF | UPX OFF
|
||||
- Optimized: Debug OFF | Optimizations ON | UPX ON
|
||||
|
||||
Software Used:
|
||||
OPTIONAL UPX 1.25 +/-
|
||||
NEEDED nasm 0.98.39 +/-
|
||||
INCLUDED zlib 1.2.3 +/-
|
||||
INCLUDED libpng 1.2.8 +/-
|
||||
NEEDED Microsoft Platform SDK 2003 SP1 +/-
|
||||
NEEDED Microsoft DirectX 9.0c SDK (June 2005) +
|
||||
NEEDED Microsoft Visual Studio .NET Professional 2003 German +
|
||||
|
||||
+ newer is ok
|
||||
+/- newer and older is ok
|
160
res/ReadMe.txt
160
res/ReadMe.txt
|
@ -1,81 +1,81 @@
|
|||
VisualBoyAdvance S1.7.6
|
||||
Nintendo Game Boy / Game Boy Advance Emulator
|
||||
|
||||
This program is distributed under the GNU General Public License
|
||||
http://www.gnu.org/licenses/gpl.html
|
||||
|
||||
VBA Official Version 1.7.2 with changes by Spacy
|
||||
Spacy51@gmx.de (Write in english or in german)
|
||||
Special Build Aturhors Homepage: www.spacyhacks.de.vu
|
||||
Original Project Homepage: vba.ngemu.com
|
||||
|
||||
My aim:
|
||||
I want to make this emulator fit my needs and hopefully the needs of others,
|
||||
which want a light-weight small, fast and multimedial emulator for the GBA
|
||||
that makes as much use of the power of modern PCs as possible (but with sense).
|
||||
If you need one of the removed features, just use the original VBA emulator.
|
||||
|
||||
Thanks go to:
|
||||
suanyuan For help in compilation and other fixes
|
||||
Tauwasser For help in assembler
|
||||
WingX For fixing a linker error
|
||||
|
||||
|
||||
The following changes have been made:
|
||||
|
||||
S1.7.6:
|
||||
Emu:
|
||||
- Readded MMX macro
|
||||
- Updated zlib to 1.2.3
|
||||
- Changed some first start options
|
||||
- Other small changes
|
||||
- Put zlib & libpng in seperate Projects
|
||||
- Added some changes from the latest CVS source
|
||||
- Small changes to ROM Header Info (just4fun)
|
||||
- Fixed the linker error (new&delete defined twice)
|
||||
|
||||
Filters:
|
||||
- Speeded up HQ3X code
|
||||
- Fixed LQ2X using HQ2X functions
|
||||
|
||||
Display:
|
||||
- Added extended display mode selection
|
||||
(Display Adapter, Resolution, Bit Depth, Frequency)
|
||||
- No more unnecessary black borders in full screen
|
||||
- Direct3D doesn't take the whole screen (only if you want)
|
||||
- Direct3D shows menu and windows correct
|
||||
- Direct3D doesn't show a black screen if left fullscreen to Windows
|
||||
- Changes on max scale are applied immediately
|
||||
|
||||
Sound:
|
||||
- Updated sound to DirectSound8
|
||||
|
||||
|
||||
S1.7.5:
|
||||
- Removed screen flickering when switching to GDI mode.
|
||||
- Changed some first start options.
|
||||
- Rearranged Menu
|
||||
- Added HQ3X in 32 bit mode
|
||||
- Changed App Icon
|
||||
- Added FINAL_VERSION definition again.
|
||||
- Added 3x/4x filter support to OpenGL mode
|
||||
- Some minor fixes
|
||||
|
||||
|
||||
S1.7.4:
|
||||
- optimized build: (many thanks to suanyuan)
|
||||
- libpng, zlib, MFC linked static
|
||||
- Target OS: Windows 2000
|
||||
- Keep in mind that HQ3X/HQ4X is NOT added
|
||||
at the moment, but everything is ready for it
|
||||
|
||||
|
||||
S1.7.3:
|
||||
- Optimized build and project file
|
||||
- Removed Skin support
|
||||
- Removed SDL support
|
||||
- Removed Linux support
|
||||
- Removed Motion Blur Experimental Filter (the none-IFB version)
|
||||
- Reworked GDI
|
||||
- 3x / 4x filter support
|
||||
VisualBoyAdvance S1.7.6
|
||||
Nintendo Game Boy / Game Boy Advance Emulator
|
||||
|
||||
This program is distributed under the GNU General Public License
|
||||
http://www.gnu.org/licenses/gpl.html
|
||||
|
||||
VBA Official Version 1.7.2 with changes by Spacy
|
||||
Spacy51@gmx.de (Write in english or in german)
|
||||
Special Build Aturhors Homepage: www.spacyhacks.de.vu
|
||||
Original Project Homepage: vba.ngemu.com
|
||||
|
||||
My aim:
|
||||
I want to make this emulator fit my needs and hopefully the needs of others,
|
||||
which want a light-weight small, fast and multimedial emulator for the GBA
|
||||
that makes as much use of the power of modern PCs as possible (but with sense).
|
||||
If you need one of the removed features, just use the original VBA emulator.
|
||||
|
||||
Thanks go to:
|
||||
suanyuan For help in compilation and other fixes
|
||||
Tauwasser For help in assembler
|
||||
WingX For fixing a linker error
|
||||
|
||||
|
||||
The following changes have been made:
|
||||
|
||||
S1.7.6:
|
||||
Emu:
|
||||
- Readded MMX macro
|
||||
- Updated zlib to 1.2.3
|
||||
- Changed some first start options
|
||||
- Other small changes
|
||||
- Put zlib & libpng in seperate Projects
|
||||
- Added some changes from the latest CVS source
|
||||
- Small changes to ROM Header Info (just4fun)
|
||||
- Fixed the linker error (new&delete defined twice)
|
||||
|
||||
Filters:
|
||||
- Speeded up HQ3X code
|
||||
- Fixed LQ2X using HQ2X functions
|
||||
|
||||
Display:
|
||||
- Added extended display mode selection
|
||||
(Display Adapter, Resolution, Bit Depth, Frequency)
|
||||
- No more unnecessary black borders in full screen
|
||||
- Direct3D doesn't take the whole screen (only if you want)
|
||||
- Direct3D shows menu and windows correct
|
||||
- Direct3D doesn't show a black screen if left fullscreen to Windows
|
||||
- Changes on max scale are applied immediately
|
||||
|
||||
Sound:
|
||||
- Updated sound to DirectSound8
|
||||
|
||||
|
||||
S1.7.5:
|
||||
- Removed screen flickering when switching to GDI mode.
|
||||
- Changed some first start options.
|
||||
- Rearranged Menu
|
||||
- Added HQ3X in 32 bit mode
|
||||
- Changed App Icon
|
||||
- Added FINAL_VERSION definition again.
|
||||
- Added 3x/4x filter support to OpenGL mode
|
||||
- Some minor fixes
|
||||
|
||||
|
||||
S1.7.4:
|
||||
- optimized build: (many thanks to suanyuan)
|
||||
- libpng, zlib, MFC linked static
|
||||
- Target OS: Windows 2000
|
||||
- Keep in mind that HQ3X/HQ4X is NOT added
|
||||
at the moment, but everything is ready for it
|
||||
|
||||
|
||||
S1.7.3:
|
||||
- Optimized build and project file
|
||||
- Removed Skin support
|
||||
- Removed SDL support
|
||||
- Removed Linux support
|
||||
- Removed Motion Blur Experimental Filter (the none-IFB version)
|
||||
- Reworked GDI
|
||||
- 3x / 4x filter support
|
||||
- Fullscreen modes available
|
678
res/gpl.txt
678
res/gpl.txt
|
@ -1,340 +1,340 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) 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
|
||||
this service 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 make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. 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.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the 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 a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE 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.
|
||||
|
||||
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
|
||||
convey 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 2 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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision 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, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This 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 Library General
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) 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
|
||||
this service 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 make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. 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.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the 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 a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE 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.
|
||||
|
||||
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
|
||||
convey 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 2 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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision 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, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This 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 Library General
|
||||
Public License instead of this License.
|
1498
res/resource.h
1498
res/resource.h
File diff suppressed because it is too large
Load Diff
284
src/2xSaI.cpp
284
src/2xSaI.cpp
|
@ -23,10 +23,10 @@ extern "C"
|
|||
void BilinearMMXGrid1 (u16 * A, u16 * B, u16 * C, u16 * D,
|
||||
u16 * dx, u16 * dy, u8 *dP);
|
||||
void EndMMX ();
|
||||
|
||||
|
||||
bool cpu_mmx = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
static u32 colorMask = 0xF7DEF7DE;
|
||||
static u32 lowPixelMask = 0x08210821;
|
||||
static u32 qcolorMask = 0xE79CE79C;
|
||||
|
@ -50,7 +50,7 @@ int Init_2xSaI(u32 BitFormat)
|
|||
greenMask = 0x7E0;
|
||||
qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xF7DEF7DE;
|
||||
hq2x_init(16);
|
||||
RGB_LOW_BITS_MASK = 0x0821;
|
||||
RGB_LOW_BITS_MASK = 0x0821;
|
||||
} else if (BitFormat == 555) {
|
||||
colorMask = 0x7BDE7BDE;
|
||||
lowPixelMask = 0x04210421;
|
||||
|
@ -60,7 +60,7 @@ int Init_2xSaI(u32 BitFormat)
|
|||
greenMask = 0x3E0;
|
||||
qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0x7BDE7BDE;
|
||||
hq2x_init(15);
|
||||
RGB_LOW_BITS_MASK = 0x0421;
|
||||
RGB_LOW_BITS_MASK = 0x0421;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -71,14 +71,14 @@ int Init_2xSaI(u32 BitFormat)
|
|||
qlowpixelMask = 0x030303;
|
||||
qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xfefefe;
|
||||
hq2x_init(32);
|
||||
RGB_LOW_BITS_MASK = 0x010101;
|
||||
RGB_LOW_BITS_MASK = 0x010101;
|
||||
} else
|
||||
return 0;
|
||||
|
||||
#ifdef MMX
|
||||
Init_2xSaIMMX (BitFormat);
|
||||
#endif
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ static inline int GetResult2 (u32 A, u32 B, u32 C, u32 D,
|
|||
int x = 0;
|
||||
int y = 0;
|
||||
int r = 0;
|
||||
|
||||
|
||||
if (A == C)
|
||||
x += 1;
|
||||
else if (B == C)
|
||||
|
@ -131,7 +131,7 @@ static inline int GetResult (u32 A, u32 B, u32 C, u32 D)
|
|||
int x = 0;
|
||||
int y = 0;
|
||||
int r = 0;
|
||||
|
||||
|
||||
if (A == C)
|
||||
x += 1;
|
||||
else if (B == C)
|
||||
|
@ -163,7 +163,7 @@ static inline u32 Q_INTERPOLATE (u32 A, u32 B, u32 C, u32 D)
|
|||
((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2);
|
||||
register u32 y = (A & qlowpixelMask) +
|
||||
(B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask);
|
||||
|
||||
|
||||
y = (y >> 2) & qlowpixelMask;
|
||||
return x + y;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ static inline int GetResult2_32 (u32 A, u32 B, u32 C, u32 D,
|
|||
int x = 0;
|
||||
int y = 0;
|
||||
int r = 0;
|
||||
|
||||
|
||||
if (A == C)
|
||||
x += 1;
|
||||
else if (B == C)
|
||||
|
@ -241,43 +241,43 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
|
|||
#endif
|
||||
{
|
||||
inc_bP = 1;
|
||||
|
||||
|
||||
for (; height; height--) {
|
||||
bP = (u16 *) srcPtr;
|
||||
dP = (u8 *) dstPtr;
|
||||
|
||||
|
||||
for (u32 finish = width; finish; finish -= inc_bP) {
|
||||
u32 color4, color5, color6;
|
||||
u32 color1, color2, color3;
|
||||
u32 colorA0, colorA1, colorA2, colorA3,
|
||||
colorB0, colorB1, colorB2, colorB3, colorS1, colorS2;
|
||||
u32 product1a, product1b, product2a, product2b;
|
||||
|
||||
|
||||
//--------------------------------------- B1 B2
|
||||
// 4 5 6 S2
|
||||
// 1 2 3 S1
|
||||
// A1 A2
|
||||
|
||||
|
||||
colorB0 = *(bP - Nextline - 1);
|
||||
colorB1 = *(bP - Nextline);
|
||||
colorB2 = *(bP - Nextline + 1);
|
||||
colorB3 = *(bP - Nextline + 2);
|
||||
|
||||
|
||||
color4 = *(bP - 1);
|
||||
color5 = *(bP);
|
||||
color6 = *(bP + 1);
|
||||
colorS2 = *(bP + 2);
|
||||
|
||||
|
||||
color1 = *(bP + Nextline - 1);
|
||||
color2 = *(bP + Nextline);
|
||||
color3 = *(bP + Nextline + 1);
|
||||
colorS1 = *(bP + Nextline + 2);
|
||||
|
||||
|
||||
colorA0 = *(bP + Nextline + Nextline - 1);
|
||||
colorA1 = *(bP + Nextline + Nextline);
|
||||
colorA2 = *(bP + Nextline + Nextline + 1);
|
||||
colorA3 = *(bP + Nextline + Nextline + 2);
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
if (color2 == color6 && color5 != color3) {
|
||||
product2b = product1b = color2;
|
||||
|
@ -285,12 +285,12 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
|
|||
product2b = product1b = color5;
|
||||
} else if (color5 == color3 && color2 == color6) {
|
||||
register int r = 0;
|
||||
|
||||
|
||||
r += GetResult (color6, color5, color1, colorA1);
|
||||
r += GetResult (color6, color5, color4, colorB1);
|
||||
r += GetResult (color6, color5, colorA2, colorS1);
|
||||
r += GetResult (color6, color5, colorB2, colorS2);
|
||||
|
||||
|
||||
if (r > 0)
|
||||
product2b = product1b = color6;
|
||||
else if (r < 0)
|
||||
|
@ -309,7 +309,7 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
|
|||
Q_INTERPOLATE (color2, color2, color2, color3);
|
||||
else
|
||||
product2b = INTERPOLATE (color2, color3);
|
||||
|
||||
|
||||
if (color6 == color3 && color6 == colorB1
|
||||
&& color5 != colorB2 && color6 != colorB0)
|
||||
product1b =
|
||||
|
@ -321,7 +321,7 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
|
|||
else
|
||||
product1b = INTERPOLATE (color5, color6);
|
||||
}
|
||||
|
||||
|
||||
if (color5 == color3 && color2 != color6 && color4 == color5
|
||||
&& color5 != colorA2)
|
||||
product2a = INTERPOLATE (color2, color5);
|
||||
|
@ -331,7 +331,7 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
|
|||
product2a = INTERPOLATE (color2, color5);
|
||||
else
|
||||
product2a = color2;
|
||||
|
||||
|
||||
if (color2 == color6 && color5 != color3 && color1 == color2
|
||||
&& color2 != colorB2)
|
||||
product1a = INTERPOLATE (color2, color5);
|
||||
|
@ -341,7 +341,7 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
|
|||
product1a = INTERPOLATE (color2, color5);
|
||||
else
|
||||
product1a = color5;
|
||||
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
product1a = (product1a << 16) | product1b;
|
||||
product2a = (product2a << 16) | product2b;
|
||||
|
@ -349,14 +349,14 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
|
|||
product1a = product1a | (product1b << 16);
|
||||
product2a = product2a | (product2b << 16);
|
||||
#endif
|
||||
|
||||
|
||||
*((u32 *) dP) = product1a;
|
||||
*((u32 *) (dP + dstPitch)) = product2a;
|
||||
|
||||
|
||||
bP += inc_bP;
|
||||
dP += sizeof (u32);
|
||||
} // end of for ( finish= width etc..)
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
deltaPtr += srcPitch;
|
||||
|
@ -373,43 +373,43 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
|
|||
u32 inc_bP;
|
||||
u32 Nextline = srcPitch >> 2;
|
||||
inc_bP = 1;
|
||||
|
||||
|
||||
for (; height; height--) {
|
||||
bP = (u32 *) srcPtr;
|
||||
dP = (u32 *) dstPtr;
|
||||
|
||||
|
||||
for (u32 finish = width; finish; finish -= inc_bP) {
|
||||
u32 color4, color5, color6;
|
||||
u32 color1, color2, color3;
|
||||
u32 colorA0, colorA1, colorA2, colorA3,
|
||||
colorB0, colorB1, colorB2, colorB3, colorS1, colorS2;
|
||||
u32 product1a, product1b, product2a, product2b;
|
||||
|
||||
|
||||
//--------------------------------------- B1 B2
|
||||
// 4 5 6 S2
|
||||
// 1 2 3 S1
|
||||
// A1 A2
|
||||
|
||||
|
||||
colorB0 = *(bP - Nextline - 1);
|
||||
colorB1 = *(bP - Nextline);
|
||||
colorB2 = *(bP - Nextline + 1);
|
||||
colorB3 = *(bP - Nextline + 2);
|
||||
|
||||
|
||||
color4 = *(bP - 1);
|
||||
color5 = *(bP);
|
||||
color6 = *(bP + 1);
|
||||
colorS2 = *(bP + 2);
|
||||
|
||||
|
||||
color1 = *(bP + Nextline - 1);
|
||||
color2 = *(bP + Nextline);
|
||||
color3 = *(bP + Nextline + 1);
|
||||
colorS1 = *(bP + Nextline + 2);
|
||||
|
||||
|
||||
colorA0 = *(bP + Nextline + Nextline - 1);
|
||||
colorA1 = *(bP + Nextline + Nextline);
|
||||
colorA2 = *(bP + Nextline + Nextline + 1);
|
||||
colorA3 = *(bP + Nextline + Nextline + 2);
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
if (color2 == color6 && color5 != color3) {
|
||||
product2b = product1b = color2;
|
||||
|
@ -417,12 +417,12 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
|
|||
product2b = product1b = color5;
|
||||
} else if (color5 == color3 && color2 == color6) {
|
||||
register int r = 0;
|
||||
|
||||
|
||||
r += GetResult (color6, color5, color1, colorA1);
|
||||
r += GetResult (color6, color5, color4, colorB1);
|
||||
r += GetResult (color6, color5, colorA2, colorS1);
|
||||
r += GetResult (color6, color5, colorB2, colorS2);
|
||||
|
||||
|
||||
if (r > 0)
|
||||
product2b = product1b = color6;
|
||||
else if (r < 0)
|
||||
|
@ -441,7 +441,7 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
|
|||
Q_INTERPOLATE (color2, color2, color2, color3);
|
||||
else
|
||||
product2b = INTERPOLATE (color2, color3);
|
||||
|
||||
|
||||
if (color6 == color3 && color6 == colorB1
|
||||
&& color5 != colorB2 && color6 != colorB0)
|
||||
product1b =
|
||||
|
@ -453,7 +453,7 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
|
|||
else
|
||||
product1b = INTERPOLATE (color5, color6);
|
||||
}
|
||||
|
||||
|
||||
if (color5 == color3 && color2 != color6 && color4 == color5
|
||||
&& color5 != colorA2)
|
||||
product2a = INTERPOLATE (color2, color5);
|
||||
|
@ -463,7 +463,7 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
|
|||
product2a = INTERPOLATE (color2, color5);
|
||||
else
|
||||
product2a = color2;
|
||||
|
||||
|
||||
if (color2 == color6 && color5 != color3 && color1 == color2
|
||||
&& color2 != colorB2)
|
||||
product1a = INTERPOLATE (color2, color5);
|
||||
|
@ -477,18 +477,18 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
|
|||
*(dP+1) = product1b;
|
||||
*(dP + (dstPitch >> 2)) = product2a;
|
||||
*(dP + (dstPitch >> 2) + 1) = product2b;
|
||||
|
||||
|
||||
bP += inc_bP;
|
||||
dP += 2;
|
||||
} // end of for ( finish= width etc..)
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
// deltaPtr += srcPitch;
|
||||
} // endof: for (; height; height--)
|
||||
}
|
||||
|
||||
void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
||||
void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
u8 *dP;
|
||||
|
@ -506,12 +506,12 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
deltaPtr += srcPitch;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
inc_bP = 1;
|
||||
|
||||
|
||||
u32 Nextline = srcPitch >> 1;
|
||||
|
||||
|
||||
for (; height; height--) {
|
||||
bP = (u16 *) srcPtr;
|
||||
xP = (u16 *) deltaPtr;
|
||||
|
@ -521,23 +521,23 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
u32 color1, color2, color3;
|
||||
u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
|
||||
u32 product1a, product1b, product2a, product2b;
|
||||
|
||||
|
||||
colorB1 = *(bP - Nextline);
|
||||
colorB2 = *(bP - Nextline + 1);
|
||||
|
||||
|
||||
color4 = *(bP - 1);
|
||||
color5 = *(bP);
|
||||
color6 = *(bP + 1);
|
||||
colorS2 = *(bP + 2);
|
||||
|
||||
|
||||
color1 = *(bP + Nextline - 1);
|
||||
color2 = *(bP + Nextline);
|
||||
color3 = *(bP + Nextline + 1);
|
||||
colorS1 = *(bP + Nextline + 2);
|
||||
|
||||
|
||||
colorA1 = *(bP + Nextline + Nextline);
|
||||
colorA2 = *(bP + Nextline + Nextline + 1);
|
||||
|
||||
|
||||
// --------------------------------------
|
||||
if (color2 == color6 && color5 != color3) {
|
||||
product1b = product2a = color2;
|
||||
|
@ -548,7 +548,7 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
} else {
|
||||
product1a = INTERPOLATE (color5, color6);
|
||||
}
|
||||
|
||||
|
||||
if ((color6 == colorS2) || (color2 == colorA1)) {
|
||||
product2b = INTERPOLATE (color2, color3);
|
||||
product2b = INTERPOLATE (color2, product2b);
|
||||
|
@ -558,7 +558,7 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
}
|
||||
} else if (color5 == color3 && color2 != color6) {
|
||||
product2b = product1a = color5;
|
||||
|
||||
|
||||
if ((colorB1 == color5) || (color3 == colorS1)) {
|
||||
product1b = INTERPOLATE (color5, color6);
|
||||
product1b = INTERPOLATE (color5, product1b);
|
||||
|
@ -566,7 +566,7 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
} else {
|
||||
product1b = INTERPOLATE (color5, color6);
|
||||
}
|
||||
|
||||
|
||||
if ((color3 == colorA2) || (color4 == color5)) {
|
||||
product2a = INTERPOLATE (color5, color2);
|
||||
product2a = INTERPOLATE (color5, product2a);
|
||||
|
@ -574,15 +574,15 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
} else {
|
||||
product2a = INTERPOLATE (color2, color3);
|
||||
}
|
||||
|
||||
|
||||
} else if (color5 == color3 && color2 == color6) {
|
||||
register int r = 0;
|
||||
|
||||
|
||||
r += GetResult (color6, color5, color1, colorA1);
|
||||
r += GetResult (color6, color5, color4, colorB1);
|
||||
r += GetResult (color6, color5, colorA2, colorS1);
|
||||
r += GetResult (color6, color5, colorB2, colorS2);
|
||||
|
||||
|
||||
if (r > 0) {
|
||||
product1b = product2a = color2;
|
||||
product1a = product2b = INTERPOLATE (color5, color6);
|
||||
|
@ -599,13 +599,13 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
Q_INTERPOLATE (color3, color3, color3, product2b);
|
||||
product1a =
|
||||
Q_INTERPOLATE (color5, color5, color5, product1a);
|
||||
|
||||
|
||||
product2a = product1b = INTERPOLATE (color5, color3);
|
||||
product2a =
|
||||
Q_INTERPOLATE (color2, color2, color2, product2a);
|
||||
product1b =
|
||||
Q_INTERPOLATE (color6, color6, color6, product1b);
|
||||
|
||||
|
||||
// product1a = color5;
|
||||
// product1b = color6;
|
||||
// product2a = color2;
|
||||
|
@ -618,16 +618,16 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
product1a = product1a | (product1b << 16);
|
||||
product2a = product2a | (product2b << 16);
|
||||
#endif
|
||||
|
||||
|
||||
*((u32 *) dP) = product1a;
|
||||
*((u32 *) (dP + dstPitch)) = product2a;
|
||||
*xP = color5;
|
||||
|
||||
|
||||
bP += inc_bP;
|
||||
xP += inc_bP;
|
||||
dP += sizeof (u32);
|
||||
} // end of for ( finish= width etc..)
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
deltaPtr += srcPitch;
|
||||
|
@ -635,7 +635,7 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
}
|
||||
}
|
||||
|
||||
void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
||||
void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
u32 *dP;
|
||||
|
@ -644,9 +644,9 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
u32 inc_bP;
|
||||
|
||||
inc_bP = 1;
|
||||
|
||||
|
||||
u32 Nextline = srcPitch >> 2;
|
||||
|
||||
|
||||
for (; height; height--) {
|
||||
bP = (u32 *) srcPtr;
|
||||
xP = (u32 *) deltaPtr;
|
||||
|
@ -656,23 +656,23 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
u32 color1, color2, color3;
|
||||
u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
|
||||
u32 product1a, product1b, product2a, product2b;
|
||||
|
||||
|
||||
colorB1 = *(bP - Nextline);
|
||||
colorB2 = *(bP - Nextline + 1);
|
||||
|
||||
|
||||
color4 = *(bP - 1);
|
||||
color5 = *(bP);
|
||||
color6 = *(bP + 1);
|
||||
colorS2 = *(bP + 2);
|
||||
|
||||
|
||||
color1 = *(bP + Nextline - 1);
|
||||
color2 = *(bP + Nextline);
|
||||
color3 = *(bP + Nextline + 1);
|
||||
colorS1 = *(bP + Nextline + 2);
|
||||
|
||||
|
||||
colorA1 = *(bP + Nextline + Nextline);
|
||||
colorA2 = *(bP + Nextline + Nextline + 1);
|
||||
|
||||
|
||||
// --------------------------------------
|
||||
if (color2 == color6 && color5 != color3) {
|
||||
product1b = product2a = color2;
|
||||
|
@ -683,7 +683,7 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
} else {
|
||||
product1a = INTERPOLATE (color5, color6);
|
||||
}
|
||||
|
||||
|
||||
if ((color6 == colorS2) || (color2 == colorA1)) {
|
||||
product2b = INTERPOLATE (color2, color3);
|
||||
product2b = INTERPOLATE (color2, product2b);
|
||||
|
@ -693,7 +693,7 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
}
|
||||
} else if (color5 == color3 && color2 != color6) {
|
||||
product2b = product1a = color5;
|
||||
|
||||
|
||||
if ((colorB1 == color5) || (color3 == colorS1)) {
|
||||
product1b = INTERPOLATE (color5, color6);
|
||||
product1b = INTERPOLATE (color5, product1b);
|
||||
|
@ -701,7 +701,7 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
} else {
|
||||
product1b = INTERPOLATE (color5, color6);
|
||||
}
|
||||
|
||||
|
||||
if ((color3 == colorA2) || (color4 == color5)) {
|
||||
product2a = INTERPOLATE (color5, color2);
|
||||
product2a = INTERPOLATE (color5, product2a);
|
||||
|
@ -709,15 +709,15 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
} else {
|
||||
product2a = INTERPOLATE (color2, color3);
|
||||
}
|
||||
|
||||
|
||||
} else if (color5 == color3 && color2 == color6) {
|
||||
register int r = 0;
|
||||
|
||||
|
||||
r += GetResult (color6, color5, color1, colorA1);
|
||||
r += GetResult (color6, color5, color4, colorB1);
|
||||
r += GetResult (color6, color5, colorA2, colorS1);
|
||||
r += GetResult (color6, color5, colorB2, colorS2);
|
||||
|
||||
|
||||
if (r > 0) {
|
||||
product1b = product2a = color2;
|
||||
product1a = product2b = INTERPOLATE (color5, color6);
|
||||
|
@ -734,13 +734,13 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
Q_INTERPOLATE (color3, color3, color3, product2b);
|
||||
product1a =
|
||||
Q_INTERPOLATE (color5, color5, color5, product1a);
|
||||
|
||||
|
||||
product2a = product1b = INTERPOLATE (color5, color3);
|
||||
product2a =
|
||||
Q_INTERPOLATE (color2, color2, color2, product2a);
|
||||
product1b =
|
||||
Q_INTERPOLATE (color6, color6, color6, product1b);
|
||||
|
||||
|
||||
// product1a = color5;
|
||||
// product1b = color6;
|
||||
// product2a = color2;
|
||||
|
@ -751,12 +751,12 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
*(dP + (dstPitch >> 2)) = product2a;
|
||||
*(dP + (dstPitch >> 2) +1) = product2b;
|
||||
*xP = color5;
|
||||
|
||||
|
||||
bP += inc_bP;
|
||||
xP += inc_bP;
|
||||
dP += 2;
|
||||
} // end of for ( finish= width etc..)
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
deltaPtr += srcPitch;
|
||||
|
@ -769,7 +769,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
u8 *dP;
|
||||
u16 *bP;
|
||||
u32 inc_bP;
|
||||
|
||||
|
||||
#ifdef MMX
|
||||
if (cpu_mmx) {
|
||||
for (; height; height -= 1) {
|
||||
|
@ -782,23 +782,23 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
#endif
|
||||
{
|
||||
inc_bP = 1;
|
||||
|
||||
|
||||
u32 Nextline = srcPitch >> 1;
|
||||
|
||||
|
||||
for (; height; height--) {
|
||||
bP = (u16 *) srcPtr;
|
||||
dP = dstPtr;
|
||||
|
||||
|
||||
for (u32 finish = width; finish; finish -= inc_bP) {
|
||||
|
||||
|
||||
register u32 colorA, colorB;
|
||||
u32 colorC, colorD,
|
||||
colorE, colorF, colorG, colorH,
|
||||
colorI, colorJ, colorK, colorL,
|
||||
|
||||
|
||||
colorM, colorN, colorO, colorP;
|
||||
u32 product, product1, product2;
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
// Map of the pixels: I|E F|J
|
||||
// G|A B|K
|
||||
|
@ -808,22 +808,22 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
colorE = *(bP - Nextline);
|
||||
colorF = *(bP - Nextline + 1);
|
||||
colorJ = *(bP - Nextline + 2);
|
||||
|
||||
|
||||
colorG = *(bP - 1);
|
||||
colorA = *(bP);
|
||||
colorB = *(bP + 1);
|
||||
colorK = *(bP + 2);
|
||||
|
||||
|
||||
colorH = *(bP + Nextline - 1);
|
||||
colorC = *(bP + Nextline);
|
||||
colorD = *(bP + Nextline + 1);
|
||||
colorL = *(bP + Nextline + 2);
|
||||
|
||||
|
||||
colorM = *(bP + Nextline + Nextline - 1);
|
||||
colorN = *(bP + Nextline + Nextline);
|
||||
colorO = *(bP + Nextline + Nextline + 1);
|
||||
colorP = *(bP + Nextline + Nextline + 2);
|
||||
|
||||
|
||||
if ((colorA == colorD) && (colorB != colorC)) {
|
||||
if (((colorA == colorE) && (colorB == colorL)) ||
|
||||
((colorA == colorC) && (colorA == colorF)
|
||||
|
@ -832,7 +832,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
} else {
|
||||
product = INTERPOLATE (colorA, colorB);
|
||||
}
|
||||
|
||||
|
||||
if (((colorA == colorG) && (colorC == colorO)) ||
|
||||
((colorA == colorB) && (colorA == colorH)
|
||||
&& (colorG != colorC) && (colorC == colorM))) {
|
||||
|
@ -849,7 +849,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
} else {
|
||||
product = INTERPOLATE (colorA, colorB);
|
||||
}
|
||||
|
||||
|
||||
if (((colorC == colorH) && (colorA == colorF)) ||
|
||||
((colorC == colorG) && (colorC == colorD)
|
||||
&& (colorA != colorH) && (colorA == colorI))) {
|
||||
|
@ -865,10 +865,10 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
product2 = colorA;
|
||||
} else {
|
||||
register int r = 0;
|
||||
|
||||
|
||||
product1 = INTERPOLATE (colorA, colorC);
|
||||
product = INTERPOLATE (colorA, colorB);
|
||||
|
||||
|
||||
r +=
|
||||
GetResult1 (colorA, colorB, colorG, colorE,
|
||||
colorI);
|
||||
|
@ -881,7 +881,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
r +=
|
||||
GetResult1 (colorA, colorB, colorL, colorO,
|
||||
colorP);
|
||||
|
||||
|
||||
if (r > 0)
|
||||
product2 = colorA;
|
||||
else if (r < 0)
|
||||
|
@ -894,7 +894,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
}
|
||||
} else {
|
||||
product2 = Q_INTERPOLATE (colorA, colorB, colorC, colorD);
|
||||
|
||||
|
||||
if ((colorA == colorC) && (colorA == colorF)
|
||||
&& (colorB != colorE) && (colorB == colorJ)) {
|
||||
product = colorA;
|
||||
|
@ -904,7 +904,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
} else {
|
||||
product = INTERPOLATE (colorA, colorB);
|
||||
}
|
||||
|
||||
|
||||
if ((colorA == colorB) && (colorA == colorH)
|
||||
&& (colorG != colorC) && (colorC == colorM)) {
|
||||
product1 = colorA;
|
||||
|
@ -915,7 +915,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
product1 = INTERPOLATE (colorA, colorC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
product = (colorA << 16) | product ;
|
||||
product1 = (product1 << 16) | product2 ;
|
||||
|
@ -925,11 +925,11 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
#endif
|
||||
*((s32 *) dP) = product;
|
||||
*((u32 *) (dP + dstPitch)) = product1;
|
||||
|
||||
|
||||
bP += inc_bP;
|
||||
dP += sizeof (u32);
|
||||
} // end of for ( finish= width etc..)
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
deltaPtr += srcPitch;
|
||||
|
@ -943,22 +943,22 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
u32 *dP;
|
||||
u32 *bP;
|
||||
u32 inc_bP = 1;
|
||||
|
||||
|
||||
u32 Nextline = srcPitch >> 2;
|
||||
|
||||
|
||||
for (; height; height--) {
|
||||
bP = (u32 *) srcPtr;
|
||||
dP = (u32 *) dstPtr;
|
||||
|
||||
|
||||
for (u32 finish = width; finish; finish -= inc_bP) {
|
||||
register u32 colorA, colorB;
|
||||
u32 colorC, colorD,
|
||||
colorE, colorF, colorG, colorH,
|
||||
colorI, colorJ, colorK, colorL,
|
||||
|
||||
|
||||
colorM, colorN, colorO, colorP;
|
||||
u32 product, product1, product2;
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
// Map of the pixels: I|E F|J
|
||||
// G|A B|K
|
||||
|
@ -968,22 +968,22 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
colorE = *(bP - Nextline);
|
||||
colorF = *(bP - Nextline + 1);
|
||||
colorJ = *(bP - Nextline + 2);
|
||||
|
||||
|
||||
colorG = *(bP - 1);
|
||||
colorA = *(bP);
|
||||
colorB = *(bP + 1);
|
||||
colorK = *(bP + 2);
|
||||
|
||||
|
||||
colorH = *(bP + Nextline - 1);
|
||||
colorC = *(bP + Nextline);
|
||||
colorD = *(bP + Nextline + 1);
|
||||
colorL = *(bP + Nextline + 2);
|
||||
|
||||
|
||||
colorM = *(bP + Nextline + Nextline - 1);
|
||||
colorN = *(bP + Nextline + Nextline);
|
||||
colorO = *(bP + Nextline + Nextline + 1);
|
||||
colorP = *(bP + Nextline + Nextline + 2);
|
||||
|
||||
|
||||
if ((colorA == colorD) && (colorB != colorC)) {
|
||||
if (((colorA == colorE) && (colorB == colorL)) ||
|
||||
((colorA == colorC) && (colorA == colorF)
|
||||
|
@ -992,7 +992,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
} else {
|
||||
product = INTERPOLATE (colorA, colorB);
|
||||
}
|
||||
|
||||
|
||||
if (((colorA == colorG) && (colorC == colorO)) ||
|
||||
((colorA == colorB) && (colorA == colorH)
|
||||
&& (colorG != colorC) && (colorC == colorM))) {
|
||||
|
@ -1009,7 +1009,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
} else {
|
||||
product = INTERPOLATE (colorA, colorB);
|
||||
}
|
||||
|
||||
|
||||
if (((colorC == colorH) && (colorA == colorF)) ||
|
||||
((colorC == colorG) && (colorC == colorD)
|
||||
&& (colorA != colorH) && (colorA == colorI))) {
|
||||
|
@ -1025,10 +1025,10 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
product2 = colorA;
|
||||
} else {
|
||||
register int r = 0;
|
||||
|
||||
|
||||
product1 = INTERPOLATE (colorA, colorC);
|
||||
product = INTERPOLATE (colorA, colorB);
|
||||
|
||||
|
||||
r +=
|
||||
GetResult1 (colorA, colorB, colorG, colorE,
|
||||
colorI);
|
||||
|
@ -1041,7 +1041,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
r +=
|
||||
GetResult1 (colorA, colorB, colorL, colorO,
|
||||
colorP);
|
||||
|
||||
|
||||
if (r > 0)
|
||||
product2 = colorA;
|
||||
else if (r < 0)
|
||||
|
@ -1054,7 +1054,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
}
|
||||
} else {
|
||||
product2 = Q_INTERPOLATE (colorA, colorB, colorC, colorD);
|
||||
|
||||
|
||||
if ((colorA == colorC) && (colorA == colorF)
|
||||
&& (colorB != colorE) && (colorB == colorJ)) {
|
||||
product = colorA;
|
||||
|
@ -1064,7 +1064,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
} else {
|
||||
product = INTERPOLATE (colorA, colorB);
|
||||
}
|
||||
|
||||
|
||||
if ((colorA == colorB) && (colorA == colorH)
|
||||
&& (colorG != colorC) && (colorC == colorM)) {
|
||||
product1 = colorA;
|
||||
|
@ -1079,11 +1079,11 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
*(dP + 1) = product;
|
||||
*(dP + (dstPitch >> 2)) = product1;
|
||||
*(dP + (dstPitch >> 2) + 1) = product2;
|
||||
|
||||
|
||||
bP += inc_bP;
|
||||
dP += 2;
|
||||
} // end of for ( finish= width etc..)
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
// deltaPtr += srcPitch;
|
||||
|
@ -1094,18 +1094,18 @@ static u32 Bilinear (u32 A, u32 B, u32 x)
|
|||
{
|
||||
unsigned long areaA, areaB;
|
||||
unsigned long result;
|
||||
|
||||
|
||||
if (A == B)
|
||||
return A;
|
||||
|
||||
|
||||
areaB = (x >> 11) & 0x1f; // reduce 16 bit fraction to 5 bits
|
||||
areaA = 0x20 - areaB;
|
||||
|
||||
|
||||
A = (A & redblueMask) | ((A & greenMask) << 16);
|
||||
B = (B & redblueMask) | ((B & greenMask) << 16);
|
||||
|
||||
|
||||
result = ((areaA * A) + (areaB * B)) >> 5;
|
||||
|
||||
|
||||
return (result & redblueMask) | ((result >> 16) & greenMask);
|
||||
}
|
||||
|
||||
|
@ -1114,28 +1114,28 @@ static u32 Bilinear4 (u32 A, u32 B, u32 C, u32 D, u32 x,
|
|||
{
|
||||
unsigned long areaA, areaB, areaC, areaD;
|
||||
unsigned long result, xy;
|
||||
|
||||
|
||||
x = (x >> 11) & 0x1f;
|
||||
y = (y >> 11) & 0x1f;
|
||||
xy = (x * y) >> 5;
|
||||
|
||||
|
||||
A = (A & redblueMask) | ((A & greenMask) << 16);
|
||||
B = (B & redblueMask) | ((B & greenMask) << 16);
|
||||
C = (C & redblueMask) | ((C & greenMask) << 16);
|
||||
D = (D & redblueMask) | ((D & greenMask) << 16);
|
||||
|
||||
|
||||
areaA = 0x20 + xy - x - y;
|
||||
areaB = x - xy;
|
||||
areaC = y - xy;
|
||||
areaD = xy;
|
||||
|
||||
|
||||
result = ((areaA * A) + (areaB * B) + (areaC * C) + (areaD * D)) >> 5;
|
||||
|
||||
|
||||
return (result & redblueMask) | ((result >> 16) & greenMask);
|
||||
}
|
||||
|
||||
void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch,
|
||||
u8 *dstPtr, u32 dstPitch,
|
||||
u32 dstWidth, u32 dstHeight, int width, int height)
|
||||
{
|
||||
u8 *dP;
|
||||
|
@ -1147,31 +1147,31 @@ void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
u32 dh;
|
||||
u32 hfinish;
|
||||
u32 wfinish;
|
||||
|
||||
|
||||
u32 Nextline = srcPitch >> 1;
|
||||
|
||||
|
||||
wfinish = (width - 1) << 16; // convert to fixed point
|
||||
dw = wfinish / (dstWidth - 1);
|
||||
hfinish = (height - 1) << 16; // convert to fixed point
|
||||
dh = hfinish / (dstHeight - 1);
|
||||
|
||||
|
||||
for (h = 0; h < hfinish; h += dh) {
|
||||
u32 y1, y2;
|
||||
|
||||
|
||||
y1 = h & 0xffff; // fraction part of fixed point
|
||||
bP = (u16 *) (srcPtr + ((h >> 16) * srcPitch));
|
||||
dP = dstPtr;
|
||||
y2 = 0x10000 - y1;
|
||||
|
||||
|
||||
w = 0;
|
||||
|
||||
|
||||
for (; w < wfinish;) {
|
||||
u32 A, B, C, D;
|
||||
u32 E, F, G, H;
|
||||
u32 I, J, K, L;
|
||||
u32 x1, x2, a1, f1, f2;
|
||||
u32 position, product1;
|
||||
|
||||
|
||||
position = w >> 16;
|
||||
A = bP[position]; // current pixel
|
||||
B = bP[position + 1]; // next pixel
|
||||
|
@ -1185,11 +1185,11 @@ void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
J = bP[position + Nextline + 2];
|
||||
K = bP[position + Nextline + Nextline];
|
||||
L = bP[position + Nextline + Nextline + 1];
|
||||
|
||||
|
||||
x1 = w & 0xffff; // fraction part of fixed point
|
||||
x2 = 0x10000 - x1;
|
||||
|
||||
/*0*/
|
||||
|
||||
/*0*/
|
||||
if (A == B && C == D && A == C)
|
||||
product1 = A;
|
||||
else /*1*/ if (A == D && B != C) {
|
||||
|
@ -1226,7 +1226,7 @@ void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
}
|
||||
}
|
||||
else
|
||||
/*2*/
|
||||
/*2*/
|
||||
if (B == C && A != D)
|
||||
{
|
||||
f1 = (x1 >> 1) + (0x10000 >> 2);
|
||||
|
@ -1267,7 +1267,7 @@ void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
{
|
||||
product1 = Bilinear4 (A, B, C, D, x1, y1);
|
||||
}
|
||||
|
||||
|
||||
//end First Pixel
|
||||
*(u32 *) dP = product1;
|
||||
dP += 2;
|
||||
|
|
|
@ -102,7 +102,7 @@ _2xSaISuper2xSaILine:
|
|||
mov ebx, [ebp+srcPitch] ;ebx contains the source pitch
|
||||
mov ecx, [ebp+width] ;ecx contains the number of pixels to process
|
||||
; eax now points to colorB1
|
||||
sub eax, ebx ;eax points to B1 which is the base
|
||||
sub eax, ebx ;eax points to B1 which is the base
|
||||
|
||||
; Main Loop
|
||||
.Loop: push ecx
|
||||
|
@ -153,7 +153,7 @@ _2xSaISuper2xSaILine:
|
|||
|
||||
packsswb mm7, mm7
|
||||
movd ecx, mm7
|
||||
test ecx, ecx
|
||||
test ecx, ecx
|
||||
jz near .SKIP_PROCESS ;no, so we can skip
|
||||
|
||||
;End Delta
|
||||
|
@ -432,7 +432,7 @@ _2xSaISuper2xSaILine:
|
|||
pcmpgtw mm0, mm1
|
||||
|
||||
por mm7, [Mask35]
|
||||
por mm0, [Mask26]
|
||||
por mm0, [Mask26]
|
||||
movq [Mask35], mm7
|
||||
movq [Mask26], mm0
|
||||
|
||||
|
@ -440,7 +440,7 @@ _2xSaISuper2xSaILine:
|
|||
|
||||
;Start the ASSEMBLY !!! eh... compose all the results together to form the final image...
|
||||
|
||||
|
||||
|
||||
movq mm0, [eax+ebx+color5]
|
||||
movq mm1, [eax+ebx+ebx+color2]
|
||||
movq mm2, mm0
|
||||
|
@ -516,7 +516,7 @@ _2xSaISuper2xSaILine:
|
|||
pand mm6, mm2
|
||||
por mm7, mm6
|
||||
|
||||
|
||||
|
||||
movq mm6, mm7
|
||||
pcmpeqw mm6, mm5
|
||||
pand mm7, mm0
|
||||
|
@ -527,8 +527,8 @@ _2xSaISuper2xSaILine:
|
|||
movq [final1a], mm7 ;finished 1a
|
||||
|
||||
|
||||
|
||||
;--------------------------------
|
||||
|
||||
;--------------------------------
|
||||
|
||||
movq mm7, [Mask35]
|
||||
push eax
|
||||
|
@ -568,7 +568,7 @@ _2xSaISuper2xSaILine:
|
|||
pand mm6, mm2
|
||||
por mm7, mm6
|
||||
|
||||
|
||||
|
||||
movq mm6, mm7
|
||||
pcmpeqw mm6, mm5
|
||||
pand mm7, mm0
|
||||
|
@ -580,7 +580,7 @@ _2xSaISuper2xSaILine:
|
|||
|
||||
|
||||
;--------------------------------------------
|
||||
|
||||
|
||||
|
||||
%ifdef dfhsdfhsdahdsfhdsfh
|
||||
if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0)
|
||||
|
@ -647,7 +647,7 @@ _2xSaISuper2xSaILine:
|
|||
|
||||
movq mm4, [Mask35]
|
||||
movq mm3, [Mask26]
|
||||
|
||||
|
||||
movq mm6, mm4
|
||||
pand mm6, mm7
|
||||
pxor mm4, mm6
|
||||
|
@ -679,7 +679,7 @@ _2xSaISuper2xSaILine:
|
|||
movq [final2b], mm0
|
||||
|
||||
;-----------------------------------
|
||||
|
||||
|
||||
|
||||
pxor mm7, mm7
|
||||
movq mm0, [eax+colorB0]
|
||||
|
@ -721,7 +721,7 @@ _2xSaISuper2xSaILine:
|
|||
|
||||
movq mm4, [Mask35]
|
||||
movq mm3, [Mask26]
|
||||
|
||||
|
||||
movq mm6, mm4
|
||||
pand mm6, mm7
|
||||
pxor mm4, mm6
|
||||
|
@ -751,7 +751,7 @@ _2xSaISuper2xSaILine:
|
|||
por mm0, mm3
|
||||
por mm0, mm2
|
||||
movq [final1b], mm0
|
||||
|
||||
|
||||
;---------
|
||||
|
||||
movq mm0, [final1a]
|
||||
|
@ -2052,7 +2052,7 @@ Bits565:
|
|||
mov [eax+4], edx
|
||||
mov eax, 0
|
||||
jmp end3
|
||||
end3:
|
||||
end3:
|
||||
pop edx
|
||||
mov esp, ebp
|
||||
pop ebp
|
||||
|
|
|
@ -120,7 +120,7 @@ void cheatSearchCleanup(CheatSearchData *cs)
|
|||
void cheatSearchStart(const CheatSearchData *cs)
|
||||
{
|
||||
int count = cs->count;
|
||||
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
CheatSearchBlock *block = &cs->blocks[i];
|
||||
|
||||
|
@ -163,7 +163,7 @@ u32 cheatSearchRead(u8 *data, int off, int size)
|
|||
return res;
|
||||
}
|
||||
|
||||
void cheatSearch(const CheatSearchData *cs, int compare, int size,
|
||||
void cheatSearch(const CheatSearchData *cs, int compare, int size,
|
||||
bool isSigned)
|
||||
{
|
||||
if(compare < 0 || compare > SEARCH_GE)
|
||||
|
@ -183,7 +183,7 @@ void cheatSearch(const CheatSearchData *cs, int compare, int size,
|
|||
u8 *bits = block->bits;
|
||||
u8 *data = block->data;
|
||||
u8 *saved = block->saved;
|
||||
|
||||
|
||||
for(int j = 0; j < size2; j += inc) {
|
||||
if(IS_BIT_SET(bits, j)) {
|
||||
s32 a = cheatSearchSignedRead(data, j, size);
|
||||
|
@ -210,7 +210,7 @@ void cheatSearch(const CheatSearchData *cs, int compare, int size,
|
|||
u8 *bits = block->bits;
|
||||
u8 *data = block->data;
|
||||
u8 *saved = block->saved;
|
||||
|
||||
|
||||
for(int j = 0; j < size2; j += inc) {
|
||||
if(IS_BIT_SET(bits, j)) {
|
||||
u32 a = cheatSearchRead(data, j, size);
|
||||
|
@ -231,7 +231,7 @@ void cheatSearch(const CheatSearchData *cs, int compare, int size,
|
|||
}
|
||||
}
|
||||
|
||||
void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
|
||||
void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
|
||||
bool isSigned, u32 value)
|
||||
{
|
||||
if(compare < 0 || compare > SEARCH_GE)
|
||||
|
@ -250,7 +250,7 @@ void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
|
|||
int size2 = block->size;
|
||||
u8 *bits = block->bits;
|
||||
u8 *data = block->data;
|
||||
|
||||
|
||||
for(int j = 0; j < size2; j += inc) {
|
||||
if(IS_BIT_SET(bits, j)) {
|
||||
s32 a = cheatSearchSignedRead(data, j, size);
|
||||
|
@ -276,7 +276,7 @@ void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
|
|||
int size2 = block->size;
|
||||
u8 *bits = block->bits;
|
||||
u8 *data = block->data;
|
||||
|
||||
|
||||
for(int j = 0; j < size2; j += inc) {
|
||||
if(IS_BIT_SET(bits, j)) {
|
||||
u32 a = cheatSearchRead(data, j, size);
|
||||
|
@ -296,7 +296,7 @@ void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
|
|||
}
|
||||
}
|
||||
|
||||
int cheatSearchGetCount(const CheatSearchData *cs, int size)
|
||||
int cheatSearchGetCount(const CheatSearchData *cs, int size)
|
||||
{
|
||||
int res = 0;
|
||||
int inc = 1;
|
||||
|
@ -307,7 +307,7 @@ int cheatSearchGetCount(const CheatSearchData *cs, int size)
|
|||
|
||||
for(int i = 0; i < cs->count; i++) {
|
||||
CheatSearchBlock *block = &cs->blocks[i];
|
||||
|
||||
|
||||
int size2 = block->size;
|
||||
u8 *bits = block->bits;
|
||||
for(int j = 0; j < size2; j += inc) {
|
||||
|
|
|
@ -62,9 +62,9 @@ enum {
|
|||
extern CheatSearchData cheatSearchData;
|
||||
extern void cheatSearchCleanup(CheatSearchData *cs);
|
||||
extern void cheatSearchStart(const CheatSearchData *cs);
|
||||
extern void cheatSearch(const CheatSearchData *cs, int compare, int size,
|
||||
extern void cheatSearch(const CheatSearchData *cs, int compare, int size,
|
||||
bool isSigned);
|
||||
extern void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
|
||||
extern void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
|
||||
bool isSigned, u32 value);
|
||||
extern int cheatSearchGetCount(const CheatSearchData *cs, int size);
|
||||
extern void cheatSearchUpdateValues(const CheatSearchData *cs);
|
||||
|
|
148
src/Cheats.cpp
148
src/Cheats.cpp
|
@ -66,7 +66,7 @@
|
|||
* 4AAAAAAA YYYY - Slide code
|
||||
* XXXXCCCC IIII (C is count and I is address increment, X is value incr.)
|
||||
* 5AAAAAAA CCCC - Super code (Write bytes to address, 2*CCCC is count)
|
||||
* BBBBBBBB BBBB
|
||||
* BBBBBBBB BBBB
|
||||
* 6AAAAAAA YYYY - 16-bit and
|
||||
* 7AAAAAAA YYYY - if address contains 16-bit value enable next code
|
||||
* 8AAAAAAA YYYY - 16-bit constant write
|
||||
|
@ -115,7 +115,7 @@
|
|||
#define CBA_ADD 32
|
||||
#define CBA_OR 33
|
||||
#define CBA_LT 34
|
||||
#define CBA_GT 35
|
||||
#define CBA_GT 35
|
||||
#define CBA_SUPER 36
|
||||
#define GSA_8_BIT_POINTER 37
|
||||
#define GSA_16_BIT_POINTER 38
|
||||
|
@ -322,7 +322,7 @@ u8 v3_deadtable2[256] = {
|
|||
WRITE16LE(((u16 *)&rom[(a) & 0x1ffffff]), v);
|
||||
|
||||
#define CHEAT_PATCH_ROM_32BIT(a,v) \
|
||||
WRITE32LE(((u32 *)&rom[(a) & 0x1ffffff]), v);
|
||||
WRITE32LE(((u32 *)&rom[(a) & 0x1ffffff]), v);
|
||||
|
||||
static bool isMultilineWithData(int i)
|
||||
{
|
||||
|
@ -613,7 +613,7 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
|||
cheatsList[i].status |= 4;
|
||||
else
|
||||
cheatsList[i].status &= ~4;
|
||||
|
||||
|
||||
if(cheatsList[i].status & 1)
|
||||
ticks += ((cheatsList[i].value & 0xFFFF) * 7);
|
||||
break;
|
||||
|
@ -752,12 +752,12 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
|||
break;
|
||||
case GSA_16_BIT_GS_WRITE:
|
||||
if(extended & 4) {
|
||||
CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value);
|
||||
CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value);
|
||||
}
|
||||
break;
|
||||
case GSA_32_BIT_GS_WRITE:
|
||||
if(extended & 4) {
|
||||
CPUWriteMemory(cheatsList[i].address, cheatsList[i].value);
|
||||
CPUWriteMemory(cheatsList[i].address, cheatsList[i].value);
|
||||
}
|
||||
break;
|
||||
case CBA_IF_KEYS_PRESSED:
|
||||
|
@ -884,12 +884,12 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
|||
}
|
||||
break;
|
||||
case CBA_ADD:
|
||||
if ((cheatsList[i].address & 1) == 0) {
|
||||
CPUWriteHalfWord(cheatsList[i].address,
|
||||
if ((cheatsList[i].address & 1) == 0) {
|
||||
CPUWriteHalfWord(cheatsList[i].address,
|
||||
CPUReadHalfWord(cheatsList[i].address) +
|
||||
cheatsList[i].value);
|
||||
} else {
|
||||
CPUWriteMemory(cheatsList[i].address & 0x0FFFFFFE,
|
||||
CPUWriteMemory(cheatsList[i].address & 0x0FFFFFFE,
|
||||
CPUReadMemory(cheatsList[i].address & 0x0FFFFFFE) +
|
||||
cheatsList[i].value);
|
||||
}
|
||||
|
@ -1121,11 +1121,11 @@ int cheatsCheckKeys(u32 keys, u32 extended)
|
|||
break;
|
||||
case GSA_16_BIT_WRITE_IOREGS:
|
||||
if ((cheatsList[i].address <= 0x3FF) && (cheatsList[i].address != 0x6) &&
|
||||
(cheatsList[i].address != 0x130))
|
||||
(cheatsList[i].address != 0x130))
|
||||
ioMem[cheatsList[i].address & 0x3FE]=cheatsList[i].value & 0xFFFF;
|
||||
break;
|
||||
case GSA_32_BIT_WRITE_IOREGS:
|
||||
if (cheatsList[i].address<=0x3FF)
|
||||
if (cheatsList[i].address<=0x3FF)
|
||||
{
|
||||
if (((cheatsList[i].address & 0x3FC) != 0x6) && ((cheatsList[i].address & 0x3FC) != 0x130))
|
||||
ioMem[cheatsList[i].address & 0x3FC]= (cheatsList[i].value & 0xFFFF);
|
||||
|
@ -1400,7 +1400,7 @@ void cheatsDelete(int number, bool restore)
|
|||
if(cheatsList[x].status & 1) {
|
||||
cheatsList[x].status &= ~1;
|
||||
CHEAT_PATCH_ROM_16BIT(cheatsList[x].address,
|
||||
cheatsList[x].oldValue);
|
||||
cheatsList[x].oldValue);
|
||||
}
|
||||
break;
|
||||
case GSA_16_BIT_ROM_PATCH2C:
|
||||
|
@ -1476,7 +1476,7 @@ bool cheatsVerifyCheatCode(const char *code, const char *desc)
|
|||
|
||||
if(code[8] != ':') {
|
||||
systemMessage(MSG_INVALID_CHEAT_CODE, N_("Invalid cheat code '%s'"), code);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t i;
|
||||
|
@ -1496,10 +1496,10 @@ bool cheatsVerifyCheatCode(const char *code, const char *desc)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
u32 address = 0;
|
||||
u32 value = 0;
|
||||
|
||||
|
||||
char buffer[10];
|
||||
strncpy(buffer, code, 8);
|
||||
buffer[8] = 0;
|
||||
|
@ -1525,8 +1525,8 @@ bool cheatsVerifyCheatCode(const char *code, const char *desc)
|
|||
address);
|
||||
return false;
|
||||
}
|
||||
|
||||
strncpy(buffer, &code[9], 8);
|
||||
|
||||
strncpy(buffer, &code[9], 8);
|
||||
sscanf(buffer, "%x", &value);
|
||||
int type = 0;
|
||||
if(len == 13)
|
||||
|
@ -1575,7 +1575,7 @@ u32 seed_gen(u8 upper, u8 seed, u8 *deadtable1, u8 *deadtable2) {
|
|||
|
||||
for (i = 0; i < 4; i++)
|
||||
newseed = ((newseed << 8) | ((deadtable1[(i + upper) & 0xFF] + deadtable2[seed]) & 0xFF));
|
||||
|
||||
|
||||
return newseed;
|
||||
}
|
||||
|
||||
|
@ -1583,7 +1583,7 @@ void cheatsDecryptGSACode(u32& address, u32& value, bool v3)
|
|||
{
|
||||
u32 rollingseed = 0xC6EF3720;
|
||||
u32 *seeds = v3 ? seeds_v3 : seeds_v1;
|
||||
|
||||
|
||||
int bitsleft = 32;
|
||||
while (bitsleft > 0) {
|
||||
value -= ((((address << 4) + seeds[2]) ^ (address + rollingseed)) ^
|
||||
|
@ -1603,7 +1603,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
|
|||
N_("Invalid GSA code. Format is XXXXXXXXYYYYYYYY"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int i;
|
||||
for(i = 0; i < 16; i++) {
|
||||
if(!CHEAT_IS_HEX(code[i])) {
|
||||
|
@ -1613,7 +1613,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char buffer[10];
|
||||
strncpy(buffer, code, 8);
|
||||
buffer[8] = 0;
|
||||
|
@ -1638,7 +1638,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
|
|||
systemMessage(MSG_GBA_CODE_WARNING, N_("Warning: cheats are for game %s. Current game is %s.\nCodes may not work correctly."),
|
||||
buffer, buffer2);
|
||||
}
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, v3 ? 257 : 256,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, v3 ? 257 : 256,
|
||||
UNKNOWN_CODE);
|
||||
return;
|
||||
}
|
||||
|
@ -1940,7 +1940,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
int type = (address >> 28) & 15;
|
||||
int type = (address >> 28) & 15;
|
||||
switch(type) {
|
||||
case 0:
|
||||
case 1:
|
||||
|
@ -1972,7 +1972,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
|
|||
break;
|
||||
default:
|
||||
// unsupported code
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
UNKNOWN_CODE);
|
||||
break;
|
||||
}
|
||||
|
@ -1981,27 +1981,27 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
|
|||
address <<= 1;
|
||||
type = (value >> 24) & 0xFF;
|
||||
if(type == 0x00) {
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
|
||||
GSA_16_BIT_ROM_PATCH);
|
||||
break;
|
||||
}
|
||||
// unsupported code
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
UNKNOWN_CODE);
|
||||
break;
|
||||
case 8:
|
||||
switch((address >> 20) & 15) {
|
||||
case 1:
|
||||
cheatsAdd(code, desc, address, address & 0x0F0FFFFF, value, 256,
|
||||
cheatsAdd(code, desc, address, address & 0x0F0FFFFF, value, 256,
|
||||
GSA_8_BIT_GS_WRITE);
|
||||
break;
|
||||
case 2:
|
||||
cheatsAdd(code, desc, address, address & 0x0F0FFFFF, value, 256,
|
||||
cheatsAdd(code, desc, address, address & 0x0F0FFFFF, value, 256,
|
||||
GSA_16_BIT_GS_WRITE);
|
||||
break;
|
||||
case 4:
|
||||
// This code is buggy : the value is always set to 0 !
|
||||
cheatsAdd(code, desc, address, address & 0x0F0FFFFF, 0, 256,
|
||||
cheatsAdd(code, desc, address, address & 0x0F0FFFFF, 0, 256,
|
||||
GSA_32_BIT_GS_WRITE);
|
||||
break;
|
||||
case 15:
|
||||
|
@ -2009,7 +2009,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
|
|||
break;
|
||||
default:
|
||||
// unsupported code
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
UNKNOWN_CODE);
|
||||
break;
|
||||
}
|
||||
|
@ -2018,52 +2018,52 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
|
|||
if(address != 0xDEADFACE) {
|
||||
switch((value >> 20) & 0xF) {
|
||||
case 0:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
|
||||
CBA_IF_TRUE);
|
||||
break;
|
||||
case 1:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
|
||||
CBA_IF_FALSE);
|
||||
break;
|
||||
case 2:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
|
||||
GSA_16_BIT_IF_LOWER_OR_EQ_U);
|
||||
break;
|
||||
case 3:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
|
||||
GSA_16_BIT_IF_HIGHER_OR_EQ_U);
|
||||
break;
|
||||
default:
|
||||
// unsupported code
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
UNKNOWN_CODE);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
UNKNOWN_CODE);
|
||||
break;
|
||||
case 0x0e:
|
||||
switch((value >> 28) & 0xF) {
|
||||
case 0:
|
||||
cheatsAdd(code, desc, address, value & 0x0FFFFFFF, address & 0xFFFF, 256,
|
||||
cheatsAdd(code, desc, address, value & 0x0FFFFFFF, address & 0xFFFF, 256,
|
||||
GSA_16_BIT_MIF_TRUE);
|
||||
break;
|
||||
case 1:
|
||||
cheatsAdd(code, desc, address, value & 0x0FFFFFFF, address & 0xFFFF, 256,
|
||||
cheatsAdd(code, desc, address, value & 0x0FFFFFFF, address & 0xFFFF, 256,
|
||||
GSA_16_BIT_MIF_FALSE);
|
||||
break;
|
||||
case 2:
|
||||
cheatsAdd(code, desc, address, value & 0x0FFFFFFF, address & 0xFFFF, 256,
|
||||
cheatsAdd(code, desc, address, value & 0x0FFFFFFF, address & 0xFFFF, 256,
|
||||
GSA_16_BIT_MIF_LOWER_OR_EQ_U);
|
||||
break;
|
||||
case 3:
|
||||
cheatsAdd(code, desc, address, value & 0x0FFFFFFF, address & 0xFFFF, 256,
|
||||
cheatsAdd(code, desc, address, value & 0x0FFFFFFF, address & 0xFFFF, 256,
|
||||
GSA_16_BIT_MIF_HIGHER_OR_EQ_U);
|
||||
break;
|
||||
default:
|
||||
// unsupported code
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
UNKNOWN_CODE);
|
||||
break;
|
||||
}
|
||||
|
@ -2074,7 +2074,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
|
|||
break;
|
||||
default:
|
||||
// unsupported code
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
cheatsAdd(code, desc, address, address, value, 256,
|
||||
UNKNOWN_CODE);
|
||||
break;
|
||||
}
|
||||
|
@ -2086,7 +2086,7 @@ bool cheatsImportGSACodeFile(const char *name, int game, bool v3)
|
|||
FILE *f = fopen(name, "rb");
|
||||
if(!f)
|
||||
return false;
|
||||
|
||||
|
||||
int games = 0;
|
||||
int len = 0;
|
||||
fseek(f, 0x1e, SEEK_CUR);
|
||||
|
@ -2371,7 +2371,7 @@ void cheatsCBAGenTable() {
|
|||
u16 cheatsCBACalcCRC(u8 *rom, int count)
|
||||
{
|
||||
u32 crc = 0xffffffff;
|
||||
|
||||
|
||||
if (count & 3) {
|
||||
// 0x08000EAE
|
||||
} else {
|
||||
|
@ -2458,7 +2458,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
|||
N_("Invalid CBA code. Format is XXXXXXXX YYYY."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int i;
|
||||
for(i = 0; i < 8; i++) {
|
||||
if(!CHEAT_IS_HEX(code[i])) {
|
||||
|
@ -2472,9 +2472,9 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
|||
if(code[8] != ' ') {
|
||||
systemMessage(MSG_INVALID_CBA_CODE,
|
||||
N_("Invalid CBA code. Format is XXXXXXXX YYYY."));
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for(i = 9; i < 13; i++) {
|
||||
if(!CHEAT_IS_HEX(code[i])) {
|
||||
// wrong cheat
|
||||
|
@ -2482,8 +2482,8 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
|||
N_("Invalid CBA code. Format is XXXXXXXX YYYY."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
char buffer[10];
|
||||
strncpy(buffer, code, 8);
|
||||
buffer[8] = 0;
|
||||
|
@ -2517,7 +2517,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
|||
|
||||
address = READ32LE(((u32 *)array));
|
||||
value = READ16LE(((u16 *)&array[4]));
|
||||
|
||||
|
||||
int type = (address >> 28) & 15;
|
||||
|
||||
if(isMultilineWithData(cheatsNumber-1) || (super>0)) {
|
||||
|
@ -2526,7 +2526,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
|||
super-= 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch(type) {
|
||||
case 0x00:
|
||||
{
|
||||
|
@ -2537,7 +2537,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
|||
systemMessage(MSG_CBA_CODE_WARNING,
|
||||
N_("Warning: Codes seem to be for a different game.\nCodes may not work correctly."));
|
||||
}
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, 512,
|
||||
UNKNOWN_CODE);
|
||||
}
|
||||
break;
|
||||
|
@ -2546,15 +2546,15 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
|||
mastercode = (address & 0x1FFFFFF) | 0x08000000;
|
||||
break;
|
||||
case 0x02:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
CBA_OR);
|
||||
break;
|
||||
case 0x03:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, 512,
|
||||
INT_8_BIT_WRITE);
|
||||
break;
|
||||
case 0x04:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
CBA_SLIDE_CODE);
|
||||
break;
|
||||
case 0x05:
|
||||
|
@ -2563,32 +2563,32 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
|||
super = getCodeLength(cheatsNumber-1);
|
||||
break;
|
||||
case 0x06:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
CBA_AND);
|
||||
break;
|
||||
case 0x07:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
CBA_IF_TRUE);
|
||||
break;
|
||||
case 0x08:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
INT_16_BIT_WRITE);
|
||||
break;
|
||||
case 0x0a:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
CBA_IF_FALSE);
|
||||
break;
|
||||
case 0x0b:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
CBA_GT);
|
||||
break;
|
||||
case 0x0c:
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
|
||||
CBA_LT);
|
||||
break;
|
||||
case 0x0d:
|
||||
if ((address & 0xF0)<0x30)
|
||||
cheatsAdd(code, desc, address, address & 0xF0, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0xF0, value, 512,
|
||||
CBA_IF_KEYS_PRESSED);
|
||||
break;
|
||||
case 0x0e:
|
||||
|
@ -2601,7 +2601,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
|||
break;
|
||||
default:
|
||||
// unsupported code
|
||||
cheatsAdd(code, desc, address, address & 0xFFFFFFFF, value, 512,
|
||||
cheatsAdd(code, desc, address, address & 0xFFFFFFFF, value, 512,
|
||||
UNKNOWN_CODE);
|
||||
break;
|
||||
}
|
||||
|
@ -2611,14 +2611,14 @@ void cheatsAddCBACode(const char *code, const char *desc)
|
|||
void cheatsSaveGame(gzFile file)
|
||||
{
|
||||
utilWriteInt(file, cheatsNumber);
|
||||
|
||||
|
||||
utilGzWrite(file, cheatsList, sizeof(cheatsList));
|
||||
}
|
||||
|
||||
void cheatsReadGame(gzFile file, int version)
|
||||
{
|
||||
cheatsNumber = 0;
|
||||
|
||||
|
||||
cheatsNumber = utilReadInt(file);
|
||||
|
||||
if (version > 8)
|
||||
|
@ -2626,7 +2626,7 @@ void cheatsReadGame(gzFile file, int version)
|
|||
|
||||
|
||||
bool firstCodeBreaker = true;
|
||||
|
||||
|
||||
for(int i = 0; i < cheatsNumber; i++) {
|
||||
if (version <9)
|
||||
{
|
||||
|
@ -2676,7 +2676,7 @@ void cheatsReadGame(gzFile file, int version)
|
|||
buffer[4] = 0;
|
||||
u32 value;
|
||||
sscanf(buffer, "%x", &value);
|
||||
|
||||
|
||||
u32 seed[8];
|
||||
cheatsCBAParseSeedCode(address, value, seed);
|
||||
cheatsCBAChangeEncryption(seed);
|
||||
|
@ -2717,7 +2717,7 @@ bool cheatsLoadCheatList(const char *file)
|
|||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(version != 1) {
|
||||
systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_VERSION,
|
||||
N_("Unsupported cheat list version %d"), version);
|
||||
|
@ -2738,7 +2738,7 @@ bool cheatsLoadCheatList(const char *file)
|
|||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(fread(&count, 1, sizeof(count), f) != sizeof(count)) {
|
||||
fclose(f);
|
||||
return false;
|
||||
|
@ -2771,7 +2771,7 @@ bool cheatsLoadCheatList(const char *file)
|
|||
}
|
||||
|
||||
bool firstCodeBreaker = true;
|
||||
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
cheatsList[i].status = 0; // remove old status as it is not used
|
||||
if(!cheatsList[i].codestring[0]) {
|
||||
|
@ -2790,7 +2790,7 @@ bool cheatsLoadCheatList(const char *file)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(cheatsList[i].code == 512 && firstCodeBreaker) {
|
||||
firstCodeBreaker = false;
|
||||
char buffer[10];
|
||||
|
@ -2803,11 +2803,11 @@ bool cheatsLoadCheatList(const char *file)
|
|||
buffer[4] = 0;
|
||||
u32 value;
|
||||
sscanf(buffer, "%x", &value);
|
||||
|
||||
|
||||
u32 seed[8];
|
||||
cheatsCBAParseSeedCode(address, value, seed);
|
||||
cheatsCBAChangeEncryption(seed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cheatsNumber = count;
|
||||
|
@ -2817,7 +2817,7 @@ bool cheatsLoadCheatList(const char *file)
|
|||
|
||||
extern int cpuNextEvent;
|
||||
|
||||
extern void debuggerBreakOnWrite(u32 , u32, u32, int, int);
|
||||
extern void debuggerBreakOnWrite(u32 , u32, u32, int, int);
|
||||
|
||||
static u8 cheatsGetType(u32 address)
|
||||
{
|
||||
|
|
|
@ -140,7 +140,7 @@ void eepromWrite(u32 /* address */, u8 value)
|
|||
eepromAddress = ((eepromBuffer[0] & 0x3F) << 8) |
|
||||
((eepromBuffer[1] & 0xFF));
|
||||
if(!(eepromBuffer[0] & 0x40)) {
|
||||
eepromBuffer[0] = bit;
|
||||
eepromBuffer[0] = bit;
|
||||
eepromBits = 1;
|
||||
eepromByte = 0;
|
||||
eepromMode = EEPROM_WRITEDATA;
|
||||
|
@ -157,7 +157,7 @@ void eepromWrite(u32 /* address */, u8 value)
|
|||
if(!(eepromBuffer[0] & 0x40)) {
|
||||
eepromBuffer[0] = bit;
|
||||
eepromBits = 1;
|
||||
eepromByte = 0;
|
||||
eepromByte = 0;
|
||||
eepromMode = EEPROM_WRITEDATA;
|
||||
} else {
|
||||
eepromMode = EEPROM_READDATA;
|
||||
|
@ -194,4 +194,4 @@ void eepromWrite(u32 /* address */, u8 value)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static variable_desc flashSaveData[] = {
|
|||
static variable_desc flashSaveData2[] = {
|
||||
{ &flashState, sizeof(int) },
|
||||
{ &flashReadState, sizeof(int) },
|
||||
{ &flashSize, sizeof(int) },
|
||||
{ &flashSize, sizeof(int) },
|
||||
{ &flashSaveMemory[0], 0x20000 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
|
8922
src/GBA.cpp
8922
src/GBA.cpp
File diff suppressed because it is too large
Load Diff
996
src/GBAinline.h
996
src/GBAinline.h
|
@ -1,498 +1,498 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef VBA_GBAinline_H
|
||||
#define VBA_GBAinline_H
|
||||
|
||||
#include "System.h"
|
||||
#include "Port.h"
|
||||
#include "RTC.h"
|
||||
|
||||
extern bool cpuSramEnabled;
|
||||
extern bool cpuFlashEnabled;
|
||||
extern bool cpuEEPROMEnabled;
|
||||
extern bool cpuEEPROMSensorEnabled;
|
||||
extern int lspeed;
|
||||
extern bool linkenable;
|
||||
extern void LinkSStop(void);
|
||||
extern bool cpuDmaHack;
|
||||
extern bool cpuDmaHack2;
|
||||
extern u32 cpuDmaLast;
|
||||
extern bool timer0On;
|
||||
extern int timer0Ticks;
|
||||
extern int timer0ClockReload;
|
||||
extern bool timer1On;
|
||||
extern int timer1Ticks;
|
||||
extern int timer1ClockReload;
|
||||
extern bool timer2On;
|
||||
extern int timer2Ticks;
|
||||
extern int timer2ClockReload;
|
||||
extern bool timer3On;
|
||||
extern int timer3Ticks;
|
||||
extern int timer3ClockReload;
|
||||
extern int cpuTotalTicks;
|
||||
|
||||
#define CPUReadByteQuick(addr) \
|
||||
map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]
|
||||
|
||||
#define CPUReadHalfWordQuick(addr) \
|
||||
READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
|
||||
|
||||
#define CPUReadMemoryQuick(addr) \
|
||||
READ32LE(((u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
|
||||
|
||||
static inline u32 CPUReadMemory(u32 address)
|
||||
{
|
||||
|
||||
#ifdef DEV_VERSION
|
||||
if(address & 3) {
|
||||
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
|
||||
log("Unaligned word read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
u32 value;
|
||||
switch(address >> 24) {
|
||||
case 0:
|
||||
if(reg[15].I >> 24) {
|
||||
if(address < 0x4000) {
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal word read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
value = READ32LE(((u32 *)&biosProtected));
|
||||
}
|
||||
else goto unreadable;
|
||||
} else
|
||||
value = READ32LE(((u32 *)&bios[address & 0x3FFC]));
|
||||
break;
|
||||
case 2:
|
||||
value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC]));
|
||||
break;
|
||||
case 3:
|
||||
value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC]));
|
||||
break;
|
||||
case 4:
|
||||
if(linkenable && (address>=0x4000120||address<=0x4000126)&&lspeed)
|
||||
LinkSStop();
|
||||
if((address < 0x4000400) && ioReadable[address & 0x3fc]) {
|
||||
if(ioReadable[(address & 0x3fc) + 2])
|
||||
value = READ32LE(((u32 *)&ioMem[address & 0x3fC]));
|
||||
else
|
||||
value = READ16LE(((u16 *)&ioMem[address & 0x3fc]));
|
||||
} else goto unreadable;
|
||||
break;
|
||||
case 5:
|
||||
value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC]));
|
||||
break;
|
||||
case 6:
|
||||
address = (address & 0x1fffc);
|
||||
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
|
||||
{
|
||||
value = 0;
|
||||
break;
|
||||
}
|
||||
if ((address & 0x18000) == 0x18000)
|
||||
address &= 0x17fff;
|
||||
value = READ32LE(((u32 *)&vram[address]));
|
||||
break;
|
||||
case 7:
|
||||
value = READ32LE(((u32 *)&oam[address & 0x3FC]));
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
value = READ32LE(((u32 *)&rom[address&0x1FFFFFC]));
|
||||
break;
|
||||
case 13:
|
||||
if(cpuEEPROMEnabled)
|
||||
// no need to swap this
|
||||
return eepromRead(address);
|
||||
goto unreadable;
|
||||
case 14:
|
||||
if(cpuFlashEnabled | cpuSramEnabled)
|
||||
// no need to swap this
|
||||
return flashRead(address);
|
||||
// default
|
||||
default:
|
||||
unreadable:
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal word read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(cpuDmaHack || cpuDmaHack2) {
|
||||
value = cpuDmaLast;
|
||||
} else {
|
||||
if(armState) {
|
||||
value = CPUReadMemoryQuick(reg[15].I);
|
||||
} else {
|
||||
value = CPUReadHalfWordQuick(reg[15].I) |
|
||||
CPUReadHalfWordQuick(reg[15].I) << 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(address & 3) {
|
||||
#ifdef C_CORE
|
||||
int shift = (address & 3) << 3;
|
||||
value = (value >> shift) | (value << (32 - shift));
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
asm("and $3, %%ecx;"
|
||||
"shl $3 ,%%ecx;"
|
||||
"ror %%cl, %0"
|
||||
: "=r" (value)
|
||||
: "r" (value), "c" (address));
|
||||
#else
|
||||
__asm {
|
||||
mov ecx, address;
|
||||
and ecx, 3;
|
||||
shl ecx, 3;
|
||||
ror [dword ptr value], cl;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
extern u32 myROM[];
|
||||
|
||||
static inline u32 CPUReadHalfWord(u32 address)
|
||||
{
|
||||
#ifdef DEV_VERSION
|
||||
if(address & 1) {
|
||||
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
|
||||
log("Unaligned halfword read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
u32 value;
|
||||
|
||||
switch(address >> 24) {
|
||||
case 0:
|
||||
if (reg[15].I >> 24) {
|
||||
if(address < 0x4000) {
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal halfword read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
value = READ16LE(((u16 *)&biosProtected[address&2]));
|
||||
} else goto unreadable;
|
||||
} else
|
||||
value = READ16LE(((u16 *)&bios[address & 0x3FFE]));
|
||||
break;
|
||||
case 2:
|
||||
value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE]));
|
||||
break;
|
||||
case 3:
|
||||
value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe]));
|
||||
break;
|
||||
case 4:
|
||||
if(linkenable && (address>=0x4000120||address<=0x4000126)&&lspeed)
|
||||
LinkSStop();
|
||||
if((address < 0x4000400) && ioReadable[address & 0x3fe])
|
||||
{
|
||||
value = READ16LE(((u16 *)&ioMem[address & 0x3fe]));
|
||||
if (((address & 0x3fe)>0xFF) && ((address & 0x3fe)<0x10E))
|
||||
{
|
||||
if (((address & 0x3fe) == 0x100) && timer0On)
|
||||
value = 0xFFFF - ((timer0Ticks-cpuTotalTicks) >> timer0ClockReload);
|
||||
else
|
||||
if (((address & 0x3fe) == 0x104) && timer1On && !(TM1CNT & 4))
|
||||
value = 0xFFFF - ((timer1Ticks-cpuTotalTicks) >> timer1ClockReload);
|
||||
else
|
||||
if (((address & 0x3fe) == 0x108) && timer2On && !(TM2CNT & 4))
|
||||
value = 0xFFFF - ((timer2Ticks-cpuTotalTicks) >> timer2ClockReload);
|
||||
else
|
||||
if (((address & 0x3fe) == 0x10C) && timer3On && !(TM3CNT & 4))
|
||||
value = 0xFFFF - ((timer3Ticks-cpuTotalTicks) >> timer3ClockReload);
|
||||
}
|
||||
}
|
||||
else goto unreadable;
|
||||
break;
|
||||
case 5:
|
||||
value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe]));
|
||||
break;
|
||||
case 6:
|
||||
address = (address & 0x1fffe);
|
||||
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
|
||||
{
|
||||
value = 0;
|
||||
break;
|
||||
}
|
||||
if ((address & 0x18000) == 0x18000)
|
||||
address &= 0x17fff;
|
||||
value = READ16LE(((u16 *)&vram[address]));
|
||||
break;
|
||||
case 7:
|
||||
value = READ16LE(((u16 *)&oam[address & 0x3fe]));
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
if(address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8)
|
||||
value = rtcRead(address);
|
||||
else
|
||||
value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE]));
|
||||
break;
|
||||
case 13:
|
||||
if(cpuEEPROMEnabled)
|
||||
// no need to swap this
|
||||
return eepromRead(address);
|
||||
goto unreadable;
|
||||
case 14:
|
||||
if(cpuFlashEnabled | cpuSramEnabled)
|
||||
// no need to swap this
|
||||
return flashRead(address);
|
||||
// default
|
||||
default:
|
||||
unreadable:
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal halfword read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
if(cpuDmaHack2 || cpuDmaHack) {
|
||||
value = cpuDmaLast & 0xFFFF;
|
||||
} else {
|
||||
if(armState) {
|
||||
value = CPUReadHalfWordQuick(reg[15].I + (address & 2));
|
||||
} else {
|
||||
value = CPUReadHalfWordQuick(reg[15].I);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(address & 1) {
|
||||
value = (value >> 8) | (value << 24);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline u16 CPUReadHalfWordSigned(u32 address)
|
||||
{
|
||||
u16 value = CPUReadHalfWord(address);
|
||||
if((address & 1))
|
||||
value = (s8)value;
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline u8 CPUReadByte(u32 address)
|
||||
{
|
||||
switch(address >> 24) {
|
||||
case 0:
|
||||
if (reg[15].I >> 24) {
|
||||
if(address < 0x4000) {
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal byte read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
return biosProtected[address & 3];
|
||||
} else goto unreadable;
|
||||
}
|
||||
return bios[address & 0x3FFF];
|
||||
case 2:
|
||||
return workRAM[address & 0x3FFFF];
|
||||
case 3:
|
||||
return internalRAM[address & 0x7fff];
|
||||
case 4:
|
||||
if(linkenable&&(address>=0x4000120||address<=0x4000126)&&lspeed)
|
||||
LinkSStop();
|
||||
if((address < 0x4000400) && ioReadable[address & 0x3ff])
|
||||
return ioMem[address & 0x3ff];
|
||||
else goto unreadable;
|
||||
case 5:
|
||||
return paletteRAM[address & 0x3ff];
|
||||
case 6:
|
||||
address = (address & 0x1ffff);
|
||||
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
|
||||
return 0;
|
||||
if ((address & 0x18000) == 0x18000)
|
||||
address &= 0x17fff;
|
||||
return vram[address];
|
||||
case 7:
|
||||
return oam[address & 0x3ff];
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
return rom[address & 0x1FFFFFF];
|
||||
case 13:
|
||||
if(cpuEEPROMEnabled)
|
||||
return eepromRead(address);
|
||||
goto unreadable;
|
||||
case 14:
|
||||
if(cpuSramEnabled | cpuFlashEnabled)
|
||||
return flashRead(address);
|
||||
if(cpuEEPROMSensorEnabled) {
|
||||
switch(address & 0x00008f00) {
|
||||
case 0x8200:
|
||||
return systemGetSensorX() & 255;
|
||||
case 0x8300:
|
||||
return (systemGetSensorX() >> 8)|0x80;
|
||||
case 0x8400:
|
||||
return systemGetSensorY() & 255;
|
||||
case 0x8500:
|
||||
return systemGetSensorY() >> 8;
|
||||
}
|
||||
}
|
||||
// default
|
||||
default:
|
||||
unreadable:
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal byte read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
if(cpuDmaHack || cpuDmaHack2) {
|
||||
return cpuDmaLast & 0xFF;
|
||||
} else {
|
||||
if(armState) {
|
||||
return CPUReadByteQuick(reg[15].I+(address & 3));
|
||||
} else {
|
||||
return CPUReadByteQuick(reg[15].I+(address & 1));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void CPUWriteMemory(u32 address, u32 value)
|
||||
{
|
||||
|
||||
#ifdef DEV_VERSION
|
||||
if(address & 3) {
|
||||
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
|
||||
log("Unaligned word write: %08x to %08x from %08x\n",
|
||||
value,
|
||||
address,
|
||||
armMode ? armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
switch(address >> 24) {
|
||||
case 0x02:
|
||||
#ifdef BKPT_SUPPORT
|
||||
if(*((u32 *)&freezeWorkRAM[address & 0x3FFFC]))
|
||||
cheatsWriteMemory(address & 0x203FFFC,
|
||||
value);
|
||||
else
|
||||
#endif
|
||||
WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value);
|
||||
break;
|
||||
case 0x03:
|
||||
#ifdef BKPT_SUPPORT
|
||||
if(*((u32 *)&freezeInternalRAM[address & 0x7ffc]))
|
||||
cheatsWriteMemory(address & 0x3007FFC,
|
||||
value);
|
||||
else
|
||||
#endif
|
||||
WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value);
|
||||
break;
|
||||
case 0x04:
|
||||
if(address < 0x4000400) {
|
||||
CPUUpdateRegister((address & 0x3FC), value & 0xFFFF);
|
||||
CPUUpdateRegister((address & 0x3FC) + 2, (value >> 16));
|
||||
} else goto unwritable;
|
||||
break;
|
||||
case 0x05:
|
||||
#ifdef BKPT_SUPPORT
|
||||
if(*((u32 *)&freezePRAM[address & 0x3fc]))
|
||||
cheatsWriteMemory(address & 0x70003FC,
|
||||
value);
|
||||
else
|
||||
#endif
|
||||
WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value);
|
||||
break;
|
||||
case 0x06:
|
||||
address = (address & 0x1fffc);
|
||||
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
|
||||
return;
|
||||
if ((address & 0x18000) == 0x18000)
|
||||
address &= 0x17fff;
|
||||
|
||||
#ifdef BKPT_SUPPORT
|
||||
if(*((u32 *)&freezeVRAM[address]))
|
||||
cheatsWriteMemory(address + 0x06000000, value);
|
||||
else
|
||||
#endif
|
||||
|
||||
WRITE32LE(((u32 *)&vram[address]), value);
|
||||
break;
|
||||
case 0x07:
|
||||
#ifdef BKPT_SUPPORT
|
||||
if(*((u32 *)&freezeOAM[address & 0x3fc]))
|
||||
cheatsWriteMemory(address & 0x70003FC,
|
||||
value);
|
||||
else
|
||||
#endif
|
||||
WRITE32LE(((u32 *)&oam[address & 0x3fc]), value);
|
||||
break;
|
||||
case 0x0D:
|
||||
if(cpuEEPROMEnabled) {
|
||||
eepromWrite(address, value);
|
||||
break;
|
||||
}
|
||||
goto unwritable;
|
||||
case 0x0E:
|
||||
if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) {
|
||||
(*cpuSaveGameFunc)(address, (u8)value);
|
||||
break;
|
||||
}
|
||||
// default
|
||||
default:
|
||||
unwritable:
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_WRITE) {
|
||||
log("Illegal word write: %08x to %08x from %08x\n",
|
||||
value,
|
||||
address,
|
||||
armMode ? armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //VBA_GBAinline_H
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef VBA_GBAinline_H
|
||||
#define VBA_GBAinline_H
|
||||
|
||||
#include "System.h"
|
||||
#include "Port.h"
|
||||
#include "RTC.h"
|
||||
|
||||
extern bool cpuSramEnabled;
|
||||
extern bool cpuFlashEnabled;
|
||||
extern bool cpuEEPROMEnabled;
|
||||
extern bool cpuEEPROMSensorEnabled;
|
||||
extern int lspeed;
|
||||
extern bool linkenable;
|
||||
extern void LinkSStop(void);
|
||||
extern bool cpuDmaHack;
|
||||
extern bool cpuDmaHack2;
|
||||
extern u32 cpuDmaLast;
|
||||
extern bool timer0On;
|
||||
extern int timer0Ticks;
|
||||
extern int timer0ClockReload;
|
||||
extern bool timer1On;
|
||||
extern int timer1Ticks;
|
||||
extern int timer1ClockReload;
|
||||
extern bool timer2On;
|
||||
extern int timer2Ticks;
|
||||
extern int timer2ClockReload;
|
||||
extern bool timer3On;
|
||||
extern int timer3Ticks;
|
||||
extern int timer3ClockReload;
|
||||
extern int cpuTotalTicks;
|
||||
|
||||
#define CPUReadByteQuick(addr) \
|
||||
map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]
|
||||
|
||||
#define CPUReadHalfWordQuick(addr) \
|
||||
READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
|
||||
|
||||
#define CPUReadMemoryQuick(addr) \
|
||||
READ32LE(((u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
|
||||
|
||||
static inline u32 CPUReadMemory(u32 address)
|
||||
{
|
||||
|
||||
#ifdef DEV_VERSION
|
||||
if(address & 3) {
|
||||
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
|
||||
log("Unaligned word read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
u32 value;
|
||||
switch(address >> 24) {
|
||||
case 0:
|
||||
if(reg[15].I >> 24) {
|
||||
if(address < 0x4000) {
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal word read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
value = READ32LE(((u32 *)&biosProtected));
|
||||
}
|
||||
else goto unreadable;
|
||||
} else
|
||||
value = READ32LE(((u32 *)&bios[address & 0x3FFC]));
|
||||
break;
|
||||
case 2:
|
||||
value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC]));
|
||||
break;
|
||||
case 3:
|
||||
value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC]));
|
||||
break;
|
||||
case 4:
|
||||
if(linkenable && (address>=0x4000120||address<=0x4000126)&&lspeed)
|
||||
LinkSStop();
|
||||
if((address < 0x4000400) && ioReadable[address & 0x3fc]) {
|
||||
if(ioReadable[(address & 0x3fc) + 2])
|
||||
value = READ32LE(((u32 *)&ioMem[address & 0x3fC]));
|
||||
else
|
||||
value = READ16LE(((u16 *)&ioMem[address & 0x3fc]));
|
||||
} else goto unreadable;
|
||||
break;
|
||||
case 5:
|
||||
value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC]));
|
||||
break;
|
||||
case 6:
|
||||
address = (address & 0x1fffc);
|
||||
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
|
||||
{
|
||||
value = 0;
|
||||
break;
|
||||
}
|
||||
if ((address & 0x18000) == 0x18000)
|
||||
address &= 0x17fff;
|
||||
value = READ32LE(((u32 *)&vram[address]));
|
||||
break;
|
||||
case 7:
|
||||
value = READ32LE(((u32 *)&oam[address & 0x3FC]));
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
value = READ32LE(((u32 *)&rom[address&0x1FFFFFC]));
|
||||
break;
|
||||
case 13:
|
||||
if(cpuEEPROMEnabled)
|
||||
// no need to swap this
|
||||
return eepromRead(address);
|
||||
goto unreadable;
|
||||
case 14:
|
||||
if(cpuFlashEnabled | cpuSramEnabled)
|
||||
// no need to swap this
|
||||
return flashRead(address);
|
||||
// default
|
||||
default:
|
||||
unreadable:
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal word read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(cpuDmaHack || cpuDmaHack2) {
|
||||
value = cpuDmaLast;
|
||||
} else {
|
||||
if(armState) {
|
||||
value = CPUReadMemoryQuick(reg[15].I);
|
||||
} else {
|
||||
value = CPUReadHalfWordQuick(reg[15].I) |
|
||||
CPUReadHalfWordQuick(reg[15].I) << 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(address & 3) {
|
||||
#ifdef C_CORE
|
||||
int shift = (address & 3) << 3;
|
||||
value = (value >> shift) | (value << (32 - shift));
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
asm("and $3, %%ecx;"
|
||||
"shl $3 ,%%ecx;"
|
||||
"ror %%cl, %0"
|
||||
: "=r" (value)
|
||||
: "r" (value), "c" (address));
|
||||
#else
|
||||
__asm {
|
||||
mov ecx, address;
|
||||
and ecx, 3;
|
||||
shl ecx, 3;
|
||||
ror [dword ptr value], cl;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
extern u32 myROM[];
|
||||
|
||||
static inline u32 CPUReadHalfWord(u32 address)
|
||||
{
|
||||
#ifdef DEV_VERSION
|
||||
if(address & 1) {
|
||||
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
|
||||
log("Unaligned halfword read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
u32 value;
|
||||
|
||||
switch(address >> 24) {
|
||||
case 0:
|
||||
if (reg[15].I >> 24) {
|
||||
if(address < 0x4000) {
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal halfword read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
value = READ16LE(((u16 *)&biosProtected[address&2]));
|
||||
} else goto unreadable;
|
||||
} else
|
||||
value = READ16LE(((u16 *)&bios[address & 0x3FFE]));
|
||||
break;
|
||||
case 2:
|
||||
value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE]));
|
||||
break;
|
||||
case 3:
|
||||
value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe]));
|
||||
break;
|
||||
case 4:
|
||||
if(linkenable && (address>=0x4000120||address<=0x4000126)&&lspeed)
|
||||
LinkSStop();
|
||||
if((address < 0x4000400) && ioReadable[address & 0x3fe])
|
||||
{
|
||||
value = READ16LE(((u16 *)&ioMem[address & 0x3fe]));
|
||||
if (((address & 0x3fe)>0xFF) && ((address & 0x3fe)<0x10E))
|
||||
{
|
||||
if (((address & 0x3fe) == 0x100) && timer0On)
|
||||
value = 0xFFFF - ((timer0Ticks-cpuTotalTicks) >> timer0ClockReload);
|
||||
else
|
||||
if (((address & 0x3fe) == 0x104) && timer1On && !(TM1CNT & 4))
|
||||
value = 0xFFFF - ((timer1Ticks-cpuTotalTicks) >> timer1ClockReload);
|
||||
else
|
||||
if (((address & 0x3fe) == 0x108) && timer2On && !(TM2CNT & 4))
|
||||
value = 0xFFFF - ((timer2Ticks-cpuTotalTicks) >> timer2ClockReload);
|
||||
else
|
||||
if (((address & 0x3fe) == 0x10C) && timer3On && !(TM3CNT & 4))
|
||||
value = 0xFFFF - ((timer3Ticks-cpuTotalTicks) >> timer3ClockReload);
|
||||
}
|
||||
}
|
||||
else goto unreadable;
|
||||
break;
|
||||
case 5:
|
||||
value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe]));
|
||||
break;
|
||||
case 6:
|
||||
address = (address & 0x1fffe);
|
||||
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
|
||||
{
|
||||
value = 0;
|
||||
break;
|
||||
}
|
||||
if ((address & 0x18000) == 0x18000)
|
||||
address &= 0x17fff;
|
||||
value = READ16LE(((u16 *)&vram[address]));
|
||||
break;
|
||||
case 7:
|
||||
value = READ16LE(((u16 *)&oam[address & 0x3fe]));
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
if(address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8)
|
||||
value = rtcRead(address);
|
||||
else
|
||||
value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE]));
|
||||
break;
|
||||
case 13:
|
||||
if(cpuEEPROMEnabled)
|
||||
// no need to swap this
|
||||
return eepromRead(address);
|
||||
goto unreadable;
|
||||
case 14:
|
||||
if(cpuFlashEnabled | cpuSramEnabled)
|
||||
// no need to swap this
|
||||
return flashRead(address);
|
||||
// default
|
||||
default:
|
||||
unreadable:
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal halfword read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
if(cpuDmaHack2 || cpuDmaHack) {
|
||||
value = cpuDmaLast & 0xFFFF;
|
||||
} else {
|
||||
if(armState) {
|
||||
value = CPUReadHalfWordQuick(reg[15].I + (address & 2));
|
||||
} else {
|
||||
value = CPUReadHalfWordQuick(reg[15].I);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(address & 1) {
|
||||
value = (value >> 8) | (value << 24);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline u16 CPUReadHalfWordSigned(u32 address)
|
||||
{
|
||||
u16 value = CPUReadHalfWord(address);
|
||||
if((address & 1))
|
||||
value = (s8)value;
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline u8 CPUReadByte(u32 address)
|
||||
{
|
||||
switch(address >> 24) {
|
||||
case 0:
|
||||
if (reg[15].I >> 24) {
|
||||
if(address < 0x4000) {
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal byte read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
return biosProtected[address & 3];
|
||||
} else goto unreadable;
|
||||
}
|
||||
return bios[address & 0x3FFF];
|
||||
case 2:
|
||||
return workRAM[address & 0x3FFFF];
|
||||
case 3:
|
||||
return internalRAM[address & 0x7fff];
|
||||
case 4:
|
||||
if(linkenable&&(address>=0x4000120||address<=0x4000126)&&lspeed)
|
||||
LinkSStop();
|
||||
if((address < 0x4000400) && ioReadable[address & 0x3ff])
|
||||
return ioMem[address & 0x3ff];
|
||||
else goto unreadable;
|
||||
case 5:
|
||||
return paletteRAM[address & 0x3ff];
|
||||
case 6:
|
||||
address = (address & 0x1ffff);
|
||||
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
|
||||
return 0;
|
||||
if ((address & 0x18000) == 0x18000)
|
||||
address &= 0x17fff;
|
||||
return vram[address];
|
||||
case 7:
|
||||
return oam[address & 0x3ff];
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
return rom[address & 0x1FFFFFF];
|
||||
case 13:
|
||||
if(cpuEEPROMEnabled)
|
||||
return eepromRead(address);
|
||||
goto unreadable;
|
||||
case 14:
|
||||
if(cpuSramEnabled | cpuFlashEnabled)
|
||||
return flashRead(address);
|
||||
if(cpuEEPROMSensorEnabled) {
|
||||
switch(address & 0x00008f00) {
|
||||
case 0x8200:
|
||||
return systemGetSensorX() & 255;
|
||||
case 0x8300:
|
||||
return (systemGetSensorX() >> 8)|0x80;
|
||||
case 0x8400:
|
||||
return systemGetSensorY() & 255;
|
||||
case 0x8500:
|
||||
return systemGetSensorY() >> 8;
|
||||
}
|
||||
}
|
||||
// default
|
||||
default:
|
||||
unreadable:
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_READ) {
|
||||
log("Illegal byte read: %08x at %08x\n", address, armMode ?
|
||||
armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
if(cpuDmaHack || cpuDmaHack2) {
|
||||
return cpuDmaLast & 0xFF;
|
||||
} else {
|
||||
if(armState) {
|
||||
return CPUReadByteQuick(reg[15].I+(address & 3));
|
||||
} else {
|
||||
return CPUReadByteQuick(reg[15].I+(address & 1));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void CPUWriteMemory(u32 address, u32 value)
|
||||
{
|
||||
|
||||
#ifdef DEV_VERSION
|
||||
if(address & 3) {
|
||||
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
|
||||
log("Unaligned word write: %08x to %08x from %08x\n",
|
||||
value,
|
||||
address,
|
||||
armMode ? armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
switch(address >> 24) {
|
||||
case 0x02:
|
||||
#ifdef BKPT_SUPPORT
|
||||
if(*((u32 *)&freezeWorkRAM[address & 0x3FFFC]))
|
||||
cheatsWriteMemory(address & 0x203FFFC,
|
||||
value);
|
||||
else
|
||||
#endif
|
||||
WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value);
|
||||
break;
|
||||
case 0x03:
|
||||
#ifdef BKPT_SUPPORT
|
||||
if(*((u32 *)&freezeInternalRAM[address & 0x7ffc]))
|
||||
cheatsWriteMemory(address & 0x3007FFC,
|
||||
value);
|
||||
else
|
||||
#endif
|
||||
WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value);
|
||||
break;
|
||||
case 0x04:
|
||||
if(address < 0x4000400) {
|
||||
CPUUpdateRegister((address & 0x3FC), value & 0xFFFF);
|
||||
CPUUpdateRegister((address & 0x3FC) + 2, (value >> 16));
|
||||
} else goto unwritable;
|
||||
break;
|
||||
case 0x05:
|
||||
#ifdef BKPT_SUPPORT
|
||||
if(*((u32 *)&freezePRAM[address & 0x3fc]))
|
||||
cheatsWriteMemory(address & 0x70003FC,
|
||||
value);
|
||||
else
|
||||
#endif
|
||||
WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value);
|
||||
break;
|
||||
case 0x06:
|
||||
address = (address & 0x1fffc);
|
||||
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
|
||||
return;
|
||||
if ((address & 0x18000) == 0x18000)
|
||||
address &= 0x17fff;
|
||||
|
||||
#ifdef BKPT_SUPPORT
|
||||
if(*((u32 *)&freezeVRAM[address]))
|
||||
cheatsWriteMemory(address + 0x06000000, value);
|
||||
else
|
||||
#endif
|
||||
|
||||
WRITE32LE(((u32 *)&vram[address]), value);
|
||||
break;
|
||||
case 0x07:
|
||||
#ifdef BKPT_SUPPORT
|
||||
if(*((u32 *)&freezeOAM[address & 0x3fc]))
|
||||
cheatsWriteMemory(address & 0x70003FC,
|
||||
value);
|
||||
else
|
||||
#endif
|
||||
WRITE32LE(((u32 *)&oam[address & 0x3fc]), value);
|
||||
break;
|
||||
case 0x0D:
|
||||
if(cpuEEPROMEnabled) {
|
||||
eepromWrite(address, value);
|
||||
break;
|
||||
}
|
||||
goto unwritable;
|
||||
case 0x0E:
|
||||
if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) {
|
||||
(*cpuSaveGameFunc)(address, (u8)value);
|
||||
break;
|
||||
}
|
||||
// default
|
||||
default:
|
||||
unwritable:
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_ILLEGAL_WRITE) {
|
||||
log("Illegal word write: %08x to %08x from %08x\n",
|
||||
value,
|
||||
address,
|
||||
armMode ? armNextPC - 4 : armNextPC - 2);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //VBA_GBAinline_H
|
||||
|
|
222
src/Gfx.h
222
src/Gfx.h
|
@ -148,7 +148,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
|
|||
|
||||
int maskX = sizeX-1;
|
||||
int maskY = sizeY-1;
|
||||
|
||||
|
||||
bool mosaicOn = (control & 0x40) ? true : false;
|
||||
|
||||
int xxx = hofs & maskX;
|
||||
|
@ -169,26 +169,26 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
|
|||
if(sizeX > 256)
|
||||
screenBase += 0x400;
|
||||
}
|
||||
|
||||
|
||||
int yshift = ((yyy>>3)<<5);
|
||||
if((control) & 0x80) {
|
||||
u16 *screenSource = screenBase + 0x400 * (xxx>>8) + ((xxx & 255)>>3) + yshift;
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u16 data = READ16LE(screenSource);
|
||||
|
||||
|
||||
int tile = data & 0x3FF;
|
||||
int tileX = (xxx & 7);
|
||||
int tileY = yyy & 7;
|
||||
|
||||
|
||||
if(data & 0x0400)
|
||||
tileX = 7 - tileX;
|
||||
if(data & 0x0800)
|
||||
tileY = 7 - tileY;
|
||||
|
||||
|
||||
u8 color = charBase[tile * 64 + tileY * 8 + tileX];
|
||||
|
||||
|
||||
line[x] = color ? (READ16LE(&palette[color]) | prio): 0x80000000;
|
||||
|
||||
|
||||
if(data & 0x0400) {
|
||||
if(tileX == 0)
|
||||
screenSource++;
|
||||
|
@ -212,7 +212,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
|
|||
yshift;
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u16 data = READ16LE(screenSource);
|
||||
|
||||
|
||||
int tile = data & 0x3FF;
|
||||
int tileX = (xxx & 7);
|
||||
int tileY = yyy & 7;
|
||||
|
@ -229,7 +229,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
|
|||
} else {
|
||||
color &= 0x0F;
|
||||
}
|
||||
|
||||
|
||||
int pal = (READ16LE(screenSource)>>8) & 0xF0;
|
||||
line[x] = color ? (READ16LE(&palette[pal + color])|prio): 0x80000000;
|
||||
|
||||
|
@ -267,7 +267,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
|
|||
}
|
||||
}
|
||||
|
||||
static inline void gfxDrawRotScreen(u16 control,
|
||||
static inline void gfxDrawRotScreen(u16 control,
|
||||
u16 x_l, u16 x_h,
|
||||
u16 y_l, u16 y_h,
|
||||
u16 pa, u16 pb,
|
||||
|
@ -327,8 +327,8 @@ static inline void gfxDrawRotScreen(u16 control,
|
|||
currentY |= 0xF8000000;
|
||||
} else {
|
||||
currentY += dmy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int realX = currentX;
|
||||
int realY = currentY;
|
||||
|
||||
|
@ -338,10 +338,10 @@ static inline void gfxDrawRotScreen(u16 control,
|
|||
realX -= y*dmx;
|
||||
realY -= y*dmy;
|
||||
}
|
||||
|
||||
|
||||
int xxx = (realX >> 8);
|
||||
int yyy = (realY >> 8);
|
||||
|
||||
|
||||
if(control & 0x2000) {
|
||||
xxx %= sizeX;
|
||||
yyy %= sizeY;
|
||||
|
@ -350,7 +350,7 @@ static inline void gfxDrawRotScreen(u16 control,
|
|||
if(yyy < 0)
|
||||
yyy += sizeY;
|
||||
}
|
||||
|
||||
|
||||
if(control & 0x80) {
|
||||
for(int x = 0; x < 240; x++) {
|
||||
if(xxx < 0 ||
|
||||
|
@ -360,20 +360,20 @@ static inline void gfxDrawRotScreen(u16 control,
|
|||
line[x] = 0x80000000;
|
||||
} else {
|
||||
int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)];
|
||||
|
||||
|
||||
int tileX = (xxx & 7);
|
||||
int tileY = yyy & 7;
|
||||
|
||||
|
||||
u8 color = charBase[(tile<<6) + (tileY<<3) + tileX];
|
||||
|
||||
|
||||
line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;
|
||||
}
|
||||
realX += dx;
|
||||
realY += dy;
|
||||
|
||||
|
||||
xxx = (realX >> 8);
|
||||
yyy = (realY >> 8);
|
||||
|
||||
|
||||
if(control & 0x2000) {
|
||||
xxx %= sizeX;
|
||||
yyy %= sizeY;
|
||||
|
@ -392,20 +392,20 @@ static inline void gfxDrawRotScreen(u16 control,
|
|||
line[x] = 0x80000000;
|
||||
} else {
|
||||
int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)];
|
||||
|
||||
|
||||
int tileX = (xxx & 7);
|
||||
int tileY = yyy & 7;
|
||||
|
||||
|
||||
u8 color = charBase[(tile<<6) + (tileY<<3) + tileX];
|
||||
|
||||
|
||||
line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;
|
||||
}
|
||||
realX += dx;
|
||||
realY += dy;
|
||||
|
||||
|
||||
xxx = (realX >> 8);
|
||||
yyy = (realY >> 8);
|
||||
|
||||
|
||||
if(control & 0x2000) {
|
||||
xxx %= sizeX;
|
||||
yyy %= sizeY;
|
||||
|
@ -414,10 +414,10 @@ static inline void gfxDrawRotScreen(u16 control,
|
|||
if(yyy < 0)
|
||||
yyy += sizeY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(control & 0x40) {
|
||||
if(control & 0x40) {
|
||||
int mosaicX = (MOSAIC & 0xF) + 1;
|
||||
if(mosaicX > 1) {
|
||||
int m = 1;
|
||||
|
@ -430,7 +430,7 @@ static inline void gfxDrawRotScreen(u16 control,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void gfxDrawRotScreen16Bit(u16 control,
|
||||
|
@ -446,7 +446,7 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
|
|||
int prio = ((control & 3) << 25) + 0x1000000;
|
||||
int sizeX = 240;
|
||||
int sizeY = 160;
|
||||
|
||||
|
||||
int startX = (x_l) | ((x_h & 0x07FF)<<16);
|
||||
if(x_h & 0x0800)
|
||||
startX |= 0xF8000000;
|
||||
|
@ -469,7 +469,7 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
|
|||
|
||||
if(VCOUNT == 0)
|
||||
changed = 3;
|
||||
|
||||
|
||||
if(changed & 1) {
|
||||
currentX = (x_l) | ((x_h & 0x07FF)<<16);
|
||||
if(x_h & 0x0800)
|
||||
|
@ -483,8 +483,8 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
|
|||
currentY |= 0xF8000000;
|
||||
} else {
|
||||
currentY += dmy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int realX = currentX;
|
||||
int realY = currentY;
|
||||
|
||||
|
@ -494,10 +494,10 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
|
|||
realX -= y*dmx;
|
||||
realY -= y*dmy;
|
||||
}
|
||||
|
||||
|
||||
int xxx = (realX >> 8);
|
||||
int yyy = (realY >> 8);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
if(xxx < 0 ||
|
||||
yyy < 0 ||
|
||||
|
@ -509,12 +509,12 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
|
|||
}
|
||||
realX += dx;
|
||||
realY += dy;
|
||||
|
||||
|
||||
xxx = (realX >> 8);
|
||||
yyy = (realY >> 8);
|
||||
}
|
||||
|
||||
if(control & 0x40) {
|
||||
if(control & 0x40) {
|
||||
int mosaicX = (MOSAIC & 0xF) + 1;
|
||||
if(mosaicX > 1) {
|
||||
int m = 1;
|
||||
|
@ -527,10 +527,10 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void gfxDrawRotScreen256(u16 control,
|
||||
static inline void gfxDrawRotScreen256(u16 control,
|
||||
u16 x_l, u16 x_h,
|
||||
u16 y_l, u16 y_h,
|
||||
u16 pa, u16 pb,
|
||||
|
@ -544,7 +544,7 @@ static inline void gfxDrawRotScreen256(u16 control,
|
|||
int prio = ((control & 3) << 25) + 0x1000000;
|
||||
int sizeX = 240;
|
||||
int sizeY = 160;
|
||||
|
||||
|
||||
int startX = (x_l) | ((x_h & 0x07FF)<<16);
|
||||
if(x_h & 0x0800)
|
||||
startX |= 0xF8000000;
|
||||
|
@ -582,8 +582,8 @@ static inline void gfxDrawRotScreen256(u16 control,
|
|||
currentY |= 0xF8000000;
|
||||
} else {
|
||||
currentY += dmy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int realX = currentX;
|
||||
int realY = currentY;
|
||||
|
||||
|
@ -593,10 +593,10 @@ static inline void gfxDrawRotScreen256(u16 control,
|
|||
realX = startX + y*dmx;
|
||||
realY = startY + y*dmy;
|
||||
}
|
||||
|
||||
|
||||
int xxx = (realX >> 8);
|
||||
int yyy = (realY >> 8);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
if(xxx < 0 ||
|
||||
yyy < 0 ||
|
||||
|
@ -605,17 +605,17 @@ static inline void gfxDrawRotScreen256(u16 control,
|
|||
line[x] = 0x80000000;
|
||||
} else {
|
||||
u8 color = screenBase[yyy * 240 + xxx];
|
||||
|
||||
|
||||
line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;
|
||||
}
|
||||
realX += dx;
|
||||
realY += dy;
|
||||
|
||||
|
||||
xxx = (realX >> 8);
|
||||
yyy = (realY >> 8);
|
||||
}
|
||||
|
||||
if(control & 0x40) {
|
||||
if(control & 0x40) {
|
||||
int mosaicX = (MOSAIC & 0xF) + 1;
|
||||
if(mosaicX > 1) {
|
||||
int m = 1;
|
||||
|
@ -628,7 +628,7 @@ static inline void gfxDrawRotScreen256(u16 control,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void gfxDrawRotScreen16Bit160(u16 control,
|
||||
|
@ -645,7 +645,7 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
|
|||
int prio = ((control & 3) << 25) + 0x1000000;
|
||||
int sizeX = 160;
|
||||
int sizeY = 128;
|
||||
|
||||
|
||||
int startX = (x_l) | ((x_h & 0x07FF)<<16);
|
||||
if(x_h & 0x0800)
|
||||
startX |= 0xF8000000;
|
||||
|
@ -683,8 +683,8 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
|
|||
currentY |= 0xF8000000;
|
||||
} else {
|
||||
currentY += dmy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int realX = currentX;
|
||||
int realY = currentY;
|
||||
|
||||
|
@ -694,10 +694,10 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
|
|||
realX = startX + y*dmx;
|
||||
realY = startY + y*dmy;
|
||||
}
|
||||
|
||||
|
||||
int xxx = (realX >> 8);
|
||||
int yyy = (realY >> 8);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
if(xxx < 0 ||
|
||||
yyy < 0 ||
|
||||
|
@ -709,12 +709,12 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
|
|||
}
|
||||
realX += dx;
|
||||
realY += dy;
|
||||
|
||||
|
||||
xxx = (realX >> 8);
|
||||
yyy = (realY >> 8);
|
||||
}
|
||||
|
||||
if(control & 0x40) {
|
||||
if(control & 0x40) {
|
||||
int mosaicX = (MOSAIC & 0xF) + 1;
|
||||
if(mosaicX > 1) {
|
||||
int m = 1;
|
||||
|
@ -727,7 +727,7 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void gfxDrawSprites(u32 *lineOBJ)
|
||||
|
@ -742,7 +742,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
u16 *sprites = (u16 *)oam;
|
||||
u16 *spritePalette = &((u16 *)paletteRAM)[256];
|
||||
int mosaicY = ((MOSAIC & 0xF000)>>12) + 1;
|
||||
int mosaicX = ((MOSAIC & 0xF00)>>8) + 1;
|
||||
int mosaicX = ((MOSAIC & 0xF00)>>8) + 1;
|
||||
for(int x = 0; x < 128 ; x++) {
|
||||
u16 a0 = READ16LE(sprites++);
|
||||
u16 a1 = READ16LE(sprites++);
|
||||
|
@ -763,7 +763,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
a0 &= 0x3FFF;
|
||||
a1 &= 0x3FFF;
|
||||
}
|
||||
|
||||
|
||||
int sizeX = 8<<(a1>>14);
|
||||
int sizeY = sizeX;
|
||||
|
||||
|
@ -827,7 +827,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
continue;
|
||||
|
||||
|
||||
|
||||
|
||||
if(a0 & 0x0100) {
|
||||
int fieldX = sizeX;
|
||||
int fieldY = sizeY;
|
||||
|
@ -846,7 +846,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
}
|
||||
if (lineOBJpix>0)
|
||||
if((sx < 240) || startpix) {
|
||||
lineOBJpix-=8;
|
||||
lineOBJpix-=8;
|
||||
// int t2 = t - (fieldY >> 1);
|
||||
int rot = (a1 >> 9) & 0x1F;
|
||||
u16 *OAM = (u16 *)oam;
|
||||
|
@ -862,7 +862,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
int dmy = READ16LE(&OAM[15 + (rot << 4)]);
|
||||
if(dmy & 0x8000)
|
||||
dmy |= 0xFFFF8000;
|
||||
|
||||
|
||||
if(a0 & 0x1000) {
|
||||
t -= (t % mosaicY);
|
||||
}
|
||||
|
@ -873,7 +873,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
+ t * dmy;
|
||||
|
||||
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
|
||||
|
||||
|
||||
if(a0 & 0x2000) {
|
||||
int c = (a2 & 0x3FF);
|
||||
if((DISPCNT & 7) > 2 && (c < 512))
|
||||
|
@ -890,7 +890,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
continue;
|
||||
int xxx = realX >> 8;
|
||||
int yyy = realY >> 8;
|
||||
|
||||
|
||||
if(xxx < 0 || xxx >= sizeX ||
|
||||
yyy < 0 || yyy >= sizeY ||
|
||||
sx >= 240);
|
||||
|
@ -898,7 +898,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5)
|
||||
+ ((yyy & 7)<<3) + ((xxx >> 3)<<6) +
|
||||
(xxx & 7))&0x7FFF)];
|
||||
if ((color==0) && (((prio >> 25)&3) <
|
||||
if ((color==0) && (((prio >> 25)&3) <
|
||||
((lineOBJ[sx]>>25)&3))) {
|
||||
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
|
||||
if((a0 & 0x1000) && m)
|
||||
|
@ -927,7 +927,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
int c = (a2 & 0x3FF);
|
||||
if((DISPCNT & 7) > 2 && (c < 512))
|
||||
continue;
|
||||
|
||||
|
||||
int inc = 32;
|
||||
if(DISPCNT & 0x40)
|
||||
inc = sizeX >> 3;
|
||||
|
@ -950,8 +950,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
color >>= 4;
|
||||
else
|
||||
color &= 0x0F;
|
||||
|
||||
if ((color==0) && (((prio >> 25)&3) <
|
||||
|
||||
if ((color==0) && (((prio >> 25)&3) <
|
||||
((lineOBJ[sx]>>25)&3))) {
|
||||
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
|
||||
if((a0 & 0x1000) && m)
|
||||
|
@ -975,8 +975,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
sx = (sx+1)&511;
|
||||
realX += dx;
|
||||
realY += dy;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -998,7 +998,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
int c = (a2 & 0x3FF);
|
||||
if((DISPCNT & 7) > 2 && (c < 512))
|
||||
continue;
|
||||
|
||||
|
||||
int inc = 32;
|
||||
if(DISPCNT & 0x40) {
|
||||
inc = sizeX >> 2;
|
||||
|
@ -1015,11 +1015,11 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
|
||||
int address = 0x10000 + ((((c+ (t>>3) * inc) << 5)
|
||||
+ ((t & 7) << 3) + ((xxx>>3)<<6) + (xxx & 7)) & 0x7FFF);
|
||||
|
||||
|
||||
if(a1 & 0x1000)
|
||||
xxx = 7;
|
||||
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
|
||||
|
||||
|
||||
for(int xx = 0; xx < sizeX; xx++) {
|
||||
if (xx >= startpix)
|
||||
lineOBJpix--;
|
||||
|
@ -1027,7 +1027,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
continue;
|
||||
if(sx < 240) {
|
||||
u8 color = vram[address];
|
||||
if ((color==0) && (((prio >> 25)&3) <
|
||||
if ((color==0) && (((prio >> 25)&3) <
|
||||
((lineOBJ[sx]>>25)&3))) {
|
||||
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
|
||||
if((a0 & 0x1000) && m)
|
||||
|
@ -1049,7 +1049,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
lineOBJ[sx] = 0x001F;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
sx = (sx+1) & 511;
|
||||
if(a1 & 0x1000) {
|
||||
xxx--;
|
||||
|
@ -1077,7 +1077,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
int c = (a2 & 0x3FF);
|
||||
if((DISPCNT & 7) > 2 && (c < 512))
|
||||
continue;
|
||||
|
||||
|
||||
int inc = 32;
|
||||
if(DISPCNT & 0x40) {
|
||||
inc = sizeX >> 3;
|
||||
|
@ -1085,7 +1085,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
int xxx = 0;
|
||||
if(a1 & 0x1000)
|
||||
xxx = sizeX - 1;
|
||||
|
||||
|
||||
if(a0 & 0x1000) {
|
||||
t -= (t % mosaicY);
|
||||
}
|
||||
|
@ -1093,7 +1093,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
int address = 0x10000 + ((((c + (t>>3) * inc)<<5)
|
||||
+ ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7FFF);
|
||||
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
|
||||
int palette = (a2 >> 8) & 0xF0;
|
||||
int palette = (a2 >> 8) & 0xF0;
|
||||
if(a1 & 0x1000) {
|
||||
xxx = 7;
|
||||
for(int xx = sizeX - 1; xx >= 0; xx--) {
|
||||
|
@ -1107,8 +1107,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
color = (color >> 4);
|
||||
} else
|
||||
color &= 0x0F;
|
||||
|
||||
if ((color==0) && (((prio >> 25)&3) <
|
||||
|
||||
if ((color==0) && (((prio >> 25)&3) <
|
||||
((lineOBJ[sx]>>25)&3))) {
|
||||
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
|
||||
if((a0 & 0x1000) && m)
|
||||
|
@ -1138,8 +1138,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
}
|
||||
if(address < 0x10000)
|
||||
address += 0x8000;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
for(int xx = 0; xx < sizeX; xx++) {
|
||||
if (xx >= startpix)
|
||||
lineOBJpix--;
|
||||
|
@ -1151,8 +1151,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
color = (color >> 4);
|
||||
} else
|
||||
color &= 0x0F;
|
||||
|
||||
if ((color==0) && (((prio >> 25)&3) <
|
||||
|
||||
if ((color==0) && (((prio >> 25)&3) <
|
||||
((lineOBJ[sx]>>25)&3))) {
|
||||
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
|
||||
if((a0 & 0x1000) && m)
|
||||
|
@ -1183,7 +1183,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
|
|||
}
|
||||
if(address > 0x17fff)
|
||||
address -= 0x8000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1215,13 +1215,13 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
|
||||
if ((a0 & 0x0c00) == 0x0c00)
|
||||
a0 &=0xF3FF;
|
||||
|
||||
|
||||
if ((a0>>14) == 3)
|
||||
{
|
||||
a0 &= 0x3FFF;
|
||||
a1 &= 0x3FFF;
|
||||
}
|
||||
|
||||
|
||||
int sizeX = 8<<(a1>>14);
|
||||
int sizeY = sizeX;
|
||||
|
||||
|
@ -1241,7 +1241,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
}
|
||||
|
||||
int sy = (a0 & 255);
|
||||
|
||||
|
||||
if(a0 & 0x0100) {
|
||||
int fieldX = sizeX;
|
||||
int fieldY = sizeY;
|
||||
|
@ -1276,14 +1276,14 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
int dmy = READ16LE(&OAM[15 + (rot << 4)]);
|
||||
if(dmy & 0x8000)
|
||||
dmy |= 0xFFFF8000;
|
||||
|
||||
|
||||
int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx
|
||||
+ t * dmx;
|
||||
int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy
|
||||
+ t * dmy;
|
||||
|
||||
// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
|
||||
|
||||
|
||||
if(a0 & 0x2000) {
|
||||
int c = (a2 & 0x3FF);
|
||||
if((DISPCNT & 7) > 2 && (c < 512))
|
||||
|
@ -1300,7 +1300,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
continue;
|
||||
int xxx = realX >> 8;
|
||||
int yyy = realY >> 8;
|
||||
|
||||
|
||||
if(xxx < 0 || xxx >= sizeX ||
|
||||
yyy < 0 || yyy >= sizeY ||
|
||||
sx >= 240) {
|
||||
|
@ -1320,11 +1320,11 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
int c = (a2 & 0x3FF);
|
||||
if((DISPCNT & 7) > 2 && (c < 512))
|
||||
continue;
|
||||
|
||||
|
||||
int inc = 32;
|
||||
if(DISPCNT & 0x40)
|
||||
inc = sizeX >> 3;
|
||||
// int palette = (a2 >> 8) & 0xF0;
|
||||
// int palette = (a2 >> 8) & 0xF0;
|
||||
for(int x = 0; x < fieldX; x++) {
|
||||
if (x >= startpix)
|
||||
lineOBJpix-=2;
|
||||
|
@ -1348,7 +1348,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
color >>= 4;
|
||||
else
|
||||
color &= 0x0F;
|
||||
|
||||
|
||||
if(color) {
|
||||
lineOBJWin[sx] = 1;
|
||||
}
|
||||
|
@ -1357,7 +1357,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
sx = (sx+1)&511;
|
||||
realX += dx;
|
||||
realY += dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1380,7 +1380,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
int c = (a2 & 0x3FF);
|
||||
if((DISPCNT & 7) > 2 && (c < 512))
|
||||
continue;
|
||||
|
||||
|
||||
int inc = 32;
|
||||
if(DISPCNT & 0x40) {
|
||||
inc = sizeX >> 2;
|
||||
|
@ -1406,7 +1406,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
lineOBJWin[sx] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sx = (sx+1) & 511;
|
||||
if(a1 & 0x1000) {
|
||||
xxx--;
|
||||
|
@ -1434,7 +1434,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
int c = (a2 & 0x3FF);
|
||||
if((DISPCNT & 7) > 2 && (c < 512))
|
||||
continue;
|
||||
|
||||
|
||||
int inc = 32;
|
||||
if(DISPCNT & 0x40) {
|
||||
inc = sizeX >> 3;
|
||||
|
@ -1445,7 +1445,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
int address = 0x10000 + ((((c + (t>>3) * inc)<<5)
|
||||
+ ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7fff);
|
||||
// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
|
||||
// int palette = (a2 >> 8) & 0xF0;
|
||||
// int palette = (a2 >> 8) & 0xF0;
|
||||
if(a1 & 0x1000) {
|
||||
xxx = 7;
|
||||
for(int xx = sizeX - 1; xx >= 0; xx--) {
|
||||
|
@ -1459,7 +1459,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
color = (color >> 4);
|
||||
} else
|
||||
color &= 0x0F;
|
||||
|
||||
|
||||
if(color) {
|
||||
lineOBJWin[sx] = 1;
|
||||
}
|
||||
|
@ -1474,8 +1474,8 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
}
|
||||
if(address < 0x10000)
|
||||
address += 0x8000;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
for(int xx = 0; xx < sizeX; xx++) {
|
||||
if (xx >= startpix)
|
||||
lineOBJpix--;
|
||||
|
@ -1487,7 +1487,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
color = (color >> 4);
|
||||
} else
|
||||
color &= 0x0F;
|
||||
|
||||
|
||||
if(color) {
|
||||
lineOBJWin[sx] = 1;
|
||||
}
|
||||
|
@ -1502,7 +1502,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
|
|||
}
|
||||
if(address > 0x17fff)
|
||||
address -= 0x8000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1517,7 +1517,7 @@ static inline u32 gfxIncreaseBrightness(u32 color, int coeff)
|
|||
int r = (color & 0x1F);
|
||||
int g = ((color >> 5) & 0x1F);
|
||||
int b = ((color >> 10) & 0x1F);
|
||||
|
||||
|
||||
r = r + (((31 - r) * coeff) >> 4);
|
||||
g = g + (((31 - g) * coeff) >> 4);
|
||||
b = b + (((31 - b) * coeff) >> 4);
|
||||
|
@ -1538,7 +1538,7 @@ static inline void gfxIncreaseBrightness(u32 *line, int coeff)
|
|||
int r = (color & 0x1F);
|
||||
int g = ((color >> 5) & 0x1F);
|
||||
int b = ((color >> 10) & 0x1F);
|
||||
|
||||
|
||||
r = r + (((31 - r) * coeff) >> 4);
|
||||
g = g + (((31 - g) * coeff) >> 4);
|
||||
b = b + (((31 - b) * coeff) >> 4);
|
||||
|
@ -1557,7 +1557,7 @@ static inline u32 gfxDecreaseBrightness(u32 color, int coeff)
|
|||
int r = (color & 0x1F);
|
||||
int g = ((color >> 5) & 0x1F);
|
||||
int b = ((color >> 10) & 0x1F);
|
||||
|
||||
|
||||
r = r - ((r * coeff) >> 4);
|
||||
g = g - ((g * coeff) >> 4);
|
||||
b = b - ((b * coeff) >> 4);
|
||||
|
@ -1568,7 +1568,7 @@ static inline u32 gfxDecreaseBrightness(u32 color, int coeff)
|
|||
if(b < 0)
|
||||
b = 0;
|
||||
color = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
|
||||
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
@ -1579,7 +1579,7 @@ static inline void gfxDecreaseBrightness(u32 *line, int coeff)
|
|||
int r = (color & 0x1F);
|
||||
int g = ((color >> 5) & 0x1F);
|
||||
int b = ((color >> 10) & 0x1F);
|
||||
|
||||
|
||||
r = r - ((r * coeff) >> 4);
|
||||
g = g - ((g * coeff) >> 4);
|
||||
b = b - ((b * coeff) >> 4);
|
||||
|
@ -1602,7 +1602,7 @@ static inline u32 gfxAlphaBlend(u32 color, u32 color2, int ca, int cb)
|
|||
int r0 = (color2 & 0x1F);
|
||||
int g0 = ((color2 >> 5) & 0x1F);
|
||||
int b0 = ((color2 >> 10) & 0x1F);
|
||||
|
||||
|
||||
r = ((r * ca) + (r0 * cb)) >> 4;
|
||||
g = ((g * ca) + (g0 * cb)) >> 4;
|
||||
b = ((b * ca) + (b0 * cb)) >> 4;
|
||||
|
@ -1631,18 +1631,18 @@ static inline void gfxAlphaBlend(u32 *ta, u32 *tb, int ca, int cb)
|
|||
int r0 = (color2 & 0x1F);
|
||||
int g0 = ((color2 >> 5) & 0x1F);
|
||||
int b0 = ((color2 >> 10) & 0x1F);
|
||||
|
||||
|
||||
r = ((r * ca) + (r0 * cb)) >> 4;
|
||||
g = ((g * ca) + (g0 * cb)) >> 4;
|
||||
b = ((b * ca) + (b0 * cb)) >> 4;
|
||||
|
||||
|
||||
if(r > 31)
|
||||
r = 31;
|
||||
if(g > 31)
|
||||
g = 31;
|
||||
if(b > 31)
|
||||
b = 31;
|
||||
|
||||
|
||||
*ta++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
|
||||
} else {
|
||||
ta++;
|
||||
|
|
2166
src/Link.cpp
2166
src/Link.cpp
File diff suppressed because it is too large
Load Diff
248
src/Link.h
248
src/Link.h
|
@ -1,124 +1,124 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include<winsock.h>
|
||||
|
||||
#ifndef LINKH
|
||||
#define LINKH
|
||||
#define LINK_PARENTLOST 0x80
|
||||
#define UNSUPPORTED -1
|
||||
#define MULTIPLAYER 0
|
||||
#define NORMAL8 1
|
||||
#define NORMAL32 2
|
||||
#define UART 3
|
||||
#define JOYBUS 4
|
||||
#define GP 5
|
||||
#define RFU_INIT 0
|
||||
#define RFU_COMM 1
|
||||
#define RFU_SEND 2
|
||||
#define RFU_RECV 3
|
||||
|
||||
typedef struct {
|
||||
WORD linkdata[4];
|
||||
WORD linkcmd[4];
|
||||
WORD numtransfers;
|
||||
int lastlinktime;
|
||||
unsigned char numgbas;
|
||||
unsigned char linkflags;
|
||||
int rfu_q[4];
|
||||
u8 rfu_request[4];
|
||||
int rfu_linktime[4];
|
||||
u32 rfu_bdata[4][7];
|
||||
u32 rfu_data[4][32];
|
||||
} LINKDATA;
|
||||
|
||||
class lserver{
|
||||
int numbytes;
|
||||
fd_set fdset;
|
||||
timeval wsocktimeout;
|
||||
//timeval udptimeout;
|
||||
char inbuffer[256], outbuffer[256];
|
||||
int *intinbuffer;
|
||||
u16 *u16inbuffer;
|
||||
int *intoutbuffer;
|
||||
u16 *u16outbuffer;
|
||||
int counter;
|
||||
int done;
|
||||
public:
|
||||
int howmanytimes;
|
||||
SOCKET tcpsocket[4];
|
||||
SOCKADDR_IN udpaddr[4];
|
||||
lserver(void);
|
||||
int Init(void*);
|
||||
void Send(void);
|
||||
void Recv(void);
|
||||
};
|
||||
|
||||
class lclient{
|
||||
fd_set fdset;
|
||||
timeval wsocktimeout;
|
||||
char inbuffer[256], outbuffer[256];
|
||||
int *intinbuffer;
|
||||
u16 *u16inbuffer;
|
||||
int *intoutbuffer;
|
||||
u16 *u16outbuffer;
|
||||
int numbytes;
|
||||
public:
|
||||
bool oncesend;
|
||||
SOCKADDR_IN serverinfo;
|
||||
SOCKET noblock;
|
||||
int numtransfers;
|
||||
lclient(void);
|
||||
int Init(LPHOSTENT, void*);
|
||||
void Send(void);
|
||||
void Recv(void);
|
||||
void CheckConn(void);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
SOCKET tcpsocket;
|
||||
//SOCKET udpsocket;
|
||||
int numgbas;
|
||||
HANDLE thread;
|
||||
u8 type;
|
||||
u8 server;
|
||||
bool terminate;
|
||||
bool connected;
|
||||
bool speed;
|
||||
bool active;
|
||||
} LANLINKDATA;
|
||||
|
||||
extern void LinkUpdate(void);
|
||||
extern void LinkChildStop(void);
|
||||
extern void LinkChildSend(u16);
|
||||
extern int openLinkLog(void);
|
||||
extern void closeLinkLog();
|
||||
extern void CloseLanLink(void);
|
||||
extern char *MakeInstanceFilename(const char *Input);
|
||||
|
||||
extern LANLINKDATA lanlink;
|
||||
extern FILE *linklogfile;
|
||||
extern int vbaid;
|
||||
extern int linklog;
|
||||
extern bool adapter;
|
||||
extern bool linkenable;
|
||||
extern int linktimeout;
|
||||
extern lclient lc;
|
||||
extern int linkid;
|
||||
|
||||
#endif
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include<winsock.h>
|
||||
|
||||
#ifndef LINKH
|
||||
#define LINKH
|
||||
#define LINK_PARENTLOST 0x80
|
||||
#define UNSUPPORTED -1
|
||||
#define MULTIPLAYER 0
|
||||
#define NORMAL8 1
|
||||
#define NORMAL32 2
|
||||
#define UART 3
|
||||
#define JOYBUS 4
|
||||
#define GP 5
|
||||
#define RFU_INIT 0
|
||||
#define RFU_COMM 1
|
||||
#define RFU_SEND 2
|
||||
#define RFU_RECV 3
|
||||
|
||||
typedef struct {
|
||||
WORD linkdata[4];
|
||||
WORD linkcmd[4];
|
||||
WORD numtransfers;
|
||||
int lastlinktime;
|
||||
unsigned char numgbas;
|
||||
unsigned char linkflags;
|
||||
int rfu_q[4];
|
||||
u8 rfu_request[4];
|
||||
int rfu_linktime[4];
|
||||
u32 rfu_bdata[4][7];
|
||||
u32 rfu_data[4][32];
|
||||
} LINKDATA;
|
||||
|
||||
class lserver{
|
||||
int numbytes;
|
||||
fd_set fdset;
|
||||
timeval wsocktimeout;
|
||||
//timeval udptimeout;
|
||||
char inbuffer[256], outbuffer[256];
|
||||
int *intinbuffer;
|
||||
u16 *u16inbuffer;
|
||||
int *intoutbuffer;
|
||||
u16 *u16outbuffer;
|
||||
int counter;
|
||||
int done;
|
||||
public:
|
||||
int howmanytimes;
|
||||
SOCKET tcpsocket[4];
|
||||
SOCKADDR_IN udpaddr[4];
|
||||
lserver(void);
|
||||
int Init(void*);
|
||||
void Send(void);
|
||||
void Recv(void);
|
||||
};
|
||||
|
||||
class lclient{
|
||||
fd_set fdset;
|
||||
timeval wsocktimeout;
|
||||
char inbuffer[256], outbuffer[256];
|
||||
int *intinbuffer;
|
||||
u16 *u16inbuffer;
|
||||
int *intoutbuffer;
|
||||
u16 *u16outbuffer;
|
||||
int numbytes;
|
||||
public:
|
||||
bool oncesend;
|
||||
SOCKADDR_IN serverinfo;
|
||||
SOCKET noblock;
|
||||
int numtransfers;
|
||||
lclient(void);
|
||||
int Init(LPHOSTENT, void*);
|
||||
void Send(void);
|
||||
void Recv(void);
|
||||
void CheckConn(void);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
SOCKET tcpsocket;
|
||||
//SOCKET udpsocket;
|
||||
int numgbas;
|
||||
HANDLE thread;
|
||||
u8 type;
|
||||
u8 server;
|
||||
bool terminate;
|
||||
bool connected;
|
||||
bool speed;
|
||||
bool active;
|
||||
} LANLINKDATA;
|
||||
|
||||
extern void LinkUpdate(void);
|
||||
extern void LinkChildStop(void);
|
||||
extern void LinkChildSend(u16);
|
||||
extern int openLinkLog(void);
|
||||
extern void closeLinkLog();
|
||||
extern void CloseLanLink(void);
|
||||
extern char *MakeInstanceFilename(const char *Input);
|
||||
|
||||
extern LANLINKDATA lanlink;
|
||||
extern FILE *linklogfile;
|
||||
extern int vbaid;
|
||||
extern int linklog;
|
||||
extern bool adapter;
|
||||
extern bool linkenable;
|
||||
extern int linktimeout;
|
||||
extern lclient lc;
|
||||
extern int linkid;
|
||||
|
||||
#endif
|
||||
|
|
108
src/Mode0.cpp
108
src/Mode0.cpp
|
@ -30,7 +30,7 @@ void mode0RenderLine()
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0100) {
|
||||
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ void mode0RenderLine()
|
|||
if(layerEnable & 0x0200) {
|
||||
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0400) {
|
||||
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ void mode0RenderLine()
|
|||
gfxDrawSprites(lineOBJ);
|
||||
|
||||
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = backdrop;
|
||||
u8 top = 0x20;
|
||||
|
||||
|
||||
if(line0[x] < color) {
|
||||
color = line0[x];
|
||||
top = 0x01;
|
||||
|
@ -74,7 +74,7 @@ void mode0RenderLine()
|
|||
color = line3[x];
|
||||
top = 0x08;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) {
|
||||
color = lineOBJ[x];
|
||||
top = 0x10;
|
||||
|
@ -84,17 +84,17 @@ void mode0RenderLine()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line0[x];
|
||||
top2 = 0x01;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
|
@ -119,8 +119,8 @@ void mode0RenderLine()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lineMix[x] = color;
|
||||
|
@ -137,7 +137,7 @@ void mode0RenderLineNoWindow()
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0100) {
|
||||
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ void mode0RenderLineNoWindow()
|
|||
if(layerEnable & 0x0200) {
|
||||
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0400) {
|
||||
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
|
||||
}
|
||||
|
@ -159,11 +159,11 @@ void mode0RenderLineNoWindow()
|
|||
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
int effect = (BLDMOD >> 6) & 3;
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = backdrop;
|
||||
u8 top = 0x20;
|
||||
|
||||
|
||||
if(line0[x] < color) {
|
||||
color = line0[x];
|
||||
top = 0x01;
|
||||
|
@ -183,7 +183,7 @@ void mode0RenderLineNoWindow()
|
|||
color = line3[x];
|
||||
top = 0x08;
|
||||
}
|
||||
|
||||
|
||||
if(lineOBJ[x] < (color & 0xFF000000)) {
|
||||
color = lineOBJ[x];
|
||||
top = 0x10;
|
||||
|
@ -204,40 +204,40 @@ void mode0RenderLineNoWindow()
|
|||
top2 = 0x01;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(line1[x] < (back & 0xFF000000)) {
|
||||
if(top != 0x02) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(line2[x] < (back & 0xFF000000)) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(line3[x] < (back & 0xFF000000)) {
|
||||
if(top != 0x08) {
|
||||
back = line3[x];
|
||||
top2 = 0x08;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(lineOBJ[x] < (back & 0xFF000000)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
coeff[(COLEV >> 8) & 0x1F]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -254,17 +254,17 @@ void mode0RenderLineNoWindow()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if(line0[x] < back) {
|
||||
back = line0[x];
|
||||
top2 = 0x01;
|
||||
}
|
||||
|
||||
|
||||
if(line1[x] < (back & 0xFF000000)) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
|
||||
|
||||
if(line2[x] < (back & 0xFF000000)) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
|
@ -289,7 +289,7 @@ void mode0RenderLineNoWindow()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,13 +323,13 @@ void mode0RenderLineAll()
|
|||
if(layerEnable & 0x4000) {
|
||||
u8 v0 = WIN1V >> 8;
|
||||
u8 v1 = WIN1V & 255;
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
if(v1 >= v0)
|
||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||
else
|
||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||
}
|
||||
|
||||
|
||||
if((layerEnable & 0x0100)) {
|
||||
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ void mode0RenderLineAll()
|
|||
if((layerEnable & 0x0200)) {
|
||||
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
|
||||
}
|
||||
|
||||
|
||||
if((layerEnable & 0x0400)) {
|
||||
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
|
||||
}
|
||||
|
@ -347,14 +347,14 @@ void mode0RenderLineAll()
|
|||
}
|
||||
|
||||
gfxDrawSprites(lineOBJ);
|
||||
gfxDrawOBJWin(lineOBJWin);
|
||||
gfxDrawOBJWin(lineOBJWin);
|
||||
|
||||
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
u8 inWin0Mask = WININ & 0xFF;
|
||||
u8 inWin1Mask = WININ >> 8;
|
||||
u8 outMask = WINOUT & 0xFF;
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = backdrop;
|
||||
u8 top = 0x20;
|
||||
|
@ -374,32 +374,32 @@ void mode0RenderLineAll()
|
|||
mask = inWin0Mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 1) && (line0[x] < color)) {
|
||||
color = line0[x];
|
||||
top = 0x01;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(color >> 24))) {
|
||||
color = line1[x];
|
||||
top = 0x02;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(color >> 24))) {
|
||||
color = line2[x];
|
||||
top = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(color >> 24))) {
|
||||
color = line3[x];
|
||||
top = 0x08;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))) {
|
||||
color = lineOBJ[x];
|
||||
top = 0x10;
|
||||
}
|
||||
|
||||
|
||||
// special FX on in the window
|
||||
if(mask & 32) {
|
||||
if(!(color & 0x00010000)) {
|
||||
|
@ -417,35 +417,35 @@ void mode0RenderLineAll()
|
|||
top2 = 0x01;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x02) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x08) {
|
||||
back = line3[x];
|
||||
top2 = 0x08;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -466,27 +466,27 @@ void mode0RenderLineAll()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24))) {
|
||||
back = line0[x];
|
||||
top2 = 0x01;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24))) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24))) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24))) {
|
||||
back = line3[x];
|
||||
top2 = 0x08;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -501,34 +501,34 @@ void mode0RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(color & 0x00010000) {
|
||||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24))) {
|
||||
back = line0[x];
|
||||
top2 = 0x01;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24))) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24))) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24))) {
|
||||
back = line3[x];
|
||||
top2 = 0x08;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -543,10 +543,10 @@ void mode0RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,19 +23,19 @@
|
|||
void mode1RenderLine()
|
||||
{
|
||||
u16 *palette = (u16 *)paletteRAM;
|
||||
|
||||
|
||||
if(DISPCNT & 0x80) {
|
||||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
if(layerEnable & 0x0100) {
|
||||
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0200) {
|
||||
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
|
||||
}
|
||||
|
@ -81,17 +81,17 @@ void mode1RenderLine()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line0[x];
|
||||
top2 = 0x01;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
|
@ -111,25 +111,25 @@ void mode1RenderLine()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
||||
void mode1RenderLineNoWindow()
|
||||
{
|
||||
u16 *palette = (u16 *)paletteRAM;
|
||||
|
||||
|
||||
if(DISPCNT & 0x80) {
|
||||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ void mode1RenderLineNoWindow()
|
|||
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(layerEnable & 0x0200) {
|
||||
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
|
||||
}
|
||||
|
@ -194,28 +194,28 @@ void mode1RenderLineNoWindow()
|
|||
top2 = 0x01;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x02) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -236,17 +236,17 @@ void mode1RenderLineNoWindow()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line0[x];
|
||||
top2 = 0x01;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
|
@ -266,25 +266,25 @@ void mode1RenderLineNoWindow()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
||||
void mode1RenderLineAll()
|
||||
{
|
||||
u16 *palette = (u16 *)paletteRAM;
|
||||
|
||||
|
||||
if(DISPCNT & 0x80) {
|
||||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -303,17 +303,17 @@ void mode1RenderLineAll()
|
|||
if(layerEnable & 0x4000) {
|
||||
u8 v0 = WIN1V >> 8;
|
||||
u8 v1 = WIN1V & 255;
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
if(v1 >= v0)
|
||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||
else
|
||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0100) {
|
||||
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0200) {
|
||||
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
|
||||
}
|
||||
|
@ -329,13 +329,13 @@ void mode1RenderLineAll()
|
|||
|
||||
gfxDrawSprites(lineOBJ);
|
||||
gfxDrawOBJWin(lineOBJWin);
|
||||
|
||||
|
||||
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
u8 inWin0Mask = WININ & 0xFF;
|
||||
u8 inWin1Mask = WININ >> 8;
|
||||
u8 outMask = WINOUT & 0xFF;
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = backdrop;
|
||||
u8 top = 0x20;
|
||||
|
@ -355,7 +355,7 @@ void mode1RenderLineAll()
|
|||
mask = inWin0Mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(line0[x] < color && (mask & 1)) {
|
||||
color = line0[x];
|
||||
top = 0x01;
|
||||
|
@ -393,28 +393,28 @@ void mode1RenderLineAll()
|
|||
top2 = 0x01;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x02) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -435,22 +435,22 @@ void mode1RenderLineAll()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line0[x];
|
||||
top2 = 0x01;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -465,29 +465,29 @@ void mode1RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(color & 0x00010000) {
|
||||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line0[x];
|
||||
top2 = 0x01;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line1[x];
|
||||
top2 = 0x02;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -502,12 +502,12 @@ void mode1RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ void mode2RenderLine()
|
|||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0400) {
|
||||
int changed = gfxBG2Changed;
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||
BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y,
|
||||
changed, line2);
|
||||
|
@ -46,7 +46,7 @@ void mode2RenderLine()
|
|||
int changed = gfxBG3Changed;
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
|
||||
BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y,
|
||||
changed, line3);
|
||||
|
@ -80,12 +80,12 @@ void mode2RenderLine()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line3[x];
|
||||
top2 = 0x08;
|
||||
|
@ -105,15 +105,15 @@ void mode2RenderLine()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxBG3Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
||||
void mode2RenderLineNoWindow()
|
||||
|
@ -127,12 +127,12 @@ void mode2RenderLineNoWindow()
|
|||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0400) {
|
||||
int changed = gfxBG2Changed;
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||
BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y,
|
||||
changed, line2);
|
||||
|
@ -142,7 +142,7 @@ void mode2RenderLineNoWindow()
|
|||
int changed = gfxBG3Changed;
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
|
||||
BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y,
|
||||
changed, line3);
|
||||
|
@ -181,28 +181,28 @@ void mode2RenderLineNoWindow()
|
|||
if(top & BLDMOD) {
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x08) {
|
||||
back = line3[x];
|
||||
top2 = 0x08;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -223,12 +223,12 @@ void mode2RenderLineNoWindow()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line3[x];
|
||||
top2 = 0x08;
|
||||
|
@ -248,15 +248,15 @@ void mode2RenderLineNoWindow()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxBG3Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
||||
void mode2RenderLineAll()
|
||||
|
@ -286,18 +286,18 @@ void mode2RenderLineAll()
|
|||
if(layerEnable & 0x4000) {
|
||||
u8 v0 = WIN1V >> 8;
|
||||
u8 v1 = WIN1V & 255;
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
if(v1 >= v0)
|
||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||
else
|
||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0400) {
|
||||
int changed = gfxBG2Changed;
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||
BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y,
|
||||
changed, line2);
|
||||
|
@ -307,7 +307,7 @@ void mode2RenderLineAll()
|
|||
int changed = gfxBG3Changed;
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
|
||||
BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y,
|
||||
changed, line3);
|
||||
|
@ -325,8 +325,8 @@ void mode2RenderLineAll()
|
|||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = backdrop;
|
||||
u8 top = 0x20;
|
||||
u8 mask = outMask;
|
||||
|
||||
u8 mask = outMask;
|
||||
|
||||
if(!(lineOBJWin[x] & 0x80000000)) {
|
||||
mask = WINOUT >> 8;
|
||||
}
|
||||
|
@ -341,22 +341,22 @@ void mode2RenderLineAll()
|
|||
mask = inWin0Mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(line2[x] < color && (mask & 4)) {
|
||||
color = line2[x];
|
||||
top = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(line3[x]>>24) < (u8)(color >> 24) && (mask & 8)) {
|
||||
color = line3[x];
|
||||
top = 0x08;
|
||||
}
|
||||
|
||||
|
||||
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24) && (mask & 16)) {
|
||||
color = lineOBJ[x];
|
||||
top = 0x10;
|
||||
}
|
||||
|
||||
|
||||
if(mask & 32) {
|
||||
if(!(color & 0x00010000)) {
|
||||
switch((BLDMOD >> 6) & 3) {
|
||||
|
@ -367,32 +367,32 @@ void mode2RenderLineAll()
|
|||
if(top & BLDMOD) {
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x08) {
|
||||
back = line3[x];
|
||||
top2 = 0x08;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
coeff[(COLEV >> 8) & 0x1F]);
|
||||
coeff[(COLEV >> 8) & 0x1F]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -409,17 +409,17 @@ void mode2RenderLineAll()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line3[x];
|
||||
top2 = 0x08;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -434,24 +434,24 @@ void mode2RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(color & 0x00010000) {
|
||||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
|
||||
back = line3[x];
|
||||
top2 = 0x08;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -466,13 +466,13 @@ void mode2RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxBG3Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
|
100
src/Mode3.cpp
100
src/Mode3.cpp
|
@ -23,32 +23,32 @@
|
|||
void mode3RenderLine()
|
||||
{
|
||||
u16 *palette = (u16 *)paletteRAM;
|
||||
|
||||
|
||||
if(DISPCNT & 0x80) {
|
||||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
if(layerEnable & 0x0400) {
|
||||
int changed = gfxBG2Changed;
|
||||
|
||||
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
|
||||
BG2Y_L, BG2Y_H, BG2PA, BG2PB,
|
||||
BG2PC, BG2PD,
|
||||
gfxBG2X, gfxBG2Y, changed,
|
||||
gfxBG2X, gfxBG2Y, changed,
|
||||
line2);
|
||||
}
|
||||
|
||||
gfxDrawSprites(lineOBJ);
|
||||
|
||||
u32 background = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = background;
|
||||
u8 top = 0x20;
|
||||
|
@ -67,12 +67,12 @@ void mode3RenderLine()
|
|||
// semi-transparent OBJ
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if(line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -87,25 +87,25 @@ void mode3RenderLine()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
||||
void mode3RenderLineNoWindow()
|
||||
{
|
||||
u16 *palette = (u16 *)paletteRAM;
|
||||
|
||||
|
||||
if(DISPCNT & 0x80) {
|
||||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -114,18 +114,18 @@ void mode3RenderLineNoWindow()
|
|||
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
|
||||
BG2Y_L, BG2Y_H, BG2PA, BG2PB,
|
||||
BG2PC, BG2PD,
|
||||
gfxBG2X, gfxBG2Y, changed,
|
||||
gfxBG2X, gfxBG2Y, changed,
|
||||
line2);
|
||||
}
|
||||
|
||||
gfxDrawSprites(lineOBJ);
|
||||
|
||||
u32 background = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = background;
|
||||
u8 top = 0x20;
|
||||
|
@ -149,26 +149,26 @@ void mode3RenderLineNoWindow()
|
|||
if(top & BLDMOD) {
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if(line2[x] < back) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
coeff[(COLEV >> 8) & 0x1F]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -185,12 +185,12 @@ void mode3RenderLineNoWindow()
|
|||
// semi-transparent OBJ
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if(line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -205,25 +205,25 @@ void mode3RenderLineNoWindow()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
||||
void mode3RenderLineAll()
|
||||
{
|
||||
u16 *palette = (u16 *)paletteRAM;
|
||||
|
||||
|
||||
if(DISPCNT & 0x80) {
|
||||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -242,35 +242,35 @@ void mode3RenderLineAll()
|
|||
if(layerEnable & 0x4000) {
|
||||
u8 v0 = WIN1V >> 8;
|
||||
u8 v1 = WIN1V & 255;
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
if(v1 >= v0)
|
||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||
else
|
||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x0400) {
|
||||
int changed = gfxBG2Changed;
|
||||
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
|
||||
BG2Y_L, BG2Y_H, BG2PA, BG2PB,
|
||||
BG2PC, BG2PD,
|
||||
gfxBG2X, gfxBG2Y, changed,
|
||||
gfxBG2X, gfxBG2Y, changed,
|
||||
line2);
|
||||
}
|
||||
|
||||
gfxDrawSprites(lineOBJ);
|
||||
gfxDrawOBJWin(lineOBJWin);
|
||||
|
||||
|
||||
u8 inWin0Mask = WININ & 0xFF;
|
||||
u8 inWin1Mask = WININ >> 8;
|
||||
u8 outMask = WINOUT & 0xFF;
|
||||
|
||||
u32 background = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = background;
|
||||
u8 top = 0x20;
|
||||
|
@ -290,7 +290,7 @@ void mode3RenderLineAll()
|
|||
mask = inWin0Mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 4) && (line2[x] < color)) {
|
||||
color = line2[x];
|
||||
top = 0x04;
|
||||
|
@ -311,26 +311,26 @@ void mode3RenderLineAll()
|
|||
if(top & BLDMOD) {
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
coeff[(COLEV >> 8) & 0x1F]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -347,12 +347,12 @@ void mode3RenderLineAll()
|
|||
// semi-transparent OBJ
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -367,19 +367,19 @@ void mode3RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(color & 0x00010000) {
|
||||
// semi-transparent OBJ
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -394,12 +394,12 @@ void mode3RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ void mode4RenderLine()
|
|||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ void mode4RenderLine()
|
|||
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||
BG2PA, BG2PB, BG2PC, BG2PD,
|
||||
gfxBG2X, gfxBG2Y, changed,
|
||||
|
@ -47,7 +47,7 @@ void mode4RenderLine()
|
|||
gfxDrawSprites(lineOBJ);
|
||||
|
||||
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = backdrop;
|
||||
u8 top = 0x20;
|
||||
|
@ -66,12 +66,12 @@ void mode4RenderLine()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if(line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -86,14 +86,14 @@ void mode4RenderLine()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
||||
void mode4RenderLineNoWindow()
|
||||
|
@ -104,7 +104,7 @@ void mode4RenderLineNoWindow()
|
|||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ void mode4RenderLineNoWindow()
|
|||
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||
BG2PA, BG2PB, BG2PC, BG2PD,
|
||||
gfxBG2X, gfxBG2Y, changed,
|
||||
|
@ -123,7 +123,7 @@ void mode4RenderLineNoWindow()
|
|||
gfxDrawSprites(lineOBJ);
|
||||
|
||||
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = backdrop;
|
||||
u8 top = 0x20;
|
||||
|
@ -147,26 +147,26 @@ void mode4RenderLineNoWindow()
|
|||
if(top & BLDMOD) {
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if(line2[x] < back) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
coeff[(COLEV >> 8) & 0x1F]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -183,7 +183,7 @@ void mode4RenderLineNoWindow()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if(line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
|
@ -203,14 +203,14 @@ void mode4RenderLineNoWindow()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
||||
void mode4RenderLineAll()
|
||||
|
@ -221,7 +221,7 @@ void mode4RenderLineAll()
|
|||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -240,19 +240,19 @@ void mode4RenderLineAll()
|
|||
if(layerEnable & 0x4000) {
|
||||
u8 v0 = WIN1V >> 8;
|
||||
u8 v1 = WIN1V & 255;
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
if(v1 >= v0)
|
||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||
else
|
||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||
}
|
||||
|
||||
|
||||
if(layerEnable & 0x400) {
|
||||
int changed = gfxBG2Changed;
|
||||
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
|
||||
BG2PA, BG2PB, BG2PC, BG2PD,
|
||||
gfxBG2X, gfxBG2Y, changed,
|
||||
|
@ -260,18 +260,18 @@ void mode4RenderLineAll()
|
|||
}
|
||||
|
||||
gfxDrawSprites(lineOBJ);
|
||||
gfxDrawOBJWin(lineOBJWin);
|
||||
gfxDrawOBJWin(lineOBJWin);
|
||||
|
||||
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
u8 inWin0Mask = WININ & 0xFF;
|
||||
u8 inWin1Mask = WININ >> 8;
|
||||
u8 outMask = WINOUT & 0xFF;
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = backdrop;
|
||||
u8 top = 0x20;
|
||||
u8 mask = outMask;
|
||||
u8 mask = outMask;
|
||||
|
||||
if(!(lineOBJWin[x] & 0x80000000)) {
|
||||
mask = WINOUT >> 8;
|
||||
|
@ -287,7 +287,7 @@ void mode4RenderLineAll()
|
|||
mask = inWin0Mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 4) && (line2[x] < color)) {
|
||||
color = line2[x];
|
||||
top = 0x04;
|
||||
|
@ -308,26 +308,26 @@ void mode4RenderLineAll()
|
|||
if(top & BLDMOD) {
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
coeff[(COLEV >> 8) & 0x1F]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -344,12 +344,12 @@ void mode4RenderLineAll()
|
|||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -364,19 +364,19 @@ void mode4RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(color & 0x00010000) {
|
||||
// semi-transparent OBJ
|
||||
u32 back = backdrop;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -391,12 +391,12 @@ void mode4RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ void mode5RenderLine()
|
|||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ void mode5RenderLine()
|
|||
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
|
||||
BG2Y_L, BG2Y_H, BG2PA, BG2PB,
|
||||
BG2PC, BG2PD,
|
||||
|
@ -48,7 +48,7 @@ void mode5RenderLine()
|
|||
gfxDrawSprites(lineOBJ);
|
||||
|
||||
u32 background = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = background;
|
||||
u8 top = 0x20;
|
||||
|
@ -67,12 +67,12 @@ void mode5RenderLine()
|
|||
// semi-transparent OBJ
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if(line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -87,14 +87,14 @@ void mode5RenderLine()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
||||
void mode5RenderLineNoWindow()
|
||||
|
@ -103,7 +103,7 @@ void mode5RenderLineNoWindow()
|
|||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ void mode5RenderLineNoWindow()
|
|||
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
|
||||
BG2Y_L, BG2Y_H, BG2PA, BG2PB,
|
||||
BG2PC, BG2PD,
|
||||
|
@ -125,7 +125,7 @@ void mode5RenderLineNoWindow()
|
|||
gfxDrawSprites(lineOBJ);
|
||||
|
||||
u32 background = ( READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = background;
|
||||
u8 top = 0x20;
|
||||
|
@ -149,26 +149,26 @@ void mode5RenderLineNoWindow()
|
|||
if(top & BLDMOD) {
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if(line2[x] < back) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
coeff[(COLEV >> 8) & 0x1F]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -185,12 +185,12 @@ void mode5RenderLineNoWindow()
|
|||
// semi-transparent OBJ
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if(line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -205,14 +205,14 @@ void mode5RenderLineNoWindow()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
||||
void mode5RenderLineAll()
|
||||
|
@ -221,7 +221,7 @@ void mode5RenderLineAll()
|
|||
for(int x = 0; x < 240; x++) {
|
||||
lineMix[x] = 0x7fff;
|
||||
}
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ void mode5RenderLineAll()
|
|||
|
||||
if(gfxLastVCOUNT > VCOUNT)
|
||||
changed = 3;
|
||||
|
||||
|
||||
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
|
||||
BG2Y_L, BG2Y_H, BG2PA, BG2PB,
|
||||
BG2PC, BG2PD,
|
||||
|
@ -258,19 +258,19 @@ void mode5RenderLineAll()
|
|||
if(layerEnable & 0x4000) {
|
||||
u8 v0 = WIN1V >> 8;
|
||||
u8 v1 = WIN1V & 255;
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
|
||||
if(v1 >= v0)
|
||||
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
|
||||
else
|
||||
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
|
||||
}
|
||||
|
||||
|
||||
u8 inWin0Mask = WININ & 0xFF;
|
||||
u8 inWin1Mask = WININ >> 8;
|
||||
u8 outMask = WINOUT & 0xFF;
|
||||
|
||||
u32 background = (READ16LE(&palette[0]) | 0x30000000);
|
||||
|
||||
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u32 color = background;
|
||||
u8 top = 0x20;
|
||||
|
@ -311,26 +311,26 @@ void mode5RenderLineAll()
|
|||
if(top & BLDMOD) {
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
if(top != 0x04) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
|
||||
if(top != 0x10) {
|
||||
back = lineOBJ[x];
|
||||
top2 = 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
coeff[(COLEV >> 8) & 0x1F]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -347,12 +347,12 @@ void mode5RenderLineAll()
|
|||
// semi-transparent OBJ
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -367,19 +367,19 @@ void mode5RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(color & 0x00010000) {
|
||||
// semi-transparent OBJ
|
||||
u32 back = background;
|
||||
u8 top2 = 0x20;
|
||||
|
||||
|
||||
if((mask & 4) && line2[x] < back) {
|
||||
back = line2[x];
|
||||
top2 = 0x04;
|
||||
}
|
||||
|
||||
|
||||
if(top2 & (BLDMOD>>8))
|
||||
color = gfxAlphaBlend(color, back,
|
||||
coeff[COLEV & 0x1F],
|
||||
|
@ -394,12 +394,12 @@ void mode5RenderLineAll()
|
|||
if(BLDMOD & top)
|
||||
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lineMix[x] = color;
|
||||
}
|
||||
gfxBG2Changed = 0;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
gfxLastVCOUNT = VCOUNT;
|
||||
}
|
||||
|
|
|
@ -47,10 +47,10 @@ static inline u32 swap32(u32 v)
|
|||
|
||||
#define WRITE16LE(base, value) \
|
||||
__asm__ ("sthbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory")
|
||||
|
||||
|
||||
#define WRITE32LE(base, value) \
|
||||
__asm__ ("stwbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory")
|
||||
|
||||
|
||||
#else
|
||||
#define READ16LE(x) \
|
||||
swap16(*((u16 *)(x)))
|
||||
|
|
14
src/RTC.cpp
14
src/RTC.cpp
|
@ -67,7 +67,7 @@ u16 rtcRead(u32 address)
|
|||
return rtcClockData.byte0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return READ16LE((&rom[address & 0x1FFFFFE]));
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ bool rtcWrite(u32 address, u16 value)
|
|||
{
|
||||
if(!rtcEnabled)
|
||||
return false;
|
||||
|
||||
|
||||
if(address == 0x80000c8) {
|
||||
rtcClockData.byte2 = (u8)value; // enable ?
|
||||
} else if(address == 0x80000c6) {
|
||||
|
@ -95,7 +95,7 @@ bool rtcWrite(u32 address, u16 value)
|
|||
rtcClockData.bits = 0;
|
||||
rtcClockData.command = 0;
|
||||
} else if(!(rtcClockData.byte0 & 1) && (value & 1)) { // bit transfer
|
||||
rtcClockData.byte0 = (u8)value;
|
||||
rtcClockData.byte0 = (u8)value;
|
||||
switch(rtcClockData.state) {
|
||||
case COMMAND:
|
||||
rtcClockData.command |= ((value & 2) >> 1) << (7-rtcClockData.bits);
|
||||
|
@ -128,7 +128,7 @@ bool rtcWrite(u32 address, u16 value)
|
|||
|
||||
time( &long_time ); /* Get time as long integer. */
|
||||
newtime = localtime( &long_time ); /* Convert to local time. */
|
||||
|
||||
|
||||
rtcClockData.dataLen = 7;
|
||||
rtcClockData.data[0] = toBCD(newtime->tm_year);
|
||||
rtcClockData.data[1] = toBCD(newtime->tm_mon+1);
|
||||
|
@ -139,7 +139,7 @@ bool rtcWrite(u32 address, u16 value)
|
|||
rtcClockData.data[6] = toBCD(newtime->tm_sec);
|
||||
rtcClockData.state = DATA;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0x67:
|
||||
{
|
||||
struct tm *newtime;
|
||||
|
@ -147,7 +147,7 @@ bool rtcWrite(u32 address, u16 value)
|
|||
|
||||
time( &long_time ); /* Get time as long integer. */
|
||||
newtime = localtime( &long_time ); /* Convert to local time. */
|
||||
|
||||
|
||||
rtcClockData.dataLen = 3;
|
||||
rtcClockData.data[0] = toBCD(newtime->tm_hour);
|
||||
rtcClockData.data[1] = toBCD(newtime->tm_min);
|
||||
|
@ -201,7 +201,7 @@ bool rtcWrite(u32 address, u16 value)
|
|||
void rtcReset()
|
||||
{
|
||||
memset(&rtcClockData, 0, sizeof(rtcClockData));
|
||||
|
||||
|
||||
rtcClockData.byte0 = 0;
|
||||
rtcClockData.byte1 = 0;
|
||||
rtcClockData.byte2 = 0;
|
||||
|
|
3008
src/Sound.cpp
3008
src/Sound.cpp
File diff suppressed because it is too large
Load Diff
180
src/Sound.h
180
src/Sound.h
|
@ -1,90 +1,90 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
// Copyright (C) 2004-2006 VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef VBA_SOUND_H
|
||||
#define VBA_SOUND_H
|
||||
|
||||
#include "System.h"
|
||||
|
||||
#define NR10 0x60
|
||||
#define NR11 0x62
|
||||
#define NR12 0x63
|
||||
#define NR13 0x64
|
||||
#define NR14 0x65
|
||||
#define NR21 0x68
|
||||
#define NR22 0x69
|
||||
#define NR23 0x6c
|
||||
#define NR24 0x6d
|
||||
#define NR30 0x70
|
||||
#define NR31 0x72
|
||||
#define NR32 0x73
|
||||
#define NR33 0x74
|
||||
#define NR34 0x75
|
||||
#define NR41 0x78
|
||||
#define NR42 0x79
|
||||
#define NR43 0x7c
|
||||
#define NR44 0x7d
|
||||
#define NR50 0x80
|
||||
#define NR51 0x81
|
||||
#define NR52 0x84
|
||||
#define SGCNT0_H 0x82
|
||||
#define FIFOA_L 0xa0
|
||||
#define FIFOA_H 0xa2
|
||||
#define FIFOB_L 0xa4
|
||||
#define FIFOB_H 0xa6
|
||||
|
||||
extern void setSoundFn();
|
||||
extern void (*psoundTickfn)();
|
||||
extern void soundShutdown();
|
||||
extern bool soundInit();
|
||||
extern void soundPause();
|
||||
extern void soundResume();
|
||||
extern void soundEnable(int);
|
||||
extern void soundDisable(int);
|
||||
extern int soundGetEnable();
|
||||
extern void soundReset();
|
||||
extern void soundSaveGame(gzFile);
|
||||
extern void soundReadGame(gzFile, int);
|
||||
extern void soundEvent(u32, u8);
|
||||
extern void soundEvent(u32, u16);
|
||||
extern void soundTimerOverflow(int);
|
||||
extern void soundSetQuality(int);
|
||||
extern void setsystemSoundOn(bool value);
|
||||
extern void setsoundPaused(bool value);
|
||||
extern void setsoundMasterOn(bool value);
|
||||
extern void interp_rate();
|
||||
|
||||
extern int SOUND_CLOCK_TICKS;
|
||||
extern int soundTicks;
|
||||
extern bool soundOffFlag;
|
||||
extern bool soundPaused;
|
||||
extern int soundQuality;
|
||||
extern int soundBufferLen;
|
||||
extern int soundBufferTotalLen;
|
||||
extern u32 soundNextPosition;
|
||||
extern u16 soundFinalWave[1470];
|
||||
extern int soundVolume;
|
||||
extern int soundInterpolation;
|
||||
|
||||
extern bool soundEcho;
|
||||
extern bool soundLowPass;
|
||||
extern bool soundReverse;
|
||||
|
||||
#endif // VBA_SOUND_H
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
// Copyright (C) 2004-2006 VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef VBA_SOUND_H
|
||||
#define VBA_SOUND_H
|
||||
|
||||
#include "System.h"
|
||||
|
||||
#define NR10 0x60
|
||||
#define NR11 0x62
|
||||
#define NR12 0x63
|
||||
#define NR13 0x64
|
||||
#define NR14 0x65
|
||||
#define NR21 0x68
|
||||
#define NR22 0x69
|
||||
#define NR23 0x6c
|
||||
#define NR24 0x6d
|
||||
#define NR30 0x70
|
||||
#define NR31 0x72
|
||||
#define NR32 0x73
|
||||
#define NR33 0x74
|
||||
#define NR34 0x75
|
||||
#define NR41 0x78
|
||||
#define NR42 0x79
|
||||
#define NR43 0x7c
|
||||
#define NR44 0x7d
|
||||
#define NR50 0x80
|
||||
#define NR51 0x81
|
||||
#define NR52 0x84
|
||||
#define SGCNT0_H 0x82
|
||||
#define FIFOA_L 0xa0
|
||||
#define FIFOA_H 0xa2
|
||||
#define FIFOB_L 0xa4
|
||||
#define FIFOB_H 0xa6
|
||||
|
||||
extern void setSoundFn();
|
||||
extern void (*psoundTickfn)();
|
||||
extern void soundShutdown();
|
||||
extern bool soundInit();
|
||||
extern void soundPause();
|
||||
extern void soundResume();
|
||||
extern void soundEnable(int);
|
||||
extern void soundDisable(int);
|
||||
extern int soundGetEnable();
|
||||
extern void soundReset();
|
||||
extern void soundSaveGame(gzFile);
|
||||
extern void soundReadGame(gzFile, int);
|
||||
extern void soundEvent(u32, u8);
|
||||
extern void soundEvent(u32, u16);
|
||||
extern void soundTimerOverflow(int);
|
||||
extern void soundSetQuality(int);
|
||||
extern void setsystemSoundOn(bool value);
|
||||
extern void setsoundPaused(bool value);
|
||||
extern void setsoundMasterOn(bool value);
|
||||
extern void interp_rate();
|
||||
|
||||
extern int SOUND_CLOCK_TICKS;
|
||||
extern int soundTicks;
|
||||
extern bool soundOffFlag;
|
||||
extern bool soundPaused;
|
||||
extern int soundQuality;
|
||||
extern int soundBufferLen;
|
||||
extern int soundBufferTotalLen;
|
||||
extern u32 soundNextPosition;
|
||||
extern u16 soundFinalWave[1470];
|
||||
extern int soundVolume;
|
||||
extern int soundInterpolation;
|
||||
|
||||
extern bool soundEcho;
|
||||
extern bool soundLowPass;
|
||||
extern bool soundReverse;
|
||||
|
||||
#endif // VBA_SOUND_H
|
||||
|
|
|
@ -58,7 +58,7 @@ struct EmulatedSystem {
|
|||
// write battery file
|
||||
bool (*emuWriteBattery)(const char *);
|
||||
// load state
|
||||
bool (*emuReadState)(const char *);
|
||||
bool (*emuReadState)(const char *);
|
||||
// save state
|
||||
bool (*emuWriteState)(const char *);
|
||||
// load memory state (rewind)
|
||||
|
|
18
src/Text.cpp
18
src/Text.cpp
|
@ -35,7 +35,7 @@ static const u8 fontdata2[2048] = {
|
|||
0x00,0x00,0x6e,0x3b,0x13,0x3b,0x6e,0x00,0x00,0x1e,0x33,0x1f,0x33,0x1f,0x03,0x03,0x00,0x3f,0x33,0x03,0x03,0x03,0x03,0x00,0x00,0x7f,0x36,0x36,0x36,0x36,0x36,0x00,0x3f,0x33,0x06,0x0c,0x06,0x33,0x3f,0x00,0x00,0x00,0x7e,0x1b,0x1b,0x1b,0x0e,0x00,0x00,0x66,0x66,0x66,0x66,0x3e,0x06,0x03,0x00,0x6e,0x3b,0x18,0x18,0x18,0x18,0x00,0x3f,0x0c,0x1e,0x33,0x33,0x1e,0x0c,0x3f,0x1c,0x36,0x63,0x7f,0x63,0x36,0x1c,0x00,0x1c,0x36,0x63,0x63,0x36,0x36,0x77,0x00,0x38,0x0c,0x18,0x3e,0x33,0x33,0x1e,0x00,0x00,0x00,0x7e,0xdb,0xdb,0x7e,0x00,0x00,0x60,0x30,0x7e,0xdb,0xdb,0x7e,0x06,0x03,0x1c,0x06,0x03,0x1f,0x03,0x06,0x1c,0x00,0x1e,0x33,0x33,0x33,0x33,0x33,0x33,0x00,0x00,0x3f,0x00,0x3f,0x00,0x3f,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x3f,0x00,0x06,0x0c,0x18,0x0c,0x06,0x00,0x3f,0x00,0x18,0x0c,0x06,0x0c,0x18,0x00,0x3f,0x00,0x70,0xd8,0xd8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1b,0x1b,0x0e,0x0c,0x0c,0x00,0x3f,0x00,0x0c,0x0c,0x00,0x00,0x6e,0x3b,0x00,0x6e,0x3b,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0xf0,0x30,0x30,0x30,0x37,0x36,0x3c,0x38,0x1e,0x36,0x36,0x36,0x36,0x00,0x00,0x00,0x0e,0x18,0x0c,0x06,0x1e,0x00,0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
};
|
||||
|
||||
static void drawTextInternal(u8 *screen, int pitch, int x, int y,
|
||||
static void drawTextInternal(u8 *screen, int pitch, int x, int y,
|
||||
const char *string, bool trans)
|
||||
{
|
||||
screen += y*pitch;
|
||||
|
@ -56,14 +56,14 @@ static void drawTextInternal(u8 *screen, int pitch, int x, int y,
|
|||
while(*string) {
|
||||
char c = *string++;
|
||||
u8 *scr = screen;
|
||||
|
||||
|
||||
u16 mask = ~RGB_LOW_BITS_MASK;
|
||||
int h, w;
|
||||
u16 *s = (u16 *)scr;
|
||||
for (h = 0; h < 8; h++) {
|
||||
for (w = 0; w < 8; w++, s++) {
|
||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
||||
|
||||
|
||||
if(trans) {
|
||||
if(on)
|
||||
*s = ((0xf) << systemRedShift) +
|
||||
|
@ -85,13 +85,13 @@ static void drawTextInternal(u8 *screen, int pitch, int x, int y,
|
|||
while(*string) {
|
||||
char c = *string++;
|
||||
u8 *scr = screen;
|
||||
|
||||
|
||||
int h, w;
|
||||
u8 *s = (u8 *)scr;
|
||||
for (h = 0; h < 8; h++) {
|
||||
for (w = 0; w < 8; w++, s+=3) {
|
||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
||||
|
||||
|
||||
if(trans) {
|
||||
if(on) {
|
||||
u32 color = (0x1f) << systemRedShift;
|
||||
|
@ -114,20 +114,20 @@ static void drawTextInternal(u8 *screen, int pitch, int x, int y,
|
|||
screen += inc*8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 32:
|
||||
{
|
||||
while(*string) {
|
||||
char c = *string++;
|
||||
u8 *scr = screen;
|
||||
|
||||
|
||||
int h, w;
|
||||
u32 mask = 0xfefefe;
|
||||
u32 *s = (u32 *)scr;
|
||||
for (h = 0; h < 8; h++) {
|
||||
for (w = 0; w < 8; w++, s++) {
|
||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
||||
|
||||
|
||||
if(trans) {
|
||||
if(on)
|
||||
*s = ((0xf) << systemRedShift) + ((*s & mask)>>1);
|
||||
|
@ -142,7 +142,7 @@ static void drawTextInternal(u8 *screen, int pitch, int x, int y,
|
|||
screen += inc*8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2370
src/Util.cpp
2370
src/Util.cpp
File diff suppressed because it is too large
Load Diff
|
@ -63,14 +63,14 @@ static void internal_scale2x_16_def(u16 *dst, const u16* src0, const u16* src1,
|
|||
dst[0] = src1[0];
|
||||
dst[1] = src1[0];
|
||||
}
|
||||
|
||||
|
||||
++src0;
|
||||
++src1;
|
||||
++src2;
|
||||
dst += 2;
|
||||
--count;
|
||||
}
|
||||
|
||||
|
||||
/* last pixel */
|
||||
if (src1[-1] == src0[0] && src2[0] != src0[0])
|
||||
dst[0] = src0[0];
|
||||
|
@ -83,7 +83,7 @@ static void internal_scale2x_32_def(u32* dst,
|
|||
const u32* src0,
|
||||
const u32* src1,
|
||||
const u32* src2,
|
||||
unsigned count)
|
||||
unsigned count)
|
||||
{
|
||||
/* first pixel */
|
||||
dst[0] = src1[0];
|
||||
|
@ -95,7 +95,7 @@ static void internal_scale2x_32_def(u32* dst,
|
|||
++src1;
|
||||
++src2;
|
||||
dst += 2;
|
||||
|
||||
|
||||
/* central pixels */
|
||||
count -= 2;
|
||||
while (count) {
|
||||
|
@ -106,14 +106,14 @@ static void internal_scale2x_32_def(u32* dst,
|
|||
dst[0] = src1[0];
|
||||
dst[1] = src1[0];
|
||||
}
|
||||
|
||||
|
||||
++src0;
|
||||
++src1;
|
||||
++src2;
|
||||
dst += 2;
|
||||
--count;
|
||||
}
|
||||
|
||||
|
||||
/* last pixel */
|
||||
if (src1[-1] == src0[0] && src2[0] != src0[0])
|
||||
dst[0] = src0[0];
|
||||
|
@ -127,7 +127,7 @@ static void internal_scale2x_16_mmx_single(u16* dst, const u16* src0, const u16*
|
|||
/* always do the first and last run */
|
||||
count -= 2*4;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef __GNUC__
|
||||
__asm__ __volatile__(
|
||||
/* first run */
|
||||
/* set the current, current_pre, current_next registers */
|
||||
|
@ -317,7 +317,7 @@ static void internal_scale2x_16_mmx_single(u16* dst, const u16* src0, const u16*
|
|||
mov ecx, src2;
|
||||
mov edx, dst;
|
||||
mov esi, count;
|
||||
|
||||
|
||||
/* first run */
|
||||
/* set the current, current_pre, current_next registers */
|
||||
movq mm0, qword ptr [ebx];
|
||||
|
@ -437,7 +437,7 @@ static void internal_scale2x_16_mmx_single(u16* dst, const u16* src0, const u16*
|
|||
add ebx,8;
|
||||
add ecx,8;
|
||||
add edx,16;
|
||||
|
||||
|
||||
dec esi;
|
||||
jnz label0;
|
||||
label1:
|
||||
|
@ -699,7 +699,7 @@ static void internal_scale2x_32_mmx_single(u32* dst, const u32* src0, const u32*
|
|||
mov ecx, src2;
|
||||
mov edx, dst;
|
||||
mov esi, count;
|
||||
|
||||
|
||||
/* first run */
|
||||
/* set the current, current_pre, current_next registers */
|
||||
movq mm0,qword ptr [ebx];
|
||||
|
@ -762,7 +762,7 @@ static void internal_scale2x_32_mmx_single(u32* dst, const u32* src0, const u32*
|
|||
shr esi,1;
|
||||
jz label1;
|
||||
label0:
|
||||
|
||||
|
||||
/* set the current, current_pre, current_next registers */
|
||||
movq mm0,qword ptr [ebx-8];
|
||||
movq mm7,qword ptr [ebx];
|
||||
|
@ -822,7 +822,7 @@ label0:
|
|||
dec esi;
|
||||
jnz label0;
|
||||
label1:
|
||||
|
||||
|
||||
/* final run */
|
||||
/* set the current, current_pre, current_next registers */
|
||||
movq mm1,qword ptr [ebx];
|
||||
|
@ -904,14 +904,14 @@ void AdMame2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
{
|
||||
u16 *dst0 = (u16 *)dstPtr;
|
||||
u16 *dst1 = dst0 + (dstPitch >> 1);
|
||||
|
||||
|
||||
u16 *src0 = (u16 *)srcPtr;
|
||||
u16 *src1 = src0 + (srcPitch >> 1);
|
||||
u16 *src2 = src1 + (srcPitch >> 1);
|
||||
#ifdef MMX
|
||||
if(cpu_mmx) {
|
||||
internal_scale2x_16_mmx(dst0, dst1, src0, src0, src1, width);
|
||||
|
||||
|
||||
int count = height;
|
||||
|
||||
count -= 2;
|
||||
|
@ -931,7 +931,7 @@ void AdMame2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
#endif
|
||||
internal_scale2x_16_def(dst0, src0, src0, src1, width);
|
||||
internal_scale2x_16_def(dst1, src1, src0, src0, width);
|
||||
|
||||
|
||||
int count = height;
|
||||
|
||||
count -= 2;
|
||||
|
@ -959,14 +959,14 @@ void AdMame2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
{
|
||||
u32 *dst0 = (u32 *)dstPtr;
|
||||
u32 *dst1 = dst0 + (dstPitch >> 2);
|
||||
|
||||
|
||||
u32 *src0 = (u32 *)srcPtr;
|
||||
u32 *src1 = src0 + (srcPitch >> 2);
|
||||
u32 *src2 = src1 + (srcPitch >> 2);
|
||||
#ifdef MMX
|
||||
if(cpu_mmx) {
|
||||
internal_scale2x_32_mmx(dst0, dst1, src0, src0, src1, width);
|
||||
|
||||
|
||||
int count = height;
|
||||
|
||||
count -= 2;
|
||||
|
@ -986,7 +986,7 @@ void AdMame2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
#endif
|
||||
internal_scale2x_32_def(dst0, src0, src0, src1, width);
|
||||
internal_scale2x_32_def(dst1, src1, src0, src0, width);
|
||||
|
||||
|
||||
int count = height;
|
||||
|
||||
count -= 2;
|
||||
|
|
|
@ -68,7 +68,7 @@ bool agbPrintIsEnabled()
|
|||
}
|
||||
|
||||
extern void (*dbgOutput)(const char *, u32);
|
||||
|
||||
|
||||
void agbPrintFlush()
|
||||
{
|
||||
u16 get = debuggerReadHalfWord(0x9fe20fc);
|
||||
|
@ -78,7 +78,7 @@ void agbPrintFlush()
|
|||
if(address != 0xfd0000 && address != 0x1fd0000) {
|
||||
dbgOutput("Did you forget to call AGBPrintInit?\n", 0);
|
||||
// get rid of the text otherwise we will continue to be called
|
||||
debuggerWriteHalfWord(0x9fe20fc, put);
|
||||
debuggerWriteHalfWord(0x9fe20fc, put);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
164
src/arm-new.h
164
src/arm-new.h
|
@ -442,7 +442,7 @@
|
|||
C_FLAG = (Flags >> 25) & 1; \
|
||||
V_FLAG = (Flags >> 26) & 1; \
|
||||
}
|
||||
|
||||
|
||||
#define LOGICAL_LSL_REG \
|
||||
{\
|
||||
u32 v = reg[opcode & 0x0f].I;\
|
||||
|
@ -666,14 +666,14 @@
|
|||
asm("ror %%cl, %%eax;"\
|
||||
"setcb %%cl;"\
|
||||
: "=a" (value), "=c" (C_OUT)\
|
||||
: "a" (reg[opcode & 0x0f].I), "c" (shift));
|
||||
: "a" (reg[opcode & 0x0f].I), "c" (shift));
|
||||
|
||||
#define LOGICAL_RRX_REG \
|
||||
asm("bt $0, C_FLAG;"\
|
||||
"rcr $1, %%eax;"\
|
||||
"setcb %%cl;"\
|
||||
: "=a" (value), "=c" (C_OUT)\
|
||||
: "a" (reg[opcode & 0x0f].I));
|
||||
: "a" (reg[opcode & 0x0f].I));
|
||||
|
||||
#define LOGICAL_ROR_IMM \
|
||||
asm("ror %%cl, %%eax;"\
|
||||
|
@ -702,14 +702,14 @@
|
|||
asm("\
|
||||
ror %%cl, %%eax;"\
|
||||
: "=a" (value)\
|
||||
: "a" (reg[opcode & 0x0f].I), "c" (shift));
|
||||
: "a" (reg[opcode & 0x0f].I), "c" (shift));
|
||||
|
||||
#define ARITHMETIC_RRX_REG \
|
||||
asm("\
|
||||
bt $0, C_FLAG;\
|
||||
rcr $1, %%eax;"\
|
||||
: "=a" (value)\
|
||||
: "a" (reg[opcode & 0x0f].I));
|
||||
: "a" (reg[opcode & 0x0f].I));
|
||||
|
||||
#define ARITHMETIC_ROR_IMM \
|
||||
asm("\
|
||||
|
@ -2410,13 +2410,13 @@
|
|||
if(cond == 0x0e) {
|
||||
cond_res = true;
|
||||
} else {
|
||||
switch(cond) {
|
||||
case 0x00: // EQ
|
||||
switch(cond) {
|
||||
case 0x00: // EQ
|
||||
cond_res = Z_FLAG;
|
||||
break;
|
||||
case 0x01: // NE
|
||||
cond_res = !Z_FLAG;
|
||||
break;
|
||||
break;
|
||||
case 0x02: // CS
|
||||
cond_res = C_FLAG;
|
||||
break;
|
||||
|
@ -2449,12 +2449,12 @@
|
|||
break;
|
||||
case 0x0C: // GT
|
||||
cond_res = !Z_FLAG &&(N_FLAG == V_FLAG);
|
||||
break;
|
||||
break;
|
||||
case 0x0D: // LE
|
||||
cond_res = Z_FLAG || (N_FLAG != V_FLAG);
|
||||
break;
|
||||
case 0x0E:
|
||||
cond_res = true;
|
||||
break;
|
||||
case 0x0E:
|
||||
cond_res = true;
|
||||
break;
|
||||
case 0x0F:
|
||||
default:
|
||||
|
@ -2463,7 +2463,7 @@
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(cond_res) {
|
||||
switch(((opcode>>16)&0xFF0) | ((opcode>>4)&0x0F)) {
|
||||
LOGICAL_DATA_OPCODE_WITHOUT_base(OP_AND, OP_AND, 0x000);
|
||||
|
@ -2473,7 +2473,7 @@ if(cond_res) {
|
|||
// MUL Rd, Rm, Rs
|
||||
int dest = (opcode >> 16) & 0x0F;
|
||||
int mult = (opcode & 0x0F);
|
||||
clockTicks = 1;
|
||||
clockTicks = 1;
|
||||
u32 rs = reg[(opcode >> 8) & 0x0F].I;
|
||||
reg[dest].I = reg[mult].I * rs;
|
||||
if(((s32)rs)<0)
|
||||
|
@ -3605,7 +3605,7 @@ if(cond_res) {
|
|||
clockTicks = 2;
|
||||
u32 umult = reg[(opcode & 0x0F)].I;
|
||||
u32 usource = reg[(opcode >> 8) & 0x0F].I;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destHi = (opcode >> 16) & 0x0F;
|
||||
u64 uTemp = ((u64)umult)*((u64)usource);
|
||||
reg[destLo].I = (u32)uTemp;
|
||||
|
@ -3629,7 +3629,7 @@ if(cond_res) {
|
|||
clockTicks = 2;
|
||||
u32 umult = reg[(opcode & 0x0F)].I;
|
||||
u32 usource = reg[(opcode >> 8) & 0x0F].I;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destHi = (opcode >> 16) & 0x0F;
|
||||
u64 uTemp = ((u64)umult)*((u64)usource);
|
||||
reg[destLo].I = (u32)uTemp;
|
||||
|
@ -3657,7 +3657,7 @@ if(cond_res) {
|
|||
clockTicks = 3;
|
||||
u32 umult = reg[(opcode & 0x0F)].I;
|
||||
u32 usource = reg[(opcode >> 8) & 0x0F].I;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destHi = (opcode >> 16) & 0x0F;
|
||||
u64 uTemp = (u64)reg[destHi].I;
|
||||
uTemp <<= 32;
|
||||
|
@ -3684,7 +3684,7 @@ if(cond_res) {
|
|||
clockTicks = 3;
|
||||
u32 umult = reg[(opcode & 0x0F)].I;
|
||||
u32 usource = reg[(opcode >> 8) & 0x0F].I;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destHi = (opcode >> 16) & 0x0F;
|
||||
u64 uTemp = (u64)reg[destHi].I;
|
||||
uTemp <<= 32;
|
||||
|
@ -3713,7 +3713,7 @@ if(cond_res) {
|
|||
{
|
||||
// SMULL RdLo, RdHi, Rm, Rs
|
||||
clockTicks = 2;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destHi = (opcode >> 16) & 0x0F;
|
||||
u32 rs = reg[(opcode >> 8) & 0x0F].I;
|
||||
s64 m = (s32)reg[(opcode & 0x0F)].I;
|
||||
|
@ -3740,7 +3740,7 @@ if(cond_res) {
|
|||
{
|
||||
// SMULLS RdLo, RdHi, Rm, Rs
|
||||
clockTicks = 2;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destHi = (opcode >> 16) & 0x0F;
|
||||
u32 rs = reg[(opcode >> 8) & 0x0F].I;
|
||||
s64 m = (s32)reg[(opcode & 0x0F)].I;
|
||||
|
@ -3771,7 +3771,7 @@ if(cond_res) {
|
|||
{
|
||||
// SMLAL RdLo, RdHi, Rm, Rs
|
||||
clockTicks = codeTicksAccess32(armNextPC) + 4;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destHi = (opcode >> 16) & 0x0F;
|
||||
u32 rs = reg[(opcode >> 8) & 0x0F].I;
|
||||
s64 m = (s32)reg[(opcode & 0x0F)].I;
|
||||
|
@ -3800,7 +3800,7 @@ if(cond_res) {
|
|||
{
|
||||
// SMLALS RdLo, RdHi, Rm, Rs
|
||||
clockTicks = codeTicksAccess32(armNextPC) + 4;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destLo = (opcode >> 12) & 0x0F;
|
||||
int destHi = (opcode >> 16) & 0x0F;
|
||||
u32 rs = reg[(opcode >> 8) & 0x0F].I;
|
||||
s64 m = (s32)reg[(opcode & 0x0F)].I;
|
||||
|
@ -4030,7 +4030,7 @@ if(cond_res) {
|
|||
}
|
||||
break;
|
||||
CASE_16(0x400)
|
||||
// T versions shouldn't be different on GBA
|
||||
// T versions shouldn't be different on GBA
|
||||
CASE_16(0x420)
|
||||
{
|
||||
// STR Rd, [Rn], -#
|
||||
|
@ -4310,7 +4310,7 @@ if(cond_res) {
|
|||
}
|
||||
break;
|
||||
CASE_16(0x440)
|
||||
// T versions shouldn't be different on GBA
|
||||
// T versions shouldn't be different on GBA
|
||||
CASE_16(0x460)
|
||||
{
|
||||
// STRB Rd, [Rn], -#
|
||||
|
@ -4825,7 +4825,7 @@ if(cond_res) {
|
|||
int dest = (opcode >> 12) & 15;
|
||||
int base = (opcode >> 16) & 15;
|
||||
u32 address = reg[base].I - offset;
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
CPUWriteMemory(address, reg[dest].I);
|
||||
clockTicks = 2 + dataTicksAccess32(address) +
|
||||
codeTicksAccess32(armNextPC);
|
||||
|
@ -4870,7 +4870,7 @@ if(cond_res) {
|
|||
int dest = (opcode >> 12) & 15;
|
||||
int base = (opcode >> 16) & 15;
|
||||
u32 address = reg[base].I - value;
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
CPUWriteMemory(address, reg[dest].I);
|
||||
clockTicks = 2 + dataTicksAccess32(address) +
|
||||
codeTicksAccess32(armNextPC);
|
||||
|
@ -4977,7 +4977,7 @@ if(cond_res) {
|
|||
int dest = (opcode >> 12) & 15;
|
||||
int base = (opcode >> 16) & 15;
|
||||
u32 address = reg[base].I + offset;
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
CPUWriteMemory(address, reg[dest].I);
|
||||
clockTicks = 2 + dataTicksAccess32(address) +
|
||||
codeTicksAccess32(armNextPC);
|
||||
|
@ -5022,7 +5022,7 @@ if(cond_res) {
|
|||
int dest = (opcode >> 12) & 15;
|
||||
int base = (opcode >> 16) & 15;
|
||||
u32 address = reg[base].I + value;
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
CPUWriteMemory(address, reg[dest].I);
|
||||
clockTicks = 2 + dataTicksAccess32(address) +
|
||||
codeTicksAccess32(armNextPC);
|
||||
|
@ -5424,7 +5424,7 @@ if(cond_res) {
|
|||
u32 address = reg[base].I - offset;
|
||||
reg[dest].I = CPUReadMemory(address);
|
||||
if(dest != base)
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
clockTicks = 0;
|
||||
if(dest == 15) {
|
||||
reg[15].I &= 0xFFFFFFFC;
|
||||
|
@ -5487,7 +5487,7 @@ if(cond_res) {
|
|||
u32 address = reg[base].I - value;
|
||||
reg[dest].I = CPUReadMemory(address);
|
||||
if(dest != base)
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
clockTicks = 0;
|
||||
if(dest == 15) {
|
||||
reg[15].I &= 0xFFFFFFFC;
|
||||
|
@ -5644,7 +5644,7 @@ if(cond_res) {
|
|||
u32 address = reg[base].I + offset;
|
||||
reg[dest].I = CPUReadMemory(address);
|
||||
if(dest != base)
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
clockTicks = 0;
|
||||
if(dest == 15) {
|
||||
reg[15].I &= 0xFFFFFFFC;
|
||||
|
@ -6001,7 +6001,7 @@ if(cond_res) {
|
|||
int dest = (opcode >> 12) & 15;
|
||||
int base = (opcode >> 16) & 15;
|
||||
u32 address = reg[base].I - offset;
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
CPUWriteByte(address, reg[dest].B.B0);
|
||||
clockTicks = 2 + dataTicksAccess16(address) +
|
||||
codeTicksAccess32(armNextPC);
|
||||
|
@ -6046,7 +6046,7 @@ if(cond_res) {
|
|||
int dest = (opcode >> 12) & 15;
|
||||
int base = (opcode >> 16) & 15;
|
||||
u32 address = reg[base].I - value;
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
CPUWriteByte(address, reg[dest].B.B0);
|
||||
clockTicks = 2 + dataTicksAccess16(address) +
|
||||
codeTicksAccess32(armNextPC);
|
||||
|
@ -6153,7 +6153,7 @@ if(cond_res) {
|
|||
int dest = (opcode >> 12) & 15;
|
||||
int base = (opcode >> 16) & 15;
|
||||
u32 address = reg[base].I + offset;
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
CPUWriteByte(address, reg[dest].B.B0);
|
||||
clockTicks = 2 + dataTicksAccess16(address) +
|
||||
codeTicksAccess32(armNextPC);
|
||||
|
@ -6198,7 +6198,7 @@ if(cond_res) {
|
|||
int dest = (opcode >> 12) & 15;
|
||||
int base = (opcode >> 16) & 15;
|
||||
u32 address = reg[base].I + value;
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
CPUWriteByte(address, reg[dest].B.B0);
|
||||
clockTicks = 2 + dataTicksAccess16(address) +
|
||||
codeTicksAccess32(armNextPC);
|
||||
|
@ -6600,7 +6600,7 @@ if(cond_res) {
|
|||
u32 address = reg[base].I - offset;
|
||||
reg[dest].I = CPUReadByte(address);
|
||||
if(dest != base)
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
clockTicks = 0;
|
||||
if(dest == 15) {
|
||||
reg[15].I &= 0xFFFFFFFC;
|
||||
|
@ -6663,7 +6663,7 @@ if(cond_res) {
|
|||
u32 address = reg[base].I - value;
|
||||
reg[dest].I = CPUReadByte(address);
|
||||
if(dest != base)
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
clockTicks = 0;
|
||||
if(dest == 15) {
|
||||
reg[15].I &= 0xFFFFFFFC;
|
||||
|
@ -6820,7 +6820,7 @@ if(cond_res) {
|
|||
u32 address = reg[base].I + offset;
|
||||
reg[dest].I = CPUReadByte(address);
|
||||
if(dest != base)
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
clockTicks = 0;
|
||||
if(dest == 15) {
|
||||
reg[15].I &= 0xFFFFFFFC;
|
||||
|
@ -6883,7 +6883,7 @@ if(cond_res) {
|
|||
u32 address = reg[base].I + value;
|
||||
reg[dest].I = CPUReadByte(address);
|
||||
if(dest != base)
|
||||
reg[base].I = address;
|
||||
reg[base].I = address;
|
||||
clockTicks = 0;
|
||||
if(dest == 15) {
|
||||
reg[15].I &= 0xFFFFFFFC;
|
||||
|
@ -6919,14 +6919,14 @@ if(cond_res) {
|
|||
}\
|
||||
address += 4;\
|
||||
}
|
||||
|
||||
|
||||
CASE_16(0x800)
|
||||
{
|
||||
// STMDA Rn, {Rlist}
|
||||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||
int offset = 0;
|
||||
|
@ -6961,7 +6961,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = (temp+4) & 0xFFFFFFFC;
|
||||
int offset = 0;
|
||||
|
@ -6998,7 +6998,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = (temp+4) & 0xFFFFFFFC;
|
||||
int offset = 0;
|
||||
|
@ -7050,7 +7050,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = (temp+4) & 0xFFFFFFFC;
|
||||
int offset = 0;
|
||||
|
@ -7097,7 +7097,7 @@ if(cond_res) {
|
|||
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
CASE_16(0x880)
|
||||
{
|
||||
// STMIA Rn, {Rlist}
|
||||
|
@ -7194,7 +7194,7 @@ if(cond_res) {
|
|||
STM_REG(512, 9);
|
||||
STM_REG(1024, 10);
|
||||
STM_REG(2048, 11);
|
||||
STM_REG(4096, 12);
|
||||
STM_REG(4096, 12);
|
||||
}
|
||||
if(armMode != 0x10 && armMode != 0x1f) {
|
||||
STM_REG(8192, R13_USR);
|
||||
|
@ -7222,7 +7222,7 @@ if(cond_res) {
|
|||
u32 address = reg[base].I & 0xFFFFFFFC;
|
||||
int offset = 0;
|
||||
u32 temp = reg[base].I + 4*(cpuBitsSet[opcode & 0xFF] +
|
||||
cpuBitsSet[(opcode >> 8) & 255]);
|
||||
cpuBitsSet[(opcode >> 8) & 255]);
|
||||
STMW_REG(1, 0);
|
||||
STMW_REG(2, 1);
|
||||
STMW_REG(4, 2);
|
||||
|
@ -7242,7 +7242,7 @@ if(cond_res) {
|
|||
STMW_REG(512, 9);
|
||||
STMW_REG(1024, 10);
|
||||
STMW_REG(2048, 11);
|
||||
STMW_REG(4096, 12);
|
||||
STMW_REG(4096, 12);
|
||||
}
|
||||
if(armMode != 0x10 && armMode != 0x1f) {
|
||||
STMW_REG(8192, R13_USR);
|
||||
|
@ -7262,14 +7262,14 @@ if(cond_res) {
|
|||
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
CASE_16(0x900)
|
||||
{
|
||||
// STMDB Rn, {Rlist}
|
||||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = temp & 0xFFFFFFFC;
|
||||
int offset = 0;
|
||||
|
@ -7304,7 +7304,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = temp & 0xFFFFFFFC;
|
||||
int offset = 0;
|
||||
|
@ -7341,7 +7341,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = temp & 0xFFFFFFFC;
|
||||
int offset = 0;
|
||||
|
@ -7393,7 +7393,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = temp & 0xFFFFFFFC;
|
||||
int offset = 0;
|
||||
|
@ -7537,7 +7537,7 @@ if(cond_res) {
|
|||
STM_REG(512, 9);
|
||||
STM_REG(1024, 10);
|
||||
STM_REG(2048, 11);
|
||||
STM_REG(4096, 12);
|
||||
STM_REG(4096, 12);
|
||||
}
|
||||
if(armMode != 0x10 && armMode != 0x1f) {
|
||||
STM_REG(8192, R13_USR);
|
||||
|
@ -7565,7 +7565,7 @@ if(cond_res) {
|
|||
u32 address = (reg[base].I+4) & 0xFFFFFFFC;
|
||||
int offset = 0;
|
||||
u32 temp = reg[base].I + 4*(cpuBitsSet[opcode & 0xFF] +
|
||||
cpuBitsSet[(opcode >> 8) & 255]);
|
||||
cpuBitsSet[(opcode >> 8) & 255]);
|
||||
STMW_REG(1, 0);
|
||||
STMW_REG(2, 1);
|
||||
STMW_REG(4, 2);
|
||||
|
@ -7585,7 +7585,7 @@ if(cond_res) {
|
|||
STMW_REG(512, 9);
|
||||
STMW_REG(1024, 10);
|
||||
STMW_REG(2048, 11);
|
||||
STMW_REG(4096, 12);
|
||||
STMW_REG(4096, 12);
|
||||
}
|
||||
if(armMode != 0x10 && armMode != 0x1f) {
|
||||
STMW_REG(8192, R13_USR);
|
||||
|
@ -7605,7 +7605,7 @@ if(cond_res) {
|
|||
clockTicks += 1 + codeTicksAccess32(armNextPC);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
#define LDM_REG(val,num) \
|
||||
if(opcode & (val)) {\
|
||||
reg[(num)].I = CPUReadMemory(address);\
|
||||
|
@ -7624,7 +7624,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||
clockTicks = 0;
|
||||
|
@ -7664,7 +7664,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||
clockTicks = 0;
|
||||
|
@ -7707,7 +7707,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||
clockTicks = 0;
|
||||
|
@ -7787,7 +7787,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = (temp + 4) & 0xFFFFFFFC;
|
||||
clockTicks = 0;
|
||||
|
@ -7811,7 +7811,7 @@ if(cond_res) {
|
|||
|
||||
reg[15].I = CPUReadMemory(address);
|
||||
|
||||
if(!(opcode & (1 << base)))
|
||||
if(!(opcode & (1 << base)))
|
||||
reg[base].I = temp;
|
||||
|
||||
CPUSwitchMode(reg[17].I & 0x1f, false);
|
||||
|
@ -7856,7 +7856,7 @@ if(cond_res) {
|
|||
LDM_REG(16384, 14);
|
||||
}
|
||||
|
||||
if(!(opcode & (1 << base)))
|
||||
if(!(opcode & (1 << base)))
|
||||
reg[base].I = temp;
|
||||
if (!offset)
|
||||
clockTicks += 1 + dataTicksAccess32(address);
|
||||
|
@ -7867,7 +7867,7 @@ if(cond_res) {
|
|||
clockTicks += 2 + codeTicksAccess32(armNextPC);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
CASE_16(0x890)
|
||||
{
|
||||
// LDMIA Rn, {Rlist}
|
||||
|
@ -7913,7 +7913,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I +
|
||||
u32 temp = reg[base].I +
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = reg[base].I & 0xFFFFFFFC;
|
||||
clockTicks = 0;
|
||||
|
@ -8058,7 +8058,7 @@ if(cond_res) {
|
|||
|
||||
reg[15].I = CPUReadMemory(address);
|
||||
|
||||
if(!(opcode & (1 << base)))
|
||||
if(!(opcode & (1 << base)))
|
||||
reg[base].I = temp;
|
||||
|
||||
CPUSwitchMode(reg[17].I & 0x1f, false);
|
||||
|
@ -8103,7 +8103,7 @@ if(cond_res) {
|
|||
LDM_REG(16384, 14);
|
||||
}
|
||||
|
||||
if(!(opcode & (1 << base)))
|
||||
if(!(opcode & (1 << base)))
|
||||
reg[base].I = temp;
|
||||
if (!offset)
|
||||
clockTicks += 1 + dataTicksAccess32(address);
|
||||
|
@ -8114,14 +8114,14 @@ if(cond_res) {
|
|||
clockTicks += 2 + codeTicksAccess32(armNextPC);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
CASE_16(0x910)
|
||||
{
|
||||
// LDMDB Rn, {Rlist}
|
||||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = temp & 0xFFFFFFFC;
|
||||
clockTicks = 0;
|
||||
|
@ -8162,7 +8162,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = temp & 0xFFFFFFFC;
|
||||
clockTicks = 0;
|
||||
|
@ -8205,7 +8205,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = temp & 0xFFFFFFFC;
|
||||
clockTicks = 0;
|
||||
|
@ -8285,7 +8285,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I -
|
||||
u32 temp = reg[base].I -
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = temp & 0xFFFFFFFC;
|
||||
clockTicks = 0;
|
||||
|
@ -8309,7 +8309,7 @@ if(cond_res) {
|
|||
|
||||
reg[15].I = CPUReadMemory(address);
|
||||
|
||||
if(!(opcode & (1 << base)))
|
||||
if(!(opcode & (1 << base)))
|
||||
reg[base].I = temp;
|
||||
|
||||
CPUSwitchMode(reg[17].I & 0x1f, false);
|
||||
|
@ -8354,7 +8354,7 @@ if(cond_res) {
|
|||
LDM_REG(16384, 14);
|
||||
}
|
||||
|
||||
if(!(opcode & (1 << base)))
|
||||
if(!(opcode & (1 << base)))
|
||||
reg[base].I = temp;
|
||||
if (!offset)
|
||||
clockTicks += 1 + dataTicksAccess32(address);
|
||||
|
@ -8365,7 +8365,7 @@ if(cond_res) {
|
|||
clockTicks += 2 + codeTicksAccess32(armNextPC);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
CASE_16(0x990)
|
||||
{
|
||||
// LDMIB Rn, {Rlist}
|
||||
|
@ -8411,7 +8411,7 @@ if(cond_res) {
|
|||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
int base = (opcode & 0x000F0000) >> 16;
|
||||
u32 temp = reg[base].I +
|
||||
u32 temp = reg[base].I +
|
||||
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
|
||||
u32 address = (reg[base].I+4) & 0xFFFFFFFC;
|
||||
clockTicks = 0;
|
||||
|
@ -8452,7 +8452,7 @@ if(cond_res) {
|
|||
if(!(opcode & (1 << base)))
|
||||
reg[base].I = temp;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
CASE_16(0x9d0)
|
||||
{
|
||||
// LDMIB Rn, {Rlist}^
|
||||
|
@ -8561,7 +8561,7 @@ if(cond_res) {
|
|||
|
||||
reg[15].I = CPUReadMemory(address);
|
||||
|
||||
if(!(opcode & (1 << base)))
|
||||
if(!(opcode & (1 << base)))
|
||||
reg[base].I = temp;
|
||||
|
||||
CPUSwitchMode(reg[17].I & 0x1f, false);
|
||||
|
@ -8606,7 +8606,7 @@ if(cond_res) {
|
|||
LDM_REG(16384, 14);
|
||||
}
|
||||
|
||||
if(!(opcode & (1 << base)))
|
||||
if(!(opcode & (1 << base)))
|
||||
reg[base].I = temp;
|
||||
if (!offset)
|
||||
clockTicks += 1 + dataTicksAccess32(address);
|
||||
|
@ -8616,7 +8616,7 @@ if(cond_res) {
|
|||
}
|
||||
clockTicks += 2 + codeTicksAccess32(armNextPC);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
CASE_256(0xa00)
|
||||
{
|
||||
// B <offset>
|
||||
|
@ -8660,7 +8660,7 @@ if(cond_res) {
|
|||
clockTicks += 2 + codeTicksAccess32(armNextPC) +
|
||||
codeTicksAccessSeq32(armNextPC);
|
||||
busPrefetchCount=0;
|
||||
CPUSoftwareInterrupt(opcode & 0x00FFFFFF);
|
||||
CPUSoftwareInterrupt(opcode & 0x00FFFFFF);
|
||||
|
||||
break;
|
||||
#ifdef GP_SUPPORT
|
||||
|
@ -8683,7 +8683,7 @@ if(cond_res) {
|
|||
case 0xe0d:
|
||||
case 0xe0f:
|
||||
// MRC
|
||||
break;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
#ifdef DEV_VERSION
|
||||
|
|
|
@ -135,11 +135,11 @@ const Opcodes thumbOpcodes[] = {
|
|||
// Format 13
|
||||
{0xff00, 0xb000, "add sp, %s"},
|
||||
// Format 14
|
||||
{0xffff, 0xb500, "push {lr}"},
|
||||
{0xffff, 0xb500, "push {lr}"},
|
||||
{0xff00, 0xb400, "push {%l}"},
|
||||
{0xff00, 0xb500, "push {%l,lr}"},
|
||||
{0xffff, 0xbd00, "pop {pc}"},
|
||||
{0xff00, 0xbd00, "pop {%l,pc}"},
|
||||
{0xff00, 0xbd00, "pop {%l,pc}"},
|
||||
{0xff00, 0xbc00, "pop {%l}"},
|
||||
// Format 15
|
||||
{0xf800, 0xc000, "stmia %r8!, {%l}"},
|
||||
|
@ -232,7 +232,7 @@ char* addHex(char *dest, int siz, u32 val){
|
|||
|
||||
int disArm(u32 offset, char *dest, int flags){
|
||||
u32 opcode = debuggerReadMemory(offset);
|
||||
|
||||
|
||||
const Opcodes *sp = armOpcodes;
|
||||
while( sp->cval != (opcode & sp->mask) )
|
||||
sp++;
|
||||
|
@ -431,7 +431,7 @@ int disArm(u32 offset, char *dest, int flags){
|
|||
if(opcode & 0x00100000)
|
||||
dest = addStr(dest, armMultLoadStore[8+((opcode>>23)&3)]);
|
||||
else
|
||||
dest = addStr(dest, armMultLoadStore[4+((opcode>>23)&3)]);
|
||||
dest = addStr(dest, armMultLoadStore[4+((opcode>>23)&3)]);
|
||||
} else
|
||||
dest = addStr(dest, armMultLoadStore[(opcode>>23)&3]);
|
||||
break;
|
||||
|
@ -540,18 +540,18 @@ int disArm(u32 offset, char *dest, int flags){
|
|||
}
|
||||
}
|
||||
*dest++ = 0;
|
||||
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
int disThumb(u32 offset, char *dest, int flags){
|
||||
u32 opcode = debuggerReadHalfWord(offset);
|
||||
|
||||
|
||||
const Opcodes *sp = thumbOpcodes;
|
||||
int ret = 2;
|
||||
while( sp->cval != (opcode & sp->mask) )
|
||||
sp++;
|
||||
|
||||
|
||||
if (flags&DIS_VIEW_ADDRESS){
|
||||
dest = addHex(dest, 32, offset);
|
||||
*dest++ = ' ';
|
||||
|
@ -560,7 +560,7 @@ int disThumb(u32 offset, char *dest, int flags){
|
|||
dest = addHex(dest, 16, opcode);
|
||||
*dest++ = ' ';
|
||||
}
|
||||
|
||||
|
||||
const char *src = sp->mnemonic;
|
||||
while (*src){
|
||||
if (*src!='%')
|
||||
|
@ -636,7 +636,7 @@ int disThumb(u32 offset, char *dest, int flags){
|
|||
if(*s) {
|
||||
*dest++ = ' ';
|
||||
dest = addStr(dest, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
|
|
|
@ -93,13 +93,13 @@ void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
for(int y = 0; y < height; y++) {
|
||||
u16 *from_orig = from;
|
||||
u16 *to_orig = to;
|
||||
|
||||
|
||||
if (y+1 < height)
|
||||
fill_rgb_row_16(from+width+2, from_width, rgb_row_next,
|
||||
fill_rgb_row_16(from+width+2, from_width, rgb_row_next,
|
||||
width+1);
|
||||
else
|
||||
fill_rgb_row_16(from, from_width, rgb_row_next, width+1);
|
||||
|
||||
|
||||
// every pixel in the src region, is extended to 4 pixels in the
|
||||
// destination, arranged in a square 'quad'; if the current src
|
||||
// pixel is 'a', then in what follows 'b' is the src pixel to the
|
||||
|
@ -123,18 +123,18 @@ void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
|
||||
// upper left pixel in quad: just copy it in
|
||||
*to++ = RGB(*ar, *ag, *ab);
|
||||
|
||||
|
||||
// upper right
|
||||
*to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1);
|
||||
|
||||
|
||||
// lower left
|
||||
*to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1);
|
||||
|
||||
|
||||
// lower right
|
||||
*to_odd++ = RGB((*ar+*br+*cr+*dr)>>2,
|
||||
(*ag+*bg+*cg+*dg)>>2,
|
||||
(*ab+*bb+*cb+*db)>>2);
|
||||
|
||||
|
||||
// 'b' becomes 'a', 'd' becomes 'c'
|
||||
ar = br;
|
||||
ag = bg;
|
||||
|
@ -143,14 +143,14 @@ void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
cg = dg;
|
||||
cb = db;
|
||||
}
|
||||
|
||||
|
||||
// the "next" rgb row becomes the current; the old current rgb row is
|
||||
// recycled and serves as the new "next" row
|
||||
u8 *temp;
|
||||
temp = rgb_row_cur;
|
||||
rgb_row_cur = rgb_row_next;
|
||||
rgb_row_next = temp;
|
||||
|
||||
|
||||
// update the pointers for start of next pair of lines
|
||||
from = (u16 *)((u8 *)from_orig + srcPitch);
|
||||
to = (u16 *)((u8 *)to_orig + (dstPitch << 1));
|
||||
|
@ -171,13 +171,13 @@ void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
for(int y = 0; y < height; y++) {
|
||||
u16 *from_orig = from;
|
||||
u16 *to_orig = to;
|
||||
|
||||
|
||||
if (y+1 < height)
|
||||
fill_rgb_row_16(from+width+2, from_width, rgb_row_next,
|
||||
fill_rgb_row_16(from+width+2, from_width, rgb_row_next,
|
||||
width+1);
|
||||
else
|
||||
fill_rgb_row_16(from, from_width, rgb_row_next, width+1);
|
||||
|
||||
|
||||
// every pixel in the src region, is extended to 4 pixels in the
|
||||
// destination, arranged in a square 'quad'; if the current src
|
||||
// pixel is 'a', then in what follows 'b' is the src pixel to the
|
||||
|
@ -198,7 +198,7 @@ void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
u8 *dr = next_row++;
|
||||
u8 *dg = next_row++;
|
||||
u8 *db = next_row++;
|
||||
|
||||
|
||||
// upper left pixel in quad: just copy it in
|
||||
//*to++ = manip.rgb(*ar, *ag, *ab);
|
||||
#ifdef USE_ORIGINAL_BILINEAR_PLUS
|
||||
|
@ -212,18 +212,18 @@ void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
(((*ag)<<3) +((*ag)<<1) + (*cg+*bg+*bg+*cg) )>> 4,
|
||||
(((*ab)<<3) +((*ab)<<1) + (*cb+*bb+*bb+*cb) )>> 4);
|
||||
#endif
|
||||
|
||||
|
||||
// upper right
|
||||
*to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1);
|
||||
|
||||
|
||||
// lower left
|
||||
*to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1);
|
||||
|
||||
|
||||
// lower right
|
||||
*to_odd++ = RGB((*ar+*br+*cr+*dr)>>2,
|
||||
(*ag+*bg+*cg+*dg)>>2,
|
||||
(*ab+*bb+*cb+*db)>>2);
|
||||
|
||||
|
||||
// 'b' becomes 'a', 'd' becomes 'c'
|
||||
ar = br;
|
||||
ag = bg;
|
||||
|
@ -232,14 +232,14 @@ void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
cg = dg;
|
||||
cb = db;
|
||||
}
|
||||
|
||||
|
||||
// the "next" rgb row becomes the current; the old current rgb row is
|
||||
// recycled and serves as the new "next" row
|
||||
u8 *temp;
|
||||
temp = rgb_row_cur;
|
||||
rgb_row_cur = rgb_row_next;
|
||||
rgb_row_next = temp;
|
||||
|
||||
|
||||
// update the pointers for start of next pair of lines
|
||||
from = (u16 *)((u8 *)from_orig + srcPitch);
|
||||
to = (u16 *)((u8 *)to_orig + (dstPitch << 1));
|
||||
|
@ -262,13 +262,13 @@ void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
for(int y = 0; y < height; y++) {
|
||||
u32 *from_orig = from;
|
||||
u32 *to_orig = to;
|
||||
|
||||
|
||||
if (y+1 < height)
|
||||
fill_rgb_row_32(from+width+1, from_width, rgb_row_next,
|
||||
fill_rgb_row_32(from+width+1, from_width, rgb_row_next,
|
||||
width+1);
|
||||
else
|
||||
fill_rgb_row_32(from, from_width, rgb_row_next, width+1);
|
||||
|
||||
|
||||
// every pixel in the src region, is extended to 4 pixels in the
|
||||
// destination, arranged in a square 'quad'; if the current src
|
||||
// pixel is 'a', then in what follows 'b' is the src pixel to the
|
||||
|
@ -292,18 +292,18 @@ void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
|
||||
// upper left pixel in quad: just copy it in
|
||||
*to++ = RGB(*ar, *ag, *ab);
|
||||
|
||||
|
||||
// upper right
|
||||
*to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1);
|
||||
|
||||
|
||||
// lower left
|
||||
*to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1);
|
||||
|
||||
|
||||
// lower right
|
||||
*to_odd++ = RGB((*ar+*br+*cr+*dr)>>2,
|
||||
(*ag+*bg+*cg+*dg)>>2,
|
||||
(*ab+*bb+*cb+*db)>>2);
|
||||
|
||||
|
||||
// 'b' becomes 'a', 'd' becomes 'c'
|
||||
ar = br;
|
||||
ag = bg;
|
||||
|
@ -312,14 +312,14 @@ void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
cg = dg;
|
||||
cb = db;
|
||||
}
|
||||
|
||||
|
||||
// the "next" rgb row becomes the current; the old current rgb row is
|
||||
// recycled and serves as the new "next" row
|
||||
u8 *temp;
|
||||
temp = rgb_row_cur;
|
||||
rgb_row_cur = rgb_row_next;
|
||||
rgb_row_next = temp;
|
||||
|
||||
|
||||
// update the pointers for start of next pair of lines
|
||||
from = (u32 *)((u8 *)from_orig + srcPitch);
|
||||
to = (u32 *)((u8 *)to_orig + (dstPitch << 1));
|
||||
|
@ -342,13 +342,13 @@ void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
for(int y = 0; y < height; y++) {
|
||||
u32 *from_orig = from;
|
||||
u32 *to_orig = to;
|
||||
|
||||
|
||||
if (y+1 < height)
|
||||
fill_rgb_row_32(from+width+1, from_width, rgb_row_next,
|
||||
fill_rgb_row_32(from+width+1, from_width, rgb_row_next,
|
||||
width+1);
|
||||
else
|
||||
fill_rgb_row_32(from, from_width, rgb_row_next, width+1);
|
||||
|
||||
|
||||
// every pixel in the src region, is extended to 4 pixels in the
|
||||
// destination, arranged in a square 'quad'; if the current src
|
||||
// pixel is 'a', then in what follows 'b' is the src pixel to the
|
||||
|
@ -369,7 +369,7 @@ void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
u8 *dr = next_row++;
|
||||
u8 *dg = next_row++;
|
||||
u8 *db = next_row++;
|
||||
|
||||
|
||||
// upper left pixel in quad: just copy it in
|
||||
//*to++ = manip.rgb(*ar, *ag, *ab);
|
||||
#ifdef USE_ORIGINAL_BILINEAR_PLUS
|
||||
|
@ -383,18 +383,18 @@ void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
(((*ag)<<3) +((*ag)<<1) + (*cg+*bg+*bg+*cg) )>> 4,
|
||||
(((*ab)<<3) +((*ab)<<1) + (*cb+*bb+*bb+*cb) )>> 4);
|
||||
#endif
|
||||
|
||||
|
||||
// upper right
|
||||
*to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1);
|
||||
|
||||
|
||||
// lower left
|
||||
*to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1);
|
||||
|
||||
|
||||
// lower right
|
||||
*to_odd++ = RGB((*ar+*br+*cr+*dr)>>2,
|
||||
(*ag+*bg+*cg+*dg)>>2,
|
||||
(*ab+*bb+*cb+*db)>>2);
|
||||
|
||||
|
||||
// 'b' becomes 'a', 'd' becomes 'c'
|
||||
ar = br;
|
||||
ag = bg;
|
||||
|
@ -403,14 +403,14 @@ void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
cg = dg;
|
||||
cb = db;
|
||||
}
|
||||
|
||||
|
||||
// the "next" rgb row becomes the current; the old current rgb row is
|
||||
// recycled and serves as the new "next" row
|
||||
u8 *temp;
|
||||
temp = rgb_row_cur;
|
||||
rgb_row_cur = rgb_row_next;
|
||||
rgb_row_next = temp;
|
||||
|
||||
|
||||
// update the pointers for start of next pair of lines
|
||||
from = (u32 *)((u8 *)from_orig + srcPitch);
|
||||
to = (u32 *)((u8 *)to_orig + (dstPitch << 1));
|
||||
|
|
124
src/bios.cpp
124
src/bios.cpp
|
@ -99,7 +99,7 @@ void BIOS_ArcTan2()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
s32 x = reg[0].I;
|
||||
s32 y = reg[1].I;
|
||||
u32 res = 0;
|
||||
|
@ -127,18 +127,18 @@ void BIOS_ArcTan2()
|
|||
}
|
||||
}
|
||||
reg[0].I = res;
|
||||
|
||||
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_SWI) {
|
||||
log("ArcTan2: return=%08x\n",
|
||||
reg[0].I);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void BIOS_BitUnPack()
|
||||
{
|
||||
#ifdef DEV_VERSION
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_SWI) {
|
||||
log("BitUnPack: %08x,%08x,%08x (VCOUNT=%2d)\n",
|
||||
reg[0].I,
|
||||
|
@ -151,7 +151,7 @@ void BIOS_BitUnPack()
|
|||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
u32 header = reg[2].I;
|
||||
|
||||
|
||||
int len = CPUReadHalfWord(header);
|
||||
// check address
|
||||
if(((source & 0xe000000) == 0) ||
|
||||
|
@ -159,21 +159,21 @@ void BIOS_BitUnPack()
|
|||
return;
|
||||
|
||||
int bits = CPUReadByte(header+2);
|
||||
int revbits = 8 - bits;
|
||||
int revbits = 8 - bits;
|
||||
// u32 value = 0;
|
||||
u32 base = CPUReadMemory(header+4);
|
||||
bool addBase = (base & 0x80000000) ? true : false;
|
||||
base &= 0x7fffffff;
|
||||
int dataSize = CPUReadByte(header+3);
|
||||
|
||||
int data = 0;
|
||||
int bitwritecount = 0;
|
||||
int data = 0;
|
||||
int bitwritecount = 0;
|
||||
while(1) {
|
||||
len -= 1;
|
||||
if(len < 0)
|
||||
break;
|
||||
int mask = 0xff >> revbits;
|
||||
u8 b = CPUReadByte(source);
|
||||
int mask = 0xff >> revbits;
|
||||
u8 b = CPUReadByte(source);
|
||||
source++;
|
||||
int bitcount = 0;
|
||||
while(1) {
|
||||
|
@ -205,7 +205,7 @@ void BIOS_GetBiosChecksum()
|
|||
|
||||
void BIOS_BgAffineSet()
|
||||
{
|
||||
#ifdef DEV_VERSION
|
||||
#ifdef DEV_VERSION
|
||||
if(systemVerbose & VERBOSE_SWI) {
|
||||
log("BgAffineSet: %08x,%08x,%08x (VCOUNT=%2d)\n",
|
||||
reg[0].I,
|
||||
|
@ -214,7 +214,7 @@ void BIOS_BgAffineSet()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 src = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
int num = reg[2].I;
|
||||
|
@ -241,7 +241,7 @@ void BIOS_BgAffineSet()
|
|||
s16 dmx = (rx * b)>>14;
|
||||
s16 dy = (ry * b)>>14;
|
||||
s16 dmy = (ry * a)>>14;
|
||||
|
||||
|
||||
CPUWriteHalfWord(dest, dx);
|
||||
dest += 2;
|
||||
CPUWriteHalfWord(dest, -dmx);
|
||||
|
@ -253,13 +253,13 @@ void BIOS_BgAffineSet()
|
|||
|
||||
s32 startx = cx - dx * dispx + dmx * dispy;
|
||||
s32 starty = cy - dy * dispx - dmy * dispy;
|
||||
|
||||
|
||||
CPUWriteMemory(dest, startx);
|
||||
dest += 4;
|
||||
CPUWriteMemory(dest, starty);
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BIOS_CpuSet()
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ void BIOS_CpuSet()
|
|||
reg[2].I, VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
u32 cnt = reg[2].I;
|
||||
|
@ -331,7 +331,7 @@ void BIOS_CpuFastSet()
|
|||
reg[2].I, VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
u32 cnt = reg[2].I;
|
||||
|
@ -343,9 +343,9 @@ void BIOS_CpuFastSet()
|
|||
// needed for 32-bit mode!
|
||||
source &= 0xFFFFFFFC;
|
||||
dest &= 0xFFFFFFFC;
|
||||
|
||||
|
||||
int count = cnt & 0x1FFFFF;
|
||||
|
||||
|
||||
// fill?
|
||||
if((cnt >> 24) & 1) {
|
||||
while(count > 0) {
|
||||
|
@ -379,7 +379,7 @@ void BIOS_Diff8bitUnFilterWram()
|
|||
reg[1].I, VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
|
||||
|
@ -388,20 +388,20 @@ void BIOS_Diff8bitUnFilterWram()
|
|||
|
||||
if(((source & 0xe000000) == 0) ||
|
||||
((source + ((header >> 8) & 0x1fffff) & 0xe000000) == 0))
|
||||
return;
|
||||
return;
|
||||
|
||||
int len = header >> 8;
|
||||
|
||||
u8 data = CPUReadByte(source++);
|
||||
CPUWriteByte(dest++, data);
|
||||
len--;
|
||||
|
||||
|
||||
while(len > 0) {
|
||||
u8 diff = CPUReadByte(source++);
|
||||
data += diff;
|
||||
CPUWriteByte(dest++, data);
|
||||
len--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BIOS_Diff8bitUnFilterVram()
|
||||
|
@ -412,7 +412,7 @@ void BIOS_Diff8bitUnFilterVram()
|
|||
reg[1].I, VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
|
||||
|
@ -421,15 +421,15 @@ void BIOS_Diff8bitUnFilterVram()
|
|||
|
||||
if(((source & 0xe000000) == 0) ||
|
||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
int len = header >> 8;
|
||||
|
||||
u8 data = CPUReadByte(source++);
|
||||
u16 writeData = data;
|
||||
int shift = 8;
|
||||
int bytes = 1;
|
||||
|
||||
|
||||
while(len >= 2) {
|
||||
u8 diff = CPUReadByte(source++);
|
||||
data += diff;
|
||||
|
@ -444,7 +444,7 @@ void BIOS_Diff8bitUnFilterVram()
|
|||
writeData = 0;
|
||||
shift = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BIOS_Diff16bitUnFilter()
|
||||
|
@ -455,7 +455,7 @@ void BIOS_Diff16bitUnFilter()
|
|||
reg[1].I, VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
|
||||
|
@ -464,8 +464,8 @@ void BIOS_Diff16bitUnFilter()
|
|||
|
||||
if(((source & 0xe000000) == 0) ||
|
||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
int len = header >> 8;
|
||||
|
||||
u16 data = CPUReadHalfWord(source);
|
||||
|
@ -473,7 +473,7 @@ void BIOS_Diff16bitUnFilter()
|
|||
CPUWriteHalfWord(dest, data);
|
||||
dest += 2;
|
||||
len -= 2;
|
||||
|
||||
|
||||
while(len >= 2) {
|
||||
u16 diff = CPUReadHalfWord(source);
|
||||
source += 2;
|
||||
|
@ -494,7 +494,7 @@ void BIOS_Div()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int number = reg[0].I;
|
||||
int denom = reg[1].I;
|
||||
|
||||
|
@ -523,7 +523,7 @@ void BIOS_DivARM()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 temp = reg[0].I;
|
||||
reg[0].I = reg[1].I;
|
||||
reg[1].I = temp;
|
||||
|
@ -540,7 +540,7 @@ void BIOS_HuffUnComp()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
|
||||
|
@ -549,14 +549,14 @@ void BIOS_HuffUnComp()
|
|||
|
||||
if(((source & 0xe000000) == 0) ||
|
||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
u8 treeSize = CPUReadByte(source++);
|
||||
|
||||
u32 treeStart = source;
|
||||
|
||||
source += ((treeSize+1)<<1)-1; // minus because we already skipped one byte
|
||||
|
||||
|
||||
int len = header >> 8;
|
||||
|
||||
u32 mask = 0x80000000;
|
||||
|
@ -578,7 +578,7 @@ void BIOS_HuffUnComp()
|
|||
pos++;
|
||||
else
|
||||
pos += (((currentNode & 0x3F)+1)<<1);
|
||||
|
||||
|
||||
if(data & mask) {
|
||||
// right
|
||||
if(currentNode & 0x40)
|
||||
|
@ -590,7 +590,7 @@ void BIOS_HuffUnComp()
|
|||
writeData = true;
|
||||
currentNode = CPUReadByte(treeStart+pos);
|
||||
}
|
||||
|
||||
|
||||
if(writeData) {
|
||||
writeValue |= (currentNode << byteShift);
|
||||
byteCount++;
|
||||
|
@ -637,7 +637,7 @@ void BIOS_HuffUnComp()
|
|||
writeData = true;
|
||||
currentNode = CPUReadByte(treeStart+pos);
|
||||
}
|
||||
|
||||
|
||||
if(writeData) {
|
||||
if(halfLen == 0)
|
||||
value |= currentNode;
|
||||
|
@ -649,7 +649,7 @@ void BIOS_HuffUnComp()
|
|||
writeValue |= (value << byteShift);
|
||||
byteCount++;
|
||||
byteShift += 8;
|
||||
|
||||
|
||||
halfLen = 0;
|
||||
value = 0;
|
||||
|
||||
|
@ -672,7 +672,7 @@ void BIOS_HuffUnComp()
|
|||
data = CPUReadMemory(source);
|
||||
source += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -686,7 +686,7 @@ void BIOS_LZ77UnCompVram()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
|
||||
|
@ -695,12 +695,12 @@ void BIOS_LZ77UnCompVram()
|
|||
|
||||
if(((source & 0xe000000) == 0) ||
|
||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
int byteCount = 0;
|
||||
int byteShift = 0;
|
||||
u32 writeValue = 0;
|
||||
|
||||
|
||||
int len = header >> 8;
|
||||
|
||||
while(len > 0) {
|
||||
|
@ -754,7 +754,7 @@ void BIOS_LZ77UnCompVram()
|
|||
byteCount++;
|
||||
if(byteCount == 2) {
|
||||
CPUWriteHalfWord(dest, writeValue);
|
||||
dest += 2;
|
||||
dest += 2;
|
||||
byteShift = 0;
|
||||
byteCount = 0;
|
||||
writeValue = 0;
|
||||
|
@ -775,7 +775,7 @@ void BIOS_LZ77UnCompWram()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
|
||||
|
@ -784,8 +784,8 @@ void BIOS_LZ77UnCompWram()
|
|||
|
||||
if(((source & 0xe000000) == 0) ||
|
||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
int len = header >> 8;
|
||||
|
||||
while(len > 0) {
|
||||
|
@ -836,7 +836,7 @@ void BIOS_ObjAffineSet()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 src = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
int num = reg[2].I;
|
||||
|
@ -857,7 +857,7 @@ void BIOS_ObjAffineSet()
|
|||
s16 dmx = ((s32)rx * b)>>14;
|
||||
s16 dy = ((s32)ry * b)>>14;
|
||||
s16 dmy = ((s32)ry * a)>>14;
|
||||
|
||||
|
||||
CPUWriteHalfWord(dest, dx);
|
||||
dest += offset;
|
||||
CPUWriteHalfWord(dest, -dmx);
|
||||
|
@ -875,7 +875,7 @@ void BIOS_RegisterRamReset(u32 flags)
|
|||
// to emulate bios initialization
|
||||
|
||||
CPUUpdateRegister(0x0, 0x80);
|
||||
|
||||
|
||||
if(flags) {
|
||||
if(flags & 0x01) {
|
||||
// clear work RAM
|
||||
|
@ -918,7 +918,7 @@ void BIOS_RegisterRamReset(u32 flags)
|
|||
CPUUpdateRegister(0x26, 0x100);
|
||||
CPUUpdateRegister(0x36, 0x100);
|
||||
}
|
||||
|
||||
|
||||
if(flags & 0x20) {
|
||||
int i;
|
||||
for(i = 0; i < 8; i++)
|
||||
|
@ -968,7 +968,7 @@ void BIOS_RLUnCompVram()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
|
||||
|
@ -977,8 +977,8 @@ void BIOS_RLUnCompVram()
|
|||
|
||||
if(((source & 0xe000000) == 0) ||
|
||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
int len = header >> 8;
|
||||
int byteCount = 0;
|
||||
int byteShift = 0;
|
||||
|
@ -1037,7 +1037,7 @@ void BIOS_RLUnCompWram()
|
|||
VCOUNT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 source = reg[0].I;
|
||||
u32 dest = reg[1].I;
|
||||
|
||||
|
@ -1046,8 +1046,8 @@ void BIOS_RLUnCompWram()
|
|||
|
||||
if(((source & 0xe000000) == 0) ||
|
||||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
int len = header >> 8;
|
||||
|
||||
while(len > 0) {
|
||||
|
@ -1092,7 +1092,7 @@ void BIOS_SoftReset()
|
|||
reg[R13_IRQ].I = 0x03007FA0;
|
||||
reg[R14_IRQ].I = 0x00000000;
|
||||
reg[SPSR_IRQ].I = 0x00000000;
|
||||
reg[R13_SVC].I = 0x03007FE0;
|
||||
reg[R13_SVC].I = 0x03007FE0;
|
||||
reg[R14_SVC].I = 0x00000000;
|
||||
reg[SPSR_SVC].I = 0x00000000;
|
||||
u8 b = internalRAM[0x7ffa];
|
||||
|
|
248
src/elf.cpp
248
src/elf.cpp
|
@ -54,7 +54,7 @@
|
|||
|
||||
#define DW_AT_sibling 0x01
|
||||
#define DW_AT_location 0x02
|
||||
#define DW_AT_name 0x03
|
||||
#define DW_AT_name 0x03
|
||||
#define DW_AT_byte_size 0x0b
|
||||
#define DW_AT_bit_offset 0x0c
|
||||
#define DW_AT_bit_size 0x0d
|
||||
|
@ -328,7 +328,7 @@ const char *elfGetAddressSymbol(u32 addr)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -448,9 +448,9 @@ bool elfGetObject(const char *name, Function *f, CompileUnit *u, Object **o)
|
|||
v = v->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CompileUnit *c = elfCompileUnits;
|
||||
|
||||
|
||||
while(c) {
|
||||
if(c != u) {
|
||||
Object *v = c->variables;
|
||||
|
@ -464,7 +464,7 @@ bool elfGetObject(const char *name, Function *f, CompileUnit *u, Object **o)
|
|||
}
|
||||
c = c->next;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -626,7 +626,7 @@ ELFFrameState *elfGetFrameState(ELFfde *fde, u32 address)
|
|||
state->dataAlign = fde->cie->dataAlign;
|
||||
state->codeAlign = fde->cie->codeAlign;
|
||||
state->returnAddress = fde->cie->returnAddress;
|
||||
|
||||
|
||||
elfExecuteCFAInstructions(state,
|
||||
fde->cie->data,
|
||||
fde->cie->dataLen,
|
||||
|
@ -647,33 +647,33 @@ void elfPrintCallChain(u32 address)
|
|||
reg_pair newRegs[15];
|
||||
|
||||
memcpy(®s[0], ®[0], sizeof(reg_pair) * 15);
|
||||
|
||||
|
||||
while(count < 20) {
|
||||
const char *addr = elfGetAddressSymbol(address);
|
||||
if(*addr == 0)
|
||||
addr = "???";
|
||||
|
||||
|
||||
printf("%08x %s\n", address, addr);
|
||||
|
||||
|
||||
ELFfde *fde = elfGetFde(address);
|
||||
|
||||
|
||||
if(fde == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
ELFFrameState *state = elfGetFrameState(fde, address);
|
||||
|
||||
|
||||
if(!state) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(state->cfaMode == CFA_REG_OFFSET) {
|
||||
memcpy(&newRegs[0], ®s[0], sizeof(reg_pair) * 15);
|
||||
memcpy(&newRegs[0], ®s[0], sizeof(reg_pair) * 15);
|
||||
u32 addr = 0;
|
||||
for(int i = 0; i < 15; i++) {
|
||||
ELFFrameStateRegister *r = &state->registers.
|
||||
regs[i];
|
||||
|
||||
|
||||
switch(r->mode) {
|
||||
case REG_NOT_SET:
|
||||
newRegs[i].I = regs[i].I;
|
||||
|
@ -742,7 +742,7 @@ u32 elfDecodeLocation(Function *f, ELFBlock *o, LocationType *type, u32 base)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ELFBlock *loc = o;
|
||||
u32 location = 0;
|
||||
int bytes = 0;
|
||||
|
@ -771,7 +771,7 @@ u32 elfDecodeLocation(Function *f, ELFBlock *o, LocationType *type, u32 base)
|
|||
case DW_OP_reg12:
|
||||
case DW_OP_reg13:
|
||||
case DW_OP_reg14:
|
||||
case DW_OP_reg15:
|
||||
case DW_OP_reg15:
|
||||
location = *loc->data - 0x50;
|
||||
*type = LOCATION_register;
|
||||
break;
|
||||
|
@ -829,7 +829,7 @@ s32 elfReadSignedLEB128(u8 *data, int *bytesRead)
|
|||
s32 result = 0;
|
||||
int shift = 0;
|
||||
int count = 0;
|
||||
|
||||
|
||||
u8 byte;
|
||||
do {
|
||||
byte = *data++;
|
||||
|
@ -971,7 +971,7 @@ u8 *elfReadAttribute(u8 *data, ELFAttr *attr)
|
|||
case DW_FORM_ref_udata:
|
||||
attr->value = (u32)((elfDebugInfo->infodata + (elfGetCompileUnitForData(data)->top - elfDebugInfo->infodata) + elfReadLEB128(data, &bytes)) - elfCurrentUnit->top);
|
||||
data += bytes;
|
||||
break;
|
||||
break;
|
||||
case DW_FORM_indirect:
|
||||
form = elfReadLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
|
@ -1063,17 +1063,17 @@ void elfParseCFA(u8 *top)
|
|||
u8 *end = data + READ32LE(&h->size);
|
||||
|
||||
ELFcie *cies = NULL;
|
||||
|
||||
|
||||
while(data < end) {
|
||||
u32 offset = (u32)(data - topOffset);
|
||||
u32 len = elfRead4Bytes(data);
|
||||
data += 4;
|
||||
|
||||
u8 *dataEnd = data + len;
|
||||
|
||||
|
||||
u32 id = elfRead4Bytes(data);
|
||||
data += 4;
|
||||
|
||||
|
||||
if(id == 0xffffffff) {
|
||||
// skip version
|
||||
*data++;
|
||||
|
@ -1084,24 +1084,24 @@ void elfParseCFA(u8 *top)
|
|||
cies = cie;
|
||||
|
||||
cie->offset = offset;
|
||||
|
||||
|
||||
cie->augmentation = data;
|
||||
while(*data)
|
||||
data++;
|
||||
data++;
|
||||
|
||||
|
||||
if(*cie->augmentation) {
|
||||
fprintf(stderr, "Error: augmentation not supported\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
int bytes;
|
||||
cie->codeAlign = elfReadLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
|
||||
|
||||
cie->dataAlign = elfReadSignedLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
|
||||
|
||||
cie->returnAddress = *data++;
|
||||
|
||||
cie->data = data;
|
||||
|
@ -1123,10 +1123,10 @@ void elfParseCFA(u8 *top)
|
|||
}
|
||||
|
||||
fde->cie = cie;
|
||||
|
||||
|
||||
fde->address = elfRead4Bytes(data);
|
||||
data += 4;
|
||||
|
||||
|
||||
fde->end = fde->address + elfRead4Bytes(data);
|
||||
data += 4;
|
||||
|
||||
|
@ -1169,7 +1169,7 @@ void elfParseLineInfo(CompileUnit *unit, u8 *top)
|
|||
l->number = 0;
|
||||
int max = 1000;
|
||||
l->lines = (LineInfoItem *)malloc(1000*sizeof(LineInfoItem));
|
||||
|
||||
|
||||
u8 *data = elfReadSection(top, h);
|
||||
data += unit->lineInfo;
|
||||
u32 totalLen = elfRead4Bytes(data);
|
||||
|
@ -1202,10 +1202,10 @@ void elfParseLineInfo(CompileUnit *unit, u8 *top)
|
|||
int count = 4;
|
||||
int index = 0;
|
||||
l->files = (char **)malloc(sizeof(char *)*count);
|
||||
|
||||
|
||||
while((s = elfReadString(data, &bytes)) != NULL) {
|
||||
l->files[index++] = s;
|
||||
|
||||
|
||||
data += bytes;
|
||||
// directory
|
||||
elfReadLEB128(data, &bytes);
|
||||
|
@ -1293,7 +1293,7 @@ void elfParseLineInfo(CompileUnit *unit, u8 *top)
|
|||
op = op - opcodeBase;
|
||||
address += (op / lineRange) * minInstrSize;
|
||||
line += lineBase + (op % lineRange);
|
||||
elfAddLine(l, address, file, line, &max);
|
||||
elfAddLine(l, address, file, line, &max);
|
||||
// fprintf(stderr, "Address %08x line %d (%d)\n", address, line,file);
|
||||
basicBlock = 1;
|
||||
break;
|
||||
|
@ -1307,32 +1307,32 @@ u8 *elfSkipData(u8 *data, ELFAbbrev *abbrev, ELFAbbrev **abbrevs)
|
|||
{
|
||||
int i;
|
||||
int bytes;
|
||||
|
||||
|
||||
for(i = 0; i < abbrev->numAttrs; i++) {
|
||||
data = elfReadAttribute(data, &abbrev->attrs[i]);
|
||||
if(abbrev->attrs[i].form == DW_FORM_block1)
|
||||
free(abbrev->attrs[i].block);
|
||||
}
|
||||
|
||||
|
||||
if(abbrev->hasChildren) {
|
||||
int nesting = 1;
|
||||
while(nesting) {
|
||||
u32 abbrevNum = elfReadLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
|
||||
|
||||
if(!abbrevNum) {
|
||||
nesting--;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
abbrev = elfGetAbbrev(abbrevs, abbrevNum);
|
||||
|
||||
|
||||
for(i = 0; i < abbrev->numAttrs; i++) {
|
||||
data = elfReadAttribute(data, &abbrev->attrs[i]);
|
||||
if(abbrev->attrs[i].form == DW_FORM_block1)
|
||||
free(abbrev->attrs[i].block);
|
||||
}
|
||||
|
||||
|
||||
if(abbrev->hasChildren) {
|
||||
nesting++;
|
||||
}
|
||||
|
@ -1356,7 +1356,7 @@ void elfAddType(Type *type, CompileUnit *unit, u32 offset)
|
|||
type->next = unit->types;
|
||||
unit->types = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||
|
@ -1366,7 +1366,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
case DW_TAG_typedef:
|
||||
{
|
||||
u32 typeref = 0;
|
||||
char *name = NULL;
|
||||
char *name = NULL;
|
||||
for(int i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data = elfReadAttribute(data, attr);
|
||||
|
@ -1379,7 +1379,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
break;
|
||||
case DW_AT_decl_file:
|
||||
case DW_AT_decl_line:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown attribute for typedef %02x\n", attr->name);
|
||||
break;
|
||||
|
@ -1401,11 +1401,11 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
t->type = TYPE_struct;
|
||||
else
|
||||
t->type = TYPE_union;
|
||||
|
||||
|
||||
Struct *s = (Struct *)calloc(sizeof(Struct), 1);
|
||||
t->structure = s;
|
||||
elfAddType(t, unit, offset);
|
||||
|
||||
|
||||
for(int i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data = elfReadAttribute(data, attr);
|
||||
|
@ -1435,7 +1435,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
int index = 0;
|
||||
while(num) {
|
||||
ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
|
||||
|
||||
|
||||
switch(abbr->tag) {
|
||||
case DW_TAG_member:
|
||||
{
|
||||
|
@ -1561,7 +1561,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
t->type = TYPE_pointer;
|
||||
|
||||
elfAddType(t, unit, offset);
|
||||
|
||||
|
||||
for(int i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data =elfReadAttribute(data, attr);
|
||||
|
@ -1590,7 +1590,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
t->type = TYPE_reference;
|
||||
|
||||
elfAddType(t, unit, offset);
|
||||
|
||||
|
||||
for(int i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data =elfReadAttribute(data, attr);
|
||||
|
@ -1615,7 +1615,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
case DW_TAG_volatile_type:
|
||||
{
|
||||
u32 typeref = 0;
|
||||
|
||||
|
||||
for(int i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data = elfReadAttribute(data, attr);
|
||||
|
@ -1638,7 +1638,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
case DW_TAG_const_type:
|
||||
{
|
||||
u32 typeref = 0;
|
||||
|
||||
|
||||
for(int i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data = elfReadAttribute(data, attr);
|
||||
|
@ -1690,7 +1690,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
data += bytes;
|
||||
while(num) {
|
||||
ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
|
||||
|
||||
|
||||
switch(abbr->tag) {
|
||||
case DW_TAG_enumerator:
|
||||
{
|
||||
|
@ -1717,7 +1717,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown enum tag %02x\n", abbr->tag);
|
||||
data = elfSkipData(data, abbr, unit->abbrevs);
|
||||
data = elfSkipData(data, abbr, unit->abbrevs);
|
||||
break;
|
||||
}
|
||||
num = elfReadLEB128(data, &bytes);
|
||||
|
@ -1734,14 +1734,14 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
Type *t = (Type *)calloc(sizeof(Type), 1);
|
||||
t->type = TYPE_function;
|
||||
FunctionType *f = (FunctionType *)calloc(sizeof(FunctionType), 1);
|
||||
t->function = f;
|
||||
t->function = f;
|
||||
elfAddType(t, unit, offset);
|
||||
for(int i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data = elfReadAttribute(data, attr);
|
||||
switch(attr->name) {
|
||||
case DW_AT_prototyped:
|
||||
case DW_AT_sibling:
|
||||
case DW_AT_sibling:
|
||||
break;
|
||||
case DW_AT_type:
|
||||
f->returnType = elfParseType(unit, attr->value);
|
||||
|
@ -1754,10 +1754,10 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
int bytes;
|
||||
u32 num = elfReadLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
Object *lastVar = NULL;
|
||||
Object *lastVar = NULL;
|
||||
while(num) {
|
||||
ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
|
||||
|
||||
|
||||
switch(abbr->tag) {
|
||||
case DW_TAG_formal_parameter:
|
||||
{
|
||||
|
@ -1780,7 +1780,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown subroutine tag %02x\n", abbr->tag);
|
||||
data = elfSkipData(data, abbr, unit->abbrevs);
|
||||
data = elfSkipData(data, abbr, unit->abbrevs);
|
||||
break;
|
||||
}
|
||||
num = elfReadLEB128(data, &bytes);
|
||||
|
@ -1799,7 +1799,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
Type *t = (Type *)calloc(sizeof(Type), 1);
|
||||
t->type = TYPE_array;
|
||||
elfAddType(t, unit, offset);
|
||||
|
||||
|
||||
for(i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data = elfReadAttribute(data, attr);
|
||||
|
@ -1822,7 +1822,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
int maxBounds = 0;
|
||||
while(num) {
|
||||
ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
|
||||
|
||||
|
||||
switch(abbr->tag) {
|
||||
case DW_TAG_subrange_type:
|
||||
{
|
||||
|
@ -1850,7 +1850,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown array tag %02x\n", abbr->tag);
|
||||
data = elfSkipData(data, abbr, unit->abbrevs);
|
||||
data = elfSkipData(data, abbr, unit->abbrevs);
|
||||
break;
|
||||
}
|
||||
num = elfReadLEB128(data, &bytes);
|
||||
|
@ -1895,7 +1895,7 @@ Type *elfParseType(CompileUnit *unit, u32 offset)
|
|||
Type *type = NULL;
|
||||
|
||||
ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
|
||||
|
||||
|
||||
elfParseType(data, offset, abbrev, unit, &type);
|
||||
return type;
|
||||
}
|
||||
|
@ -1906,13 +1906,13 @@ void elfGetObjectAttributes(CompileUnit *unit, u32 offset, Object *o)
|
|||
int bytes;
|
||||
u32 abbrevNum = elfReadLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
|
||||
|
||||
if(!abbrevNum) {
|
||||
return;
|
||||
}
|
||||
|
||||
ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
|
||||
|
||||
|
||||
for(int i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data = elfReadAttribute(data, attr);
|
||||
|
@ -1939,7 +1939,7 @@ void elfGetObjectAttributes(CompileUnit *unit, u32 offset, Object *o)
|
|||
case DW_AT_external:
|
||||
o->external = attr->flag;
|
||||
break;
|
||||
case DW_AT_const_value:
|
||||
case DW_AT_const_value:
|
||||
case DW_AT_abstract_origin:
|
||||
case DW_AT_declaration:
|
||||
case DW_AT_artificial:
|
||||
|
@ -1952,7 +1952,7 @@ void elfGetObjectAttributes(CompileUnit *unit, u32 offset, Object *o)
|
|||
fprintf(stderr, "Unknown object attribute %02x\n", attr->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u8 *elfParseObject(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
||||
|
@ -1991,7 +1991,7 @@ u8 *elfParseObject(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
case DW_AT_abstract_origin:
|
||||
elfGetObjectAttributes(unit, attr->value, o);
|
||||
break;
|
||||
case DW_AT_const_value:
|
||||
case DW_AT_const_value:
|
||||
case DW_AT_declaration:
|
||||
case DW_AT_artificial:
|
||||
break;
|
||||
|
@ -2013,7 +2013,7 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
int bytes;
|
||||
u32 start = func->lowPC;
|
||||
u32 end = func->highPC;
|
||||
|
||||
|
||||
for(int i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data = elfReadAttribute(data, attr);
|
||||
|
@ -2033,26 +2033,26 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(abbrev->hasChildren) {
|
||||
int nesting = 1;
|
||||
|
||||
while(nesting) {
|
||||
u32 abbrevNum = elfReadLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
|
||||
|
||||
if(!abbrevNum) {
|
||||
nesting--;
|
||||
continue;
|
||||
}
|
||||
|
||||
abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
|
||||
|
||||
|
||||
switch(abbrev->tag) {
|
||||
CASE_TYPE_TAG: // types only parsed when used
|
||||
case DW_TAG_label: // not needed
|
||||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||
break;
|
||||
break;
|
||||
case DW_TAG_lexical_block:
|
||||
data = elfParseBlock(data, abbrev, unit, func, lastVar);
|
||||
break;
|
||||
|
@ -2081,7 +2081,7 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
(*lastVar)->next = o;
|
||||
else
|
||||
func->variables = o;
|
||||
*lastVar = o;
|
||||
*lastVar = o;
|
||||
}
|
||||
break;
|
||||
case DW_TAG_inlined_subroutine:
|
||||
|
@ -2091,13 +2091,13 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
default:
|
||||
{
|
||||
fprintf(stderr, "Unknown block TAG %02x\n", abbrev->tag);
|
||||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
|
||||
void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func)
|
||||
|
@ -2106,7 +2106,7 @@ void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func)
|
|||
int bytes;
|
||||
u32 abbrevNum = elfReadLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
|
||||
|
||||
if(!abbrevNum) {
|
||||
return;
|
||||
}
|
||||
|
@ -2116,10 +2116,10 @@ void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func)
|
|||
for(int i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data = elfReadAttribute(data, attr);
|
||||
|
||||
|
||||
switch(attr->name) {
|
||||
case DW_AT_sibling:
|
||||
break;
|
||||
break;
|
||||
case DW_AT_name:
|
||||
if(func->name == NULL)
|
||||
func->name = attr->string;
|
||||
|
@ -2166,7 +2166,7 @@ void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func)
|
|||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown function attribute %02x\n", attr->name);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2178,7 +2178,7 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
{
|
||||
Function *func = (Function *)calloc(sizeof(Function), 1);
|
||||
*f = func;
|
||||
|
||||
|
||||
int bytes;
|
||||
bool mangled = false;
|
||||
bool declaration = false;
|
||||
|
@ -2233,7 +2233,7 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
case DW_AT_user_2002:
|
||||
case DW_AT_virtuality:
|
||||
case DW_AT_containing_type:
|
||||
case DW_AT_accessibility:
|
||||
case DW_AT_accessibility:
|
||||
// todo;
|
||||
break;
|
||||
case DW_AT_vtable_elem_location:
|
||||
|
@ -2263,7 +2263,7 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(abbrev->hasChildren) {
|
||||
int nesting = 1;
|
||||
Object *lastParam = NULL;
|
||||
|
@ -2272,14 +2272,14 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
while(nesting) {
|
||||
u32 abbrevNum = elfReadLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
|
||||
|
||||
if(!abbrevNum) {
|
||||
nesting--;
|
||||
continue;
|
||||
}
|
||||
|
||||
abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
|
||||
|
||||
|
||||
switch(abbrev->tag) {
|
||||
CASE_TYPE_TAG: // no need to parse types. only parsed when used
|
||||
case DW_TAG_label: // not needed
|
||||
|
@ -2334,7 +2334,7 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
if(abbrev->attrs[i].form == DW_FORM_block1)
|
||||
free(abbrev->attrs[i].block);
|
||||
}
|
||||
|
||||
|
||||
if(abbrev->hasChildren)
|
||||
nesting++;
|
||||
}
|
||||
|
@ -2342,7 +2342,7 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
|
|||
default:
|
||||
{
|
||||
fprintf(stderr, "Unknown function TAG %02x\n", abbrev->tag);
|
||||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||
data = elfSkipData(data, abbrev, unit->abbrevs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2358,34 +2358,34 @@ u8 *elfParseUnknownData(u8 *data, ELFAbbrev *abbrev, ELFAbbrev **abbrevs)
|
|||
// switch(abbrev->tag) {
|
||||
// default:
|
||||
fprintf(stderr, "Unknown TAG %02x\n", abbrev->tag);
|
||||
|
||||
|
||||
for(i = 0; i < abbrev->numAttrs; i++) {
|
||||
data = elfReadAttribute(data, &abbrev->attrs[i]);
|
||||
if(abbrev->attrs[i].form == DW_FORM_block1)
|
||||
free(abbrev->attrs[i].block);
|
||||
}
|
||||
|
||||
|
||||
if(abbrev->hasChildren) {
|
||||
int nesting = 1;
|
||||
while(nesting) {
|
||||
u32 abbrevNum = elfReadLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
|
||||
|
||||
if(!abbrevNum) {
|
||||
nesting--;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
abbrev = elfGetAbbrev(abbrevs, abbrevNum);
|
||||
|
||||
|
||||
fprintf(stderr, "Unknown TAG %02x\n", abbrev->tag);
|
||||
|
||||
|
||||
for(i = 0; i < abbrev->numAttrs; i++) {
|
||||
data = elfReadAttribute(data, &abbrev->attrs[i]);
|
||||
if(abbrev->attrs[i].form == DW_FORM_block1)
|
||||
free(abbrev->attrs[i].block);
|
||||
}
|
||||
|
||||
|
||||
if(abbrev->hasChildren) {
|
||||
nesting++;
|
||||
}
|
||||
|
@ -2435,7 +2435,7 @@ u8 *elfParseCompileUnitChildren(u8 *data, CompileUnit *unit)
|
|||
data = elfParseUnknownData(data, abbrev, unit->abbrevs);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
abbrevNum = elfReadLEB128(data, &bytes);
|
||||
data += bytes;
|
||||
}
|
||||
|
@ -2447,23 +2447,23 @@ CompileUnit *elfParseCompUnit(u8 *data, u8 *abbrevData)
|
|||
{
|
||||
int bytes;
|
||||
u8 *top = data;
|
||||
|
||||
|
||||
u32 length = elfRead4Bytes(data);
|
||||
data += 4;
|
||||
|
||||
|
||||
u16 version = elfRead2Bytes(data);
|
||||
data += 2;
|
||||
|
||||
|
||||
u32 offset = elfRead4Bytes(data);
|
||||
data += 4;
|
||||
|
||||
|
||||
u8 addrSize = *data++;
|
||||
|
||||
if(version != 2) {
|
||||
fprintf(stderr, "Unsupported debugging information version %d\n", version);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if(addrSize != 4) {
|
||||
fprintf(stderr, "Unsupported address size %d\n", addrSize);
|
||||
return NULL;
|
||||
|
@ -2483,9 +2483,9 @@ CompileUnit *elfParseCompUnit(u8 *data, u8 *abbrevData)
|
|||
unit->next = NULL;
|
||||
|
||||
elfCurrentUnit = unit;
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
for(i = 0; i < abbrev->numAttrs; i++) {
|
||||
ELFAttr *attr = &abbrev->attrs[i];
|
||||
data = elfReadAttribute(data, attr);
|
||||
|
@ -2540,7 +2540,7 @@ void elfParseAranges(u8 *data)
|
|||
ARanges *ranges = (ARanges *)calloc(sizeof(ARanges), 4);
|
||||
|
||||
int index = 0;
|
||||
|
||||
|
||||
while(data < end) {
|
||||
u32 len = elfRead4Bytes(data);
|
||||
data += 4;
|
||||
|
@ -2583,7 +2583,7 @@ void elfReadSymtab(u8 *data)
|
|||
int table = READ32LE(&sh->link);
|
||||
|
||||
char *strtable = (char *)elfReadSection(data, elfGetSectionByNumber(table));
|
||||
|
||||
|
||||
ELFSymbol *symtab = (ELFSymbol *)elfReadSection(data, sh);
|
||||
|
||||
int count = READ32LE(&sh->size) / sizeof(ELFSymbol);
|
||||
|
@ -2592,7 +2592,7 @@ void elfReadSymtab(u8 *data)
|
|||
elfSymbols = (Symbol *)malloc(sizeof(Symbol)*count);
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
for(i = 0; i < count; i++) {
|
||||
ELFSymbol *s = &symtab[i];
|
||||
int type = s->info & 15;
|
||||
|
@ -2622,7 +2622,7 @@ void elfReadSymtab(u8 *data)
|
|||
sym->size = READ32LE(&s->size);
|
||||
elfSymbolsCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
elfSymbolsStrTab = strtable;
|
||||
// free(symtab);
|
||||
}
|
||||
|
@ -2631,7 +2631,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
{
|
||||
int count = READ16LE(&eh->e_phnum);
|
||||
int i;
|
||||
|
||||
|
||||
if(READ32LE(&eh->e_entry) == 0x2000000)
|
||||
cpuIsMultiBoot = true;
|
||||
|
||||
|
@ -2655,7 +2655,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
data + READ32LE(&ph->offset),
|
||||
READ32LE(&ph->filesz));
|
||||
size += READ32LE(&ph->filesz);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(READ32LE(&ph->paddr) >= 0x8000000 &&
|
||||
READ32LE(&ph->paddr) <= 0x9ffffff) {
|
||||
|
@ -2675,7 +2675,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
|
||||
ELFSectionHeader **sh = (ELFSectionHeader **)
|
||||
malloc(sizeof(ELFSectionHeader *) * count);
|
||||
|
||||
|
||||
for(i = 0; i < count; i++) {
|
||||
sh[i] = (ELFSectionHeader *)p;
|
||||
p += sizeof(ELFSectionHeader);
|
||||
|
@ -2687,7 +2687,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
stringTable = (char *)elfReadSection(data,
|
||||
sh[READ16LE(&eh->e_shstrndx)]);
|
||||
}
|
||||
|
||||
|
||||
elfSectionHeaders = sh;
|
||||
elfSectionHeadersStringTable = stringTable;
|
||||
elfSectionHeadersCount = count;
|
||||
|
@ -2705,7 +2705,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
READ32LE(&sh[i]->offset),
|
||||
READ32LE(&sh[i]->size));
|
||||
size += READ32LE(&sh[i]->size);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(READ32LE(&sh[i]->addr) >= 0x8000000 &&
|
||||
READ32LE(&sh[i]->addr) <= 0x9ffffff) {
|
||||
|
@ -2714,7 +2714,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
READ32LE(&sh[i]->size));
|
||||
size += READ32LE(&sh[i]->size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2724,7 +2724,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
ELFSectionHeader *dbgHeader = elfGetSectionByName(".debug_info");
|
||||
if(dbgHeader == NULL) {
|
||||
fprintf(stderr, "Cannot find debug information\n");
|
||||
goto end;
|
||||
goto end;
|
||||
}
|
||||
|
||||
ELFSectionHeader *h = elfGetSectionByName(".debug_abbrev");
|
||||
|
@ -2732,7 +2732,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
fprintf(stderr, "Cannot find abbreviation table\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
elfDebugInfo = (DebugInfo *)calloc(sizeof(DebugInfo), 1);
|
||||
u8 *abbrevdata = elfReadSection(data, h);
|
||||
|
||||
|
@ -2742,19 +2742,19 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
elfDebugStrings = NULL;
|
||||
else
|
||||
elfDebugStrings = (char *)elfReadSection(data, h);
|
||||
|
||||
|
||||
u8 *debugdata = elfReadSection(data, dbgHeader);
|
||||
|
||||
|
||||
elfDebugInfo->debugdata = data;
|
||||
elfDebugInfo->infodata = debugdata;
|
||||
|
||||
|
||||
u32 total = READ32LE(&dbgHeader->size);
|
||||
u8 *end = debugdata + total;
|
||||
u8 *ddata = debugdata;
|
||||
|
||||
|
||||
CompileUnit *last = NULL;
|
||||
CompileUnit *unit = NULL;
|
||||
|
||||
|
||||
while(ddata < end) {
|
||||
unit = elfParseCompUnit(ddata, abbrevdata);
|
||||
unit->offset = (u32)(ddata-debugdata);
|
||||
|
@ -2780,7 +2780,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
elfParseCFA(data);
|
||||
elfReadSymtab(data);
|
||||
}
|
||||
end:
|
||||
end:
|
||||
if(sh) {
|
||||
free(sh);
|
||||
}
|
||||
|
@ -2788,7 +2788,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
|
|||
elfSectionHeaders = NULL;
|
||||
elfSectionHeadersStringTable = NULL;
|
||||
elfSectionHeadersCount = 0;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2802,9 +2802,9 @@ bool elfRead(const char *name, int& siz, FILE *f)
|
|||
fseek(f, 0, SEEK_SET);
|
||||
fread(elfFileData, 1, size, f);
|
||||
fclose(f);
|
||||
|
||||
|
||||
ELFHeader *header = (ELFHeader *)elfFileData;
|
||||
|
||||
|
||||
if(READ32LE(&header->magic) != 0x464C457F ||
|
||||
READ16LE(&header->e_machine) != 40 ||
|
||||
header->clazz != 1) {
|
||||
|
@ -2819,7 +2819,7 @@ bool elfRead(const char *name, int& siz, FILE *f)
|
|||
elfFileData = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2857,7 +2857,7 @@ void elfCleanUp(ELFAbbrev **abbrevs)
|
|||
free(abbrev->attrs);
|
||||
ELFAbbrev *next = abbrev->next;
|
||||
free(abbrev);
|
||||
|
||||
|
||||
abbrev = next;
|
||||
}
|
||||
}
|
||||
|
@ -2875,7 +2875,7 @@ void elfCleanUp(Type *t)
|
|||
free(o);
|
||||
o = next;
|
||||
}
|
||||
free(t->function);
|
||||
free(t->function);
|
||||
}
|
||||
break;
|
||||
case TYPE_array:
|
||||
|
@ -2974,7 +2974,7 @@ void elfCleanUp()
|
|||
free(elfFdes[i]);
|
||||
}
|
||||
free(elfFdes);
|
||||
|
||||
|
||||
elfFdes = NULL;
|
||||
elfFdeCount = 0;
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ struct Function {
|
|||
|
||||
struct LineInfoItem {
|
||||
u32 address;
|
||||
char *file;
|
||||
char *file;
|
||||
int line;
|
||||
};
|
||||
|
||||
|
@ -235,7 +235,7 @@ struct CompileUnit {
|
|||
ELFAbbrev **abbrevs;
|
||||
ARanges *ranges;
|
||||
char *name;
|
||||
char *compdir;
|
||||
char *compdir;
|
||||
u32 lowPC;
|
||||
u32 highPC;
|
||||
bool hasLineInfo;
|
||||
|
@ -245,7 +245,7 @@ struct CompileUnit {
|
|||
Function *lastFunction;
|
||||
Object *variables;
|
||||
Type *types;
|
||||
CompileUnit *next;
|
||||
CompileUnit *next;
|
||||
};
|
||||
|
||||
struct DebugInfo {
|
||||
|
|
|
@ -662,7 +662,7 @@ YY_RULE_SETUP
|
|||
#line 45 "expr.l"
|
||||
{
|
||||
return TOKEN_DOT;
|
||||
}
|
||||
}
|
||||
YY_BREAK
|
||||
case 5:
|
||||
YY_RULE_SETUP
|
||||
|
|
10
src/expr.cpp
10
src/expr.cpp
|
@ -14,7 +14,7 @@
|
|||
|
||||
#line 1 "expr.y"
|
||||
|
||||
namespace std {
|
||||
namespace std {
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -22,16 +22,16 @@ namespace std {
|
|||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "System.h"
|
||||
#include "elf.h"
|
||||
#include "exprNode.h"
|
||||
#include "exprNode.h"
|
||||
|
||||
extern int yyerror(char *);
|
||||
extern int yylex();
|
||||
extern int yylex();
|
||||
extern char *yytext;
|
||||
|
||||
|
||||
|
||||
//#define YYERROR_VERBOSE 1
|
||||
//#define YYDEBUG 1
|
||||
|
||||
|
|
|
@ -56,9 +56,9 @@ Node *exprNodeIdentifier()
|
|||
Node *n = (Node *)calloc(1, sizeof(Node));
|
||||
n->name = strdup(yytext);
|
||||
|
||||
exprNodeClean(n->name);
|
||||
exprNodeClean(n->name);
|
||||
exprNodeClean(n);
|
||||
|
||||
|
||||
n->print = exprNodeIdentifierPrint;
|
||||
n->resolve = exprNodeIdentifierResolve;
|
||||
return n;
|
||||
|
@ -89,7 +89,7 @@ Node *exprNodeNumber()
|
|||
exprNodeClean(n);
|
||||
n->location = atoi(yytext);
|
||||
n->type = &exprNodeType;
|
||||
n->locType = LOCATION_value;
|
||||
n->locType = LOCATION_value;
|
||||
n->print = exprNodeNumberPrint;
|
||||
n->resolve = exprNodeNumberResolve;
|
||||
return n;
|
||||
|
@ -109,9 +109,9 @@ Node *exprNodeStar(Node *exp)
|
|||
{
|
||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
||||
exprNodeClean(n);
|
||||
|
||||
|
||||
n->expression = exp;
|
||||
|
||||
|
||||
n->print = exprNodeStarPrint;
|
||||
n->resolve = exprNodeStarResolve;
|
||||
return n;
|
||||
|
@ -149,10 +149,10 @@ Node *exprNodeDot(Node *exp, Node *ident)
|
|||
{
|
||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
||||
exprNodeClean(n);
|
||||
|
||||
|
||||
n->expression = exp;
|
||||
n->name = ident->name;
|
||||
|
||||
|
||||
n->print = exprNodeDotPrint;
|
||||
n->resolve = exprNodeDotResolve;
|
||||
return n;
|
||||
|
@ -162,7 +162,7 @@ bool exprNodeDotResolve(Node *n, Function *f, CompileUnit *u)
|
|||
{
|
||||
if(n->expression->resolve(n->expression, f, u)) {
|
||||
TypeEnum tt = n->expression->type->type;
|
||||
|
||||
|
||||
if(tt == TYPE_struct ||
|
||||
tt == TYPE_union) {
|
||||
u32 loc = n->expression->location;
|
||||
|
@ -206,10 +206,10 @@ Node *exprNodeArrow(Node *exp, Node *ident)
|
|||
{
|
||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
||||
exprNodeClean(n);
|
||||
|
||||
|
||||
n->expression = exp;
|
||||
n->name = ident->name;
|
||||
|
||||
|
||||
n->print = exprNodeArrowPrint;
|
||||
n->resolve = exprNodeArrowResolve;
|
||||
return n;
|
||||
|
@ -224,7 +224,7 @@ bool exprNodeArrowResolve(Node *n, Function *f, CompileUnit *u)
|
|||
return false;
|
||||
}
|
||||
tt = n->expression->type->pointer->type;
|
||||
|
||||
|
||||
if(tt == TYPE_struct ||
|
||||
tt == TYPE_union) {
|
||||
u32 loc = debuggerReadMemory(n->expression->location);
|
||||
|
@ -268,9 +268,9 @@ Node *exprNodeAddr(Node *exp)
|
|||
{
|
||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
||||
exprNodeClean(n);
|
||||
|
||||
|
||||
n->expression = exp;
|
||||
|
||||
|
||||
n->print = exprNodeAddrPrint;
|
||||
n->resolve = exprNodeAddrResolve;
|
||||
return n;
|
||||
|
@ -303,9 +303,9 @@ Node *exprNodeSizeof(Node *exp)
|
|||
{
|
||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
||||
exprNodeClean(n);
|
||||
|
||||
|
||||
n->expression = exp;
|
||||
|
||||
|
||||
n->print = exprNodeSizeofPrint;
|
||||
n->resolve = exprNodeSizeofResolve;
|
||||
return n;
|
||||
|
@ -333,10 +333,10 @@ Node *exprNodeArray(Node *exp, Node *number)
|
|||
{
|
||||
Node *n = (Node *)calloc(1, sizeof(Node));
|
||||
exprNodeClean(n);
|
||||
|
||||
|
||||
n->expression = exp;
|
||||
n->value = number->location;
|
||||
|
||||
|
||||
n->print = exprNodeArrayPrint;
|
||||
n->resolve = exprNodeArrayResolve;
|
||||
return n;
|
||||
|
@ -349,7 +349,7 @@ int exprNodeGetSize(Array *a, int index)
|
|||
return a->type->size;
|
||||
} else {
|
||||
int size = a->bounds[a->maxBounds-1] * a->type->size;
|
||||
|
||||
|
||||
for(int i = index; i < a->maxBounds-1; i++) {
|
||||
size *= a->bounds[i];
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u)
|
|||
|
||||
if(tt == TYPE_array) {
|
||||
Array *a = n->expression->type->array;
|
||||
|
||||
|
||||
u32 loc = n->expression->location;
|
||||
Type *t = a->type;
|
||||
if(a->maxBounds > 1) {
|
||||
|
|
416
src/gb/GB.cpp
416
src/gb/GB.cpp
File diff suppressed because it is too large
Load Diff
|
@ -69,9 +69,9 @@ void gbCheatsReadGame(gzFile gzFile, int version)
|
|||
gbAddGgCheat(tmpCheat.cheatCode, tmpCheat.cheatDesc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int gbGsOn = utilReadInt(gzFile);
|
||||
|
||||
|
||||
if(gbGsOn) {
|
||||
int n = utilReadInt(gzFile);
|
||||
gbXxCheat tmpCheat;
|
||||
|
@ -112,7 +112,7 @@ bool gbCheatsLoadCheatList(const char *file)
|
|||
gbCheatNumber = 0;
|
||||
|
||||
gbCheatUpdateMap();
|
||||
|
||||
|
||||
int count = 0;
|
||||
|
||||
FILE *f = fopen(file, "rb");
|
||||
|
@ -126,7 +126,7 @@ bool gbCheatsLoadCheatList(const char *file)
|
|||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(version != 1) {
|
||||
systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_VERSION,
|
||||
N_("Unsupported cheat list version %d"), version);
|
||||
|
@ -146,12 +146,12 @@ bool gbCheatsLoadCheatList(const char *file)
|
|||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(fread(&count, 1, sizeof(count), f) != sizeof(count)) {
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(fread(gbCheatList, 1, sizeof(gbCheatList), f) != sizeof(gbCheatList)) {
|
||||
fclose(f);
|
||||
return false;
|
||||
|
@ -159,7 +159,7 @@ bool gbCheatsLoadCheatList(const char *file)
|
|||
|
||||
gbCheatNumber = count;
|
||||
gbCheatUpdateMap();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ bool gbVerifyGsCode(const char *code)
|
|||
|
||||
if(len == 0)
|
||||
return true;
|
||||
|
||||
|
||||
if(len != 8)
|
||||
return false;
|
||||
|
||||
|
@ -198,12 +198,12 @@ void gbAddGsCheat(const char *code, const char *desc)
|
|||
N_("Invalid GameShark code: %s"), code);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int i = gbCheatNumber;
|
||||
|
||||
strcpy(gbCheatList[i].cheatCode, code);
|
||||
strcpy(gbCheatList[i].cheatDesc, desc);
|
||||
|
||||
|
||||
gbCheatList[i].code = GBCHEAT_HEX_VALUE(code[0]) << 4 |
|
||||
GBCHEAT_HEX_VALUE(code[1]);
|
||||
|
||||
|
@ -244,7 +244,7 @@ bool gbVerifyGgCode(const char *code)
|
|||
|
||||
if(len == 0)
|
||||
return true;
|
||||
|
||||
|
||||
if(!GBCHEAT_IS_HEX(code[0]))
|
||||
return false;
|
||||
if(!GBCHEAT_IS_HEX(code[1]))
|
||||
|
@ -296,7 +296,7 @@ bool gbVerifyGgCode(const char *code)
|
|||
compare ^= 0x45;
|
||||
|
||||
int cloak = (GBCHEAT_HEX_VALUE(code[8])) ^ (GBCHEAT_HEX_VALUE(code[9]));
|
||||
|
||||
|
||||
if(cloak >=1 && cloak <= 7)
|
||||
return false;
|
||||
|
||||
|
@ -316,27 +316,27 @@ void gbAddGgCheat(const char *code, const char *desc)
|
|||
N_("Invalid GameGenie code: %s"), code);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int i = gbCheatNumber;
|
||||
|
||||
size_t len = strlen(code);
|
||||
|
||||
|
||||
strcpy(gbCheatList[i].cheatCode, code);
|
||||
strcpy(gbCheatList[i].cheatDesc, desc);
|
||||
|
||||
gbCheatList[i].code = 0x101;
|
||||
gbCheatList[i].value = (GBCHEAT_HEX_VALUE(code[0]) << 4) +
|
||||
GBCHEAT_HEX_VALUE(code[1]);
|
||||
|
||||
|
||||
gbCheatList[i].address = (GBCHEAT_HEX_VALUE(code[2]) << 8) +
|
||||
(GBCHEAT_HEX_VALUE(code[4]) << 4) +
|
||||
(GBCHEAT_HEX_VALUE(code[5])) +
|
||||
((GBCHEAT_HEX_VALUE(code[6]) ^ 0x0f) << 12);
|
||||
|
||||
gbCheatList[i].compare = 0;
|
||||
|
||||
|
||||
if(len != 7 && len != 8) {
|
||||
|
||||
|
||||
int compare = (GBCHEAT_HEX_VALUE(code[8]) << 4) +
|
||||
(GBCHEAT_HEX_VALUE(code[10]));
|
||||
compare = compare ^ 0xff;
|
||||
|
@ -351,9 +351,9 @@ void gbAddGgCheat(const char *code, const char *desc)
|
|||
|
||||
|
||||
gbCheatList[i].enabled = true;
|
||||
|
||||
|
||||
gbCheatMap[gbCheatList[i].address] = true;
|
||||
|
||||
|
||||
gbCheatNumber++;
|
||||
}
|
||||
|
||||
|
@ -364,12 +364,12 @@ void gbCheatRemove(int i)
|
|||
N_("Invalid cheat to remove %d"), i);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if((i+1) < gbCheatNumber) {
|
||||
memcpy(&gbCheatList[i], &gbCheatList[i+1], sizeof(gbCheat)*
|
||||
(gbCheatNumber-i-1));
|
||||
}
|
||||
|
||||
|
||||
gbCheatNumber--;
|
||||
|
||||
gbCheatUpdateMap();
|
||||
|
@ -404,12 +404,12 @@ void gbCheatDisable(int i)
|
|||
bool gbCheatReadGSCodeFile(const char *fileName)
|
||||
{
|
||||
FILE *file = fopen(fileName, "rb");
|
||||
|
||||
|
||||
if(!file) {
|
||||
systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), fileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
fseek(file, 0x18, SEEK_SET);
|
||||
int count = 0;
|
||||
fread(&count, 1, 2, file);
|
||||
|
@ -419,7 +419,7 @@ bool gbCheatReadGSCodeFile(const char *fileName)
|
|||
char code[9];
|
||||
int i;
|
||||
for(i = 0; i < count; i++) {
|
||||
fread(&dummy, 1, 2, file);
|
||||
fread(&dummy, 1, 2, file);
|
||||
fread(desc, 1, 12, file);
|
||||
desc[12] = 0;
|
||||
fread(code, 1, 8, file);
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
// along with this program; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
case 0x00:
|
||||
case 0x00:
|
||||
// NOP
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x01:
|
||||
// LD BC, NNNN
|
||||
BC.B.B0=gbReadOpcode(PC.W++);
|
||||
BC.B.B1=gbReadOpcode(PC.W++);
|
||||
|
@ -33,14 +33,14 @@
|
|||
// INC BC
|
||||
BC.W++;
|
||||
break;
|
||||
case 0x04:
|
||||
case 0x04:
|
||||
// INC B
|
||||
BC.B.B1++;
|
||||
BC.B.B1++;
|
||||
AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B1]| (BC.B.B1&0x0F? 0:H_FLAG);
|
||||
break;
|
||||
case 0x05:
|
||||
// DEC B
|
||||
BC.B.B1--;
|
||||
BC.B.B1--;
|
||||
AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B1]|
|
||||
((BC.B.B1&0x0F)==0x0F? H_FLAG:0);
|
||||
break;
|
||||
|
@ -75,7 +75,7 @@
|
|||
case 0x0b:
|
||||
// DEC BC
|
||||
BC.W--;
|
||||
break;
|
||||
break;
|
||||
case 0x0c:
|
||||
// INC C
|
||||
BC.B.B0++;
|
||||
|
@ -86,7 +86,7 @@
|
|||
BC.B.B0--;
|
||||
AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B0]|
|
||||
((BC.B.B0&0x0F)==0x0F? H_FLAG:0);
|
||||
break;
|
||||
break;
|
||||
case 0x0e:
|
||||
// LD C, NN
|
||||
BC.B.B0=gbReadOpcode(PC.W++);
|
||||
|
@ -102,10 +102,10 @@
|
|||
opcode = gbReadOpcode(PC.W++);
|
||||
if(gbCgbMode) {
|
||||
if(gbMemory[0xff4d] & 1) {
|
||||
|
||||
|
||||
gbSpeedSwitch();
|
||||
//clockTicks += 228*144-(gbSpeed ? 62 : 63);
|
||||
|
||||
|
||||
if(gbSpeed == 0)
|
||||
gbMemory[0xff4d] = 0x00;
|
||||
else
|
||||
|
@ -161,7 +161,7 @@
|
|||
case 0x1a:
|
||||
// LD A,(DE)
|
||||
AF.B.B1=gbReadMemory(DE.W);
|
||||
break;
|
||||
break;
|
||||
case 0x1b:
|
||||
// DEC DE
|
||||
DE.W--;
|
||||
|
@ -180,7 +180,7 @@
|
|||
case 0x1e:
|
||||
// LD E,NN
|
||||
DE.B.B0=gbReadOpcode(PC.W++);
|
||||
break;
|
||||
break;
|
||||
case 0x1f:
|
||||
// RRA
|
||||
tempValue=AF.B.B1&0x01;
|
||||
|
@ -200,7 +200,7 @@
|
|||
// LD HL,NNNN
|
||||
HL.B.B0=gbReadOpcode(PC.W++);
|
||||
HL.B.B1=gbReadOpcode(PC.W++);
|
||||
break;
|
||||
break;
|
||||
case 0x22:
|
||||
// LDI (HL),A
|
||||
gbWriteMemory(HL.W++,AF.B.B1);
|
||||
|
@ -254,7 +254,7 @@
|
|||
case 0x2b:
|
||||
// DEC HL
|
||||
HL.W--;
|
||||
break;
|
||||
break;
|
||||
case 0x2c:
|
||||
// INC L
|
||||
HL.B.B0++;
|
||||
|
@ -269,7 +269,7 @@
|
|||
case 0x2e:
|
||||
// LD L,NN
|
||||
HL.B.B0=gbReadOpcode(PC.W++);
|
||||
break;
|
||||
break;
|
||||
case 0x2f:
|
||||
// CPL
|
||||
AF.B.B1 ^= 255;
|
||||
|
@ -316,7 +316,7 @@
|
|||
case 0x37:
|
||||
// SCF
|
||||
AF.B.B0 = AF.B.B0 & Z_FLAG | C_FLAG;
|
||||
break;
|
||||
break;
|
||||
case 0x38:
|
||||
// JR C,NN
|
||||
if(AF.B.B0&C_FLAG) {
|
||||
|
@ -587,7 +587,7 @@ case 0x38:
|
|||
}
|
||||
else
|
||||
{
|
||||
// if (IE & IF) and interrupts are disabeld,
|
||||
// if (IE & IF) and interrupts are disabeld,
|
||||
// Halt is cancelled.
|
||||
if ((register_IE & register_IF & 0x1f) && !(IFF & 1))
|
||||
{
|
||||
|
@ -1309,7 +1309,7 @@ case 0x38:
|
|||
case 0xe8:
|
||||
// ADD SP,NN
|
||||
offset = (s8)gbReadOpcode(PC.W++);
|
||||
|
||||
|
||||
if(offset >= 0) {
|
||||
tempRegister.W = SP.W + offset;
|
||||
AF.B.B0 = (SP.W > tempRegister.W ? C_FLAG : 0) |
|
||||
|
|
|
@ -160,7 +160,7 @@ int gbDis(char *buffer, u16 address)
|
|||
u16 addr = address;
|
||||
sprintf(p, "%04x ", address);
|
||||
p += 12;
|
||||
|
||||
|
||||
u8 opcode = GB_READ(address);
|
||||
address++;
|
||||
const char *mnen;
|
||||
|
@ -175,7 +175,7 @@ int gbDis(char *buffer, u16 address)
|
|||
}
|
||||
while(op->value != (opcode & op->mask)) op++;
|
||||
mnen = op->mnen;
|
||||
|
||||
|
||||
u8 b0, b1;
|
||||
s8 disp;
|
||||
int shift;
|
||||
|
|
132
src/gb/gbGfx.cpp
132
src/gb/gbGfx.cpp
|
@ -73,7 +73,7 @@ void gbRenderLine()
|
|||
bank0 = &gbMemory[0x8000];
|
||||
bank1 = NULL;
|
||||
}
|
||||
|
||||
|
||||
int tile_map = 0x1800;
|
||||
if((register_LCDC & 8) != 0)
|
||||
tile_map = 0x1c00;
|
||||
|
@ -82,7 +82,7 @@ void gbRenderLine()
|
|||
|
||||
if((register_LCDC & 16) != 0)
|
||||
tile_pattern = 0x0000;
|
||||
|
||||
|
||||
int x = 0;
|
||||
int y = register_LY;
|
||||
|
||||
|
@ -96,7 +96,7 @@ void gbRenderLine()
|
|||
sy+=y;
|
||||
|
||||
sy &= 255;
|
||||
|
||||
|
||||
int tx = sx >> 3;
|
||||
int ty = sy >> 3;
|
||||
|
||||
|
@ -104,17 +104,17 @@ void gbRenderLine()
|
|||
int by = sy & 7;
|
||||
|
||||
int tile_map_line_y = tile_map + ty * 32;
|
||||
|
||||
|
||||
int tile_map_address = tile_map_line_y + tx;
|
||||
|
||||
u8 attrs = 0;
|
||||
if(bank1 != NULL)
|
||||
attrs = bank1[tile_map_address];
|
||||
|
||||
|
||||
u8 tile = bank0[tile_map_address];
|
||||
|
||||
|
||||
tile_map_address++;
|
||||
|
||||
|
||||
if(!(register_LCDC & 0x10))
|
||||
tile ^= 0x80;
|
||||
|
||||
|
@ -128,11 +128,11 @@ void gbRenderLine()
|
|||
|
||||
u8 tile_a = 0;
|
||||
u8 tile_b = 0;
|
||||
|
||||
|
||||
if(attrs & 0x40) {
|
||||
tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2;
|
||||
}
|
||||
|
||||
|
||||
if(attrs & 0x08) {
|
||||
tile_a = bank1[tile_pattern_address++];
|
||||
tile_b = bank1[tile_pattern_address];
|
||||
|
@ -140,34 +140,34 @@ void gbRenderLine()
|
|||
tile_a = bank0[tile_pattern_address++];
|
||||
tile_b = bank0[tile_pattern_address];
|
||||
}
|
||||
|
||||
|
||||
if(attrs & 0x20) {
|
||||
tile_a = gbInvertTab[tile_a];
|
||||
tile_b = gbInvertTab[tile_b];
|
||||
}
|
||||
|
||||
|
||||
while(bx > 0) {
|
||||
u8 c = (tile_a & bx) ? 1 : 0;
|
||||
c += ((tile_b & bx) ? 2 : 0);
|
||||
|
||||
|
||||
gbLineBuffer[x] = c; // mark the gbLineBuffer color
|
||||
|
||||
|
||||
if(attrs & 0x80)
|
||||
gbLineBuffer[x] |= 0x300;
|
||||
|
||||
|
||||
if(gbCgbMode) {
|
||||
c = c + (attrs & 7)*4;
|
||||
} else {
|
||||
c = (gbBgpLine[x+(gbSpeed ? 5 : 11)+SpritesTicks]>>(c<<1)) &3;
|
||||
c = (gbBgpLine[x+(gbSpeed ? 5 : 11)+SpritesTicks]>>(c<<1)) &3;
|
||||
if(gbSgbMode && !gbCgbMode) {
|
||||
int dx = x >> 3;
|
||||
int dy = y >> 3;
|
||||
|
||||
|
||||
int palette = gbSgbATF[dy * 20 + dx];
|
||||
|
||||
|
||||
if(c == 0)
|
||||
palette = 0;
|
||||
|
||||
|
||||
c = c + 4*palette;
|
||||
}
|
||||
}
|
||||
|
@ -178,9 +178,9 @@ void gbRenderLine()
|
|||
break;
|
||||
bx >>= 1;
|
||||
}
|
||||
|
||||
|
||||
bx = 128;
|
||||
|
||||
|
||||
SpritesTicks = gbSpritesTicks[x]*(gbSpeed ? 2 : 4);
|
||||
|
||||
sx = gbSCXLine[x+(gbSpeed ? 0 : 4)+SpritesTicks];
|
||||
|
@ -188,7 +188,7 @@ void gbRenderLine()
|
|||
sy = gbSCYLine[x+(gbSpeed ? 11 : 5)+SpritesTicks];
|
||||
|
||||
|
||||
tx = ((sx+x)>>3) & 0x1f;
|
||||
tx = ((sx+x)>>3) & 0x1f;
|
||||
|
||||
sy+=y;
|
||||
|
||||
|
@ -206,7 +206,7 @@ void gbRenderLine()
|
|||
|
||||
if(bank1)
|
||||
attrs = bank1[tile_map_line_y + tx];
|
||||
|
||||
|
||||
tile = bank0[tile_map_line_y + tx];
|
||||
|
||||
if(!(register_LCDC & 0x10))
|
||||
|
@ -229,7 +229,7 @@ void gbRenderLine()
|
|||
gbLineBuffer[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// do the window display
|
||||
// LCDC.0 also enables/disables the window in !gbCgbMode ?!?!
|
||||
// (tested on real hardware)
|
||||
|
@ -249,7 +249,7 @@ void gbRenderLine()
|
|||
}
|
||||
|
||||
int wy = inUseRegister_WY;
|
||||
|
||||
|
||||
if(y >= inUseRegister_WY) {
|
||||
|
||||
if (gbWindowLine == -1)
|
||||
|
@ -258,21 +258,21 @@ void gbRenderLine()
|
|||
int wx = register_WX;
|
||||
int swx = 0;
|
||||
wx -= 7;
|
||||
|
||||
|
||||
if( wx <= 159 && gbWindowLine <= 143) {
|
||||
|
||||
|
||||
tile_map = 0x1800;
|
||||
|
||||
|
||||
if((register_LCDC & 0x40) != 0)
|
||||
tile_map = 0x1c00;
|
||||
|
||||
|
||||
|
||||
|
||||
tx = 0;
|
||||
ty = gbWindowLine >> 3;
|
||||
|
||||
|
||||
bx = 128;
|
||||
by = gbWindowLine & 7;
|
||||
|
||||
|
||||
// Tries to emulate the 'window scrolling bug' when wx == 0 (ie. wx-7 == -7).
|
||||
// Nothing close to perfect, but good enought for now...
|
||||
if (wx == -7)
|
||||
|
@ -281,7 +281,7 @@ void gbRenderLine()
|
|||
bx >>= ((gbSCXLine[0]+((swx != 1) ? 1 : 0)) & 7);
|
||||
if (swx == 1)
|
||||
swx = 2;
|
||||
|
||||
|
||||
//bx >>= ((gbSCXLine[0]+(((swx>1) && (swx != 7)) ? 1 : 0)) & 7);
|
||||
|
||||
if ((swx == 7))
|
||||
|
@ -296,24 +296,24 @@ void gbRenderLine()
|
|||
bx >>= (-wx);
|
||||
wx = 0;
|
||||
}
|
||||
|
||||
|
||||
tile_map_line_y = tile_map + ty * 32;
|
||||
|
||||
|
||||
tile_map_address = tile_map_line_y + tx;
|
||||
|
||||
|
||||
x = wx;
|
||||
|
||||
|
||||
tile = bank0[tile_map_address];
|
||||
u8 attrs = 0;
|
||||
if(bank1)
|
||||
attrs = bank1[tile_map_address];
|
||||
tile_map_address++;
|
||||
|
||||
if((register_LCDC & 16) == 0) {
|
||||
|
||||
if((register_LCDC & 16) == 0) {
|
||||
if(tile < 128) tile += 128;
|
||||
else tile -= 128;
|
||||
}
|
||||
|
||||
|
||||
tile_pattern_address = tile_pattern + tile * 16 + by*2;
|
||||
|
||||
if (wx)
|
||||
|
@ -323,11 +323,11 @@ void gbRenderLine()
|
|||
while(x < 160) {
|
||||
u8 tile_a = 0;
|
||||
u8 tile_b = 0;
|
||||
|
||||
|
||||
if(attrs & 0x40) {
|
||||
tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2;
|
||||
}
|
||||
|
||||
|
||||
if(attrs & 0x08) {
|
||||
tile_a = bank1[tile_pattern_address++];
|
||||
tile_b = bank1[tile_pattern_address];
|
||||
|
@ -335,12 +335,12 @@ void gbRenderLine()
|
|||
tile_a = bank0[tile_pattern_address++];
|
||||
tile_b = bank0[tile_pattern_address];
|
||||
}
|
||||
|
||||
|
||||
if(attrs & 0x20) {
|
||||
tile_a = gbInvertTab[tile_a];
|
||||
tile_b = gbInvertTab[tile_b];
|
||||
}
|
||||
|
||||
|
||||
while(bx > 0) {
|
||||
u8 c = (tile_a & bx) != 0 ? 1 : 0;
|
||||
c += ((tile_b & bx) != 0 ? 2 : 0);
|
||||
|
@ -351,21 +351,21 @@ void gbRenderLine()
|
|||
gbLineBuffer[x] = 0x300 + c;
|
||||
else
|
||||
gbLineBuffer[x] = 0x100 + c;
|
||||
|
||||
|
||||
if(gbCgbMode) {
|
||||
c = c + (attrs & 7) * 4;
|
||||
} else {
|
||||
c = (gbBgpLine[x+(gbSpeed ? 5 : 11)+gbSpritesTicks[x]*(gbSpeed ? 2 : 4)]>>(c<<1)) &3;
|
||||
c = (gbBgpLine[x+(gbSpeed ? 5 : 11)+gbSpritesTicks[x]*(gbSpeed ? 2 : 4)]>>(c<<1)) &3;
|
||||
if(gbSgbMode && !gbCgbMode) {
|
||||
int dx = x >> 3;
|
||||
int dy = y >> 3;
|
||||
|
||||
|
||||
int palette = gbSgbATF[dy * 20 + dx];
|
||||
|
||||
|
||||
if(c == 0)
|
||||
palette = 0;
|
||||
|
||||
c = c + 4*palette;
|
||||
|
||||
c = c + 4*palette;
|
||||
}
|
||||
}
|
||||
gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c] & 0x7FFF] :
|
||||
|
@ -383,8 +383,8 @@ void gbRenderLine()
|
|||
tile = bank0[tile_map_line_y + tx];
|
||||
if(bank1)
|
||||
attrs = bank1[tile_map_line_y + tx];
|
||||
|
||||
if((register_LCDC & 16) == 0) {
|
||||
|
||||
if((register_LCDC & 16) == 0) {
|
||||
if(tile < 128) tile += 128;
|
||||
else tile -= 128;
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||
bank0 = &gbMemory[0x8000];
|
||||
bank1 = NULL;
|
||||
}
|
||||
|
||||
|
||||
int init = 0x0000;
|
||||
|
||||
for (int i = 0; i<4; i++)
|
||||
|
@ -448,7 +448,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||
|
||||
int flipx = (flags & 0x20);
|
||||
int flipy = (flags & 0x40);
|
||||
|
||||
|
||||
if((flags & 0x10))
|
||||
pal = gbObp1;
|
||||
|
||||
|
@ -457,7 +457,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||
}
|
||||
|
||||
int prio = flags & 0x80;
|
||||
|
||||
|
||||
int address = init + tile * 16 + 2*t;
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
|
@ -469,7 +469,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||
a = bank0[address++];
|
||||
b = bank0[address++];
|
||||
}
|
||||
|
||||
|
||||
for(int xx = 0; xx < 8; xx++) {
|
||||
u8 mask = 1 << (7-xx);
|
||||
u8 c = 0;
|
||||
|
@ -477,7 +477,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||
c++;
|
||||
if( (b & mask))
|
||||
c+=2;
|
||||
|
||||
|
||||
if(c==0) continue;
|
||||
|
||||
int xxx = xx+x;
|
||||
|
@ -516,8 +516,8 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
gbLineBuffer[xxx] = 0x200 + spriteNumber;
|
||||
|
||||
|
@ -530,13 +530,13 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
|
|||
if(gbSgbMode && !gbCgbMode) {
|
||||
int dx = xxx >> 3;
|
||||
int dy = y >> 3;
|
||||
|
||||
|
||||
int palette = gbSgbATF[dy * 20 + dx];
|
||||
|
||||
|
||||
if(c == 0)
|
||||
palette = 0;
|
||||
|
||||
c = c + 4*palette;
|
||||
|
||||
c = c + 4*palette;
|
||||
} else {
|
||||
c += 4;
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ void gbDrawSprites(bool draw)
|
|||
int x = 0;
|
||||
int y = 0;
|
||||
int count = 0;
|
||||
|
||||
|
||||
int size = (register_LCDC & 4);
|
||||
|
||||
if (!draw)
|
||||
|
@ -560,10 +560,10 @@ void gbDrawSprites(bool draw)
|
|||
|
||||
if(!(register_LCDC & 0x80))
|
||||
return;
|
||||
|
||||
|
||||
if((register_LCDC & 2) && (layerSettings & 0x1000)) {
|
||||
int yc = register_LY;
|
||||
|
||||
|
||||
int address = 0xfe00;
|
||||
for(int i = 0; i < 40; i++) {
|
||||
y = gbMemory[address++];
|
||||
|
@ -595,7 +595,7 @@ void gbDrawSprites(bool draw)
|
|||
// sprite limit reached!
|
||||
if(count >= 10)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ void mapperMBC1RAM(u16 address, u8 value)
|
|||
// MBC1 read RAM
|
||||
u8 mapperMBC1ReadRAM(u16 address)
|
||||
{
|
||||
|
||||
|
||||
if(gbDataMBC1.mapperRAMEnable)
|
||||
return gbMemoryMap[address>>12][address & 0x0fff];
|
||||
|
||||
|
@ -627,7 +627,7 @@ void mapperMBC5RAM(u16 address, u8 value)
|
|||
// MBC5 read RAM
|
||||
u8 mapperMBC5ReadRAM(u16 address)
|
||||
{
|
||||
|
||||
|
||||
if(gbDataMBC5.mapperRAMEnable)
|
||||
return gbMemoryMap[address>>12][address & 0x0fff];
|
||||
|
||||
|
@ -790,10 +790,10 @@ void mapperMBC7RAM(u16 address, u8 value)
|
|||
if(address == 0xa080) {
|
||||
// special processing needed
|
||||
int oldCs = gbDataMBC7.cs,oldSk=gbDataMBC7.sk;
|
||||
|
||||
|
||||
gbDataMBC7.cs=value>>7;
|
||||
gbDataMBC7.sk=(value>>6)&1;
|
||||
|
||||
|
||||
if(!oldCs && gbDataMBC7.cs) {
|
||||
if(gbDataMBC7.state==5) {
|
||||
if(gbDataMBC7.writeEnable) {
|
||||
|
@ -808,7 +808,7 @@ void mapperMBC7RAM(u16 address, u8 value)
|
|||
gbDataMBC7.state=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!oldSk && gbDataMBC7.sk) {
|
||||
if(gbDataMBC7.idle) {
|
||||
if(value & 0x02) {
|
||||
|
@ -855,7 +855,7 @@ void mapperMBC7RAM(u16 address, u8 value)
|
|||
gbDataMBC7.buffer <<= 1;
|
||||
gbDataMBC7.buffer |= (value&0x02)?1:0;
|
||||
gbDataMBC7.count++;
|
||||
|
||||
|
||||
switch(gbDataMBC7.code) {
|
||||
case 0:
|
||||
if(gbDataMBC7.count==16) {
|
||||
|
@ -897,7 +897,7 @@ void mapperMBC7RAM(u16 address, u8 value)
|
|||
gbDataMBC7.state=4;
|
||||
gbDataMBC7.count=0;
|
||||
gbDataMBC7.buffer = (gbMemory[0xa000+gbDataMBC7.address*2]<<8)|
|
||||
(gbMemory[0xa000+gbDataMBC7.address*2+1]);
|
||||
(gbMemory[0xa000+gbDataMBC7.address*2+1]);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
|
@ -913,9 +913,9 @@ void mapperMBC7RAM(u16 address, u8 value)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (oldSk && !gbDataMBC7.sk) {
|
||||
if (gbDataMBC7.state==4) {
|
||||
if (gbDataMBC7.state==4) {
|
||||
gbDataMBC7.value = (gbDataMBC7.buffer & 0x8000)?1:0;
|
||||
gbDataMBC7.buffer <<= 1;
|
||||
gbDataMBC7.count++;
|
||||
|
@ -1446,7 +1446,7 @@ void mapperTAMA5RAM(u16 address, u8 value)
|
|||
{
|
||||
gbDataTAMA5.mapperHours = (data/16)*10 + data%16;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = data;
|
||||
}
|
||||
|
@ -1457,7 +1457,7 @@ void mapperTAMA5RAM(u16 address, u8 value)
|
|||
case 1: // 'Commands' Register
|
||||
{
|
||||
gbMemoryMap[0xa][1] = gbDataTAMA5.mapperCommandNumber = value;
|
||||
|
||||
|
||||
// This should be only a 'is the flashrom ready ?' command.
|
||||
// However as I couldn't find any 'copy' command
|
||||
// (that seems to be needed for the saving system to work)
|
||||
|
@ -1501,7 +1501,7 @@ void mapperTAMA5RAM(u16 address, u8 value)
|
|||
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ void gbPrinterShowData()
|
|||
pal[3].g = 0;
|
||||
pal[3].b = 0;
|
||||
set_palette(pal);
|
||||
acquire_screen();
|
||||
acquire_screen();
|
||||
u8 *data = gbPrinterData;
|
||||
for(int y = 0; y < 0x12; y++) {
|
||||
for(int x = 0; x < 0x14; x++) {
|
||||
|
@ -100,7 +100,7 @@ void gbPrinterShowData()
|
|||
release_screen();
|
||||
while(!keypressed()) {
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
void gbPrinterReceiveData()
|
||||
|
@ -165,12 +165,12 @@ u8 gbPrinterSend(u8 b)
|
|||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterState++;
|
||||
} else {
|
||||
// todo: handle failure
|
||||
// todo: handle failure
|
||||
gbPrinterReset();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// receiving preamble
|
||||
// receiving preamble
|
||||
if(b == 0x33) {
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterState++;
|
||||
|
|
|
@ -91,12 +91,12 @@ void gbSgbReset()
|
|||
memset(gbSgbPacket, 0, 16 * 7);
|
||||
memset(gbSgbBorderChar, 0, 32*256);
|
||||
memset(gbSgbBorder, 0, 2048);
|
||||
|
||||
|
||||
int i;
|
||||
for(i = 1; i < 2048; i+=2) {
|
||||
gbSgbBorder[i] = 1 << 2;
|
||||
}
|
||||
|
||||
|
||||
for(i = 0; i < 32; i++) {
|
||||
gbPalette[i*4] = (0x1f) | (0x1f << 5) | (0x1f << 10);
|
||||
gbPalette[i*4+1] = (0x15) | (0x15 << 5) | (0x15 << 10);
|
||||
|
@ -123,7 +123,7 @@ void gbSgbShutdown()
|
|||
if(gbSgbBorder != NULL) {
|
||||
free(gbSgbBorder);
|
||||
gbSgbBorder = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gbSgbFillScreen(u16 color)
|
||||
|
@ -178,7 +178,7 @@ void gbSgbRenderScreenToBuffer()
|
|||
u16 patternAddress = 0x8800;
|
||||
|
||||
int flag = 1;
|
||||
|
||||
|
||||
if(register_LCDC & 0x10) {
|
||||
patternAddress = 0x8000;
|
||||
flag = 0;
|
||||
|
@ -209,7 +209,7 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
|
|||
u16 *dest = (u16*)pix + ((y+1) * (256+2)) + x;
|
||||
u8 *dest8 = (u8*)pix + ((y*256)+x)*3;
|
||||
u32 *dest32 = (u32*)pix + ((y+1)*257) + x;
|
||||
|
||||
|
||||
u8 *tileAddress = &gbSgbBorderChar[tile * 32];
|
||||
u8 *tileAddress2 = &gbSgbBorderChar[tile * 32 + 16];
|
||||
|
||||
|
@ -221,10 +221,10 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
|
|||
palette += 4;
|
||||
|
||||
palette *= 16;
|
||||
|
||||
|
||||
u8 xx = 0;
|
||||
u8 yy = 0;
|
||||
|
||||
|
||||
int flipX = attr & 0x40;
|
||||
int flipY = attr & 0x80;
|
||||
|
||||
|
@ -234,9 +234,9 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
|
|||
u8 b = *tileAddress++;
|
||||
u8 c = *tileAddress2++;
|
||||
u8 d = *tileAddress2++;
|
||||
|
||||
|
||||
while(mask > 0) {
|
||||
|
||||
|
||||
u8 color = 0;
|
||||
if(a & mask)
|
||||
color++;
|
||||
|
@ -249,7 +249,7 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
|
|||
|
||||
u8 xxx = xx;
|
||||
u8 yyy = yy;
|
||||
|
||||
|
||||
if(flipX)
|
||||
xxx = 7 - xx;
|
||||
if(flipY)
|
||||
|
@ -290,12 +290,12 @@ void gbSgbRenderBorder()
|
|||
{
|
||||
if(gbBorderOn) {
|
||||
u8 *fromAddress = gbSgbBorder;
|
||||
|
||||
|
||||
for(u8 y = 0; y < 28; y++) {
|
||||
for(u8 x = 0; x< 32; x++) {
|
||||
u8 tile = *fromAddress++;
|
||||
u8 attr = *fromAddress++;
|
||||
|
||||
|
||||
gbSgbDrawBorderTile(x*8,y*8,tile,attr);
|
||||
}
|
||||
}
|
||||
|
@ -307,9 +307,9 @@ void gbSgbPicture()
|
|||
gbSgbRenderScreenToBuffer();
|
||||
|
||||
memcpy(gbSgbBorder, gbSgbScreenBuffer, 2048);
|
||||
|
||||
|
||||
u16 *paletteAddr = (u16 *)&gbSgbScreenBuffer[2048];
|
||||
|
||||
|
||||
for(int i = 64; i < 128; i++) {
|
||||
gbPalette[i] = READ16LE(paletteAddr++);
|
||||
}
|
||||
|
@ -321,9 +321,9 @@ void gbSgbPicture()
|
|||
systemGbBorderOn();
|
||||
}
|
||||
|
||||
if(gbBorderOn && !gbSgbMask)
|
||||
if(gbBorderOn && !gbSgbMask)
|
||||
gbSgbRenderBorder();
|
||||
|
||||
|
||||
if(gbSgbMode && gbCgbMode && gbSgbCGBSupport > 4) {
|
||||
gbSgbCGBSupport = 0;
|
||||
gbSgbMode = 0;
|
||||
|
@ -340,15 +340,15 @@ void gbSgbSetPalette(int a,int b,u16 *p)
|
|||
{
|
||||
u16 bit00 = READ16LE(p++);
|
||||
int i;
|
||||
|
||||
|
||||
for(i = 1; i < 4; i++) {
|
||||
gbPalette[a*4+i] = READ16LE(p++);
|
||||
}
|
||||
|
||||
|
||||
for(i = 1; i < 4; i++) {
|
||||
gbPalette[b*4+i] = READ16LE(p++);
|
||||
}
|
||||
|
||||
|
||||
gbPalette[0] = gbPalette[4] = gbPalette[8] = gbPalette[12] = bit00;
|
||||
if(gbBorderOn && !gbSgbMask)
|
||||
gbSgbRenderBorder();
|
||||
|
@ -357,9 +357,9 @@ void gbSgbSetPalette(int a,int b,u16 *p)
|
|||
void gbSgbScpPalette()
|
||||
{
|
||||
gbSgbRenderScreenToBuffer();
|
||||
|
||||
|
||||
u16 *fromAddress = (u16 *)gbSgbScreenBuffer;
|
||||
|
||||
|
||||
for(int i = 0; i < 512*4; i++) {
|
||||
gbSgbSCPPalette[i] = READ16LE(fromAddress++);
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ void gbSgbSetPalette()
|
|||
if(atf & 0x80) {
|
||||
gbSgbSetATF(atf & 0x3f);
|
||||
}
|
||||
|
||||
|
||||
if(atf & 0x40) {
|
||||
gbSgbMask = 0;
|
||||
if(gbBorderOn)
|
||||
|
@ -418,7 +418,7 @@ void gbSgbAttributeBlock()
|
|||
nDataSet = 1;
|
||||
|
||||
while(nDataSet) {
|
||||
u8 controlCode = (*fromAddress++) & 7;
|
||||
u8 controlCode = (*fromAddress++) & 7;
|
||||
u8 paletteDesignation = (*fromAddress++) & 0x3f;
|
||||
u8 startH = (*fromAddress++) & 0x1f;
|
||||
u8 startV = (*fromAddress++) & 0x1f;
|
||||
|
@ -426,7 +426,7 @@ void gbSgbAttributeBlock()
|
|||
u8 endV = (*fromAddress++) & 0x1f;
|
||||
|
||||
u8 * toAddress = gbSgbATF;
|
||||
|
||||
|
||||
for(u8 y = 0; y < 18; y++) {
|
||||
for(u8 x = 0; x < 20; x++) {
|
||||
if(x < startH || y < startV ||
|
||||
|
@ -444,7 +444,7 @@ void gbSgbAttributeBlock()
|
|||
if(controlCode & 0x02)
|
||||
*toAddress = (paletteDesignation>>2) & 0x03;
|
||||
else if(controlCode == 0x01)
|
||||
*toAddress = paletteDesignation & 0x03;
|
||||
*toAddress = paletteDesignation & 0x03;
|
||||
}
|
||||
toAddress++;
|
||||
}
|
||||
|
@ -461,9 +461,9 @@ void gbSgbSetColumnPalette(u8 col, u8 p)
|
|||
col = 19;
|
||||
|
||||
p &= 3;
|
||||
|
||||
|
||||
u8 *toAddress = &gbSgbATF[col];
|
||||
|
||||
|
||||
for(u8 y = 0; y < 18; y++) {
|
||||
*toAddress = p;
|
||||
toAddress += 20;
|
||||
|
@ -478,9 +478,9 @@ void gbSgbSetRowPalette(u8 row, u8 p)
|
|||
row = 17;
|
||||
|
||||
p &= 3;
|
||||
|
||||
|
||||
u8 *toAddress = &gbSgbATF[row*20];
|
||||
|
||||
|
||||
for(u8 x = 0; x < 20; x++) {
|
||||
*toAddress++ = p;
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ void gbSgbAttributeDivide()
|
|||
else if ( i > coord)
|
||||
gbSgbSetColumnPalette(i, colorBR);
|
||||
else
|
||||
gbSgbSetColumnPalette(i, colorOL);
|
||||
gbSgbSetColumnPalette(i, colorOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ void gbSgbAttributeCharacter()
|
|||
u8 s = 6;
|
||||
u8 *fromAddress = &gbSgbPacket[6];
|
||||
u8 v = *fromAddress++;
|
||||
|
||||
|
||||
if(style) {
|
||||
while(nDataSet) {
|
||||
u8 p = (v >> s) & 3;
|
||||
|
@ -593,14 +593,14 @@ void gbSgbAttributeCharacter()
|
|||
if(startV == 18)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(s)
|
||||
s -= 2;
|
||||
else {
|
||||
s = 6;
|
||||
v = *fromAddress++;
|
||||
nDataSet--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ void gbSgbAttributeCharacter()
|
|||
void gbSgbSetATFList()
|
||||
{
|
||||
gbSgbRenderScreenToBuffer();
|
||||
|
||||
|
||||
u8 *fromAddress = gbSgbScreenBuffer;
|
||||
u8 *toAddress = gbSgbATFList;
|
||||
|
||||
|
@ -631,7 +631,7 @@ void gbSgbMaskEnable()
|
|||
int gbSgbMaskFlag = gbSgbPacket[1] & 3;
|
||||
|
||||
gbSgbMask = gbSgbMaskFlag;
|
||||
|
||||
|
||||
switch(gbSgbMaskFlag) {
|
||||
case 1:
|
||||
break;
|
||||
|
@ -652,14 +652,14 @@ void gbSgbMaskEnable()
|
|||
void gbSgbChrTransfer()
|
||||
{
|
||||
gbSgbRenderScreenToBuffer();
|
||||
|
||||
|
||||
int address = (gbSgbPacket[1] & 1) * (128*32);
|
||||
|
||||
if(gbSgbPacket[1] & 1)
|
||||
gbSgbCGBSupport |= 2;
|
||||
else
|
||||
gbSgbCGBSupport |= 1;
|
||||
|
||||
|
||||
memcpy(&gbSgbBorderChar[address], gbSgbScreenBuffer, 128 * 32);
|
||||
|
||||
if(gbBorderAutomatic && !gbBorderOn && gbSgbCGBSupport > 4) {
|
||||
|
@ -676,7 +676,7 @@ void gbSgbChrTransfer()
|
|||
gbSgbMask = 0;
|
||||
gbSgbRenderBorder();
|
||||
gbReset();
|
||||
}
|
||||
}
|
||||
|
||||
if(gbSgbCGBSupport > 4)
|
||||
gbSgbCGBSupport = 0;
|
||||
|
@ -787,13 +787,13 @@ void gbSgbDoBitTransfer(u8 value)
|
|||
gbSgbReadingController &= 3;
|
||||
}
|
||||
}
|
||||
gbSgbPacketTimeout = 0;
|
||||
gbSgbPacketTimeout = 0;
|
||||
} else {
|
||||
if(value == 0x10)
|
||||
gbSgbReadingController |= 0x2;
|
||||
else if(value == 0x20)
|
||||
gbSgbReadingController |= 0x01;
|
||||
gbSgbPacketTimeout = 0;
|
||||
gbSgbPacketTimeout = 0;
|
||||
}
|
||||
gbSgbPacketTimeout = 0;
|
||||
break;
|
||||
|
@ -887,7 +887,7 @@ void gbSgbSaveGame(gzFile gzFile)
|
|||
|
||||
utilGzWrite(gzFile, gbSgbBorder, 2048);
|
||||
utilGzWrite(gzFile, gbSgbBorderChar, 32*256);
|
||||
|
||||
|
||||
utilGzWrite(gzFile, gbSgbPacket, 16*7);
|
||||
|
||||
utilGzWrite(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16));
|
||||
|
@ -908,7 +908,7 @@ void gbSgbReadGame(gzFile gzFile, int version)
|
|||
utilGzRead(gzFile, gbSgbBorder, 2048);
|
||||
utilGzRead(gzFile, gbSgbBorderChar, 32*256);
|
||||
}
|
||||
|
||||
|
||||
utilGzRead(gzFile, gbSgbPacket, 16*7);
|
||||
|
||||
utilGzRead(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16));
|
||||
|
|
|
@ -137,7 +137,7 @@ bool gbDigitalSound = false;
|
|||
void gbSoundEvent(register u16 address, register int data)
|
||||
{
|
||||
int freq = 0;
|
||||
|
||||
|
||||
gbMemory[address] = data;
|
||||
|
||||
#ifndef FINAL_VERSION
|
||||
|
@ -195,7 +195,7 @@ void gbSoundEvent(register u16 address, register int data)
|
|||
sound1SweepSteps = gbMemory[NR10] & 7;
|
||||
sound1SweepUpDown = gbMemory[NR10] & 0x08;
|
||||
sound1SweepStep = 0;
|
||||
|
||||
|
||||
sound1Index = 0;
|
||||
sound1On = 1;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ void gbSoundEvent(register u16 address, register int data)
|
|||
sound2EnvelopeUpDown = gbMemory[NR22] & 0x08;
|
||||
sound2ATL = sound2ATLreload;
|
||||
sound2EnvelopeATLReload = sound2EnvelopeATL = 689 * (gbMemory[NR22] & 7);
|
||||
|
||||
|
||||
sound2Index = 0;
|
||||
sound2On = 1;
|
||||
}
|
||||
|
@ -297,13 +297,13 @@ void gbSoundEvent(register u16 address, register int data)
|
|||
sound4NSteps = data & 0x08;
|
||||
|
||||
sound4Skip = (freq << 8) / NOISE_MAGIC;
|
||||
|
||||
|
||||
sound4Clock = data >> 4;
|
||||
|
||||
freq = freq / soundShiftClock[sound4Clock];
|
||||
|
||||
sound4ShiftSkip = (freq << 8) / NOISE_MAGIC;
|
||||
|
||||
|
||||
break;
|
||||
case NR44:
|
||||
gbMemory[address] = data | 0xbf;
|
||||
|
@ -316,10 +316,10 @@ void gbSoundEvent(register u16 address, register int data)
|
|||
sound4EnvelopeATLReload = sound4EnvelopeATL = 689 * (gbMemory[NR42] & 7);
|
||||
|
||||
sound4On = 1;
|
||||
|
||||
|
||||
sound4Index = 0;
|
||||
sound4ShiftIndex = 0;
|
||||
|
||||
|
||||
if(sound4NSteps)
|
||||
sound4ShiftRight = 0x7fff;
|
||||
else
|
||||
|
@ -366,7 +366,7 @@ void gbSoundEvent(register u16 address, register int data)
|
|||
int freq = 0;
|
||||
|
||||
int value = 0;
|
||||
|
||||
|
||||
if(sound1On && (sound1ATL || !sound1Continue)) {
|
||||
sound1Index += soundQuality*sound1Skip;
|
||||
sound1Index &= 0x1fffffff;
|
||||
|
@ -376,20 +376,20 @@ void gbSoundEvent(register u16 address, register int data)
|
|||
|
||||
soundBuffer[0][soundIndex] = value;
|
||||
|
||||
|
||||
|
||||
if(sound1On) {
|
||||
if(sound1ATL) {
|
||||
sound1ATL-=soundQuality;
|
||||
|
||||
|
||||
if(sound1ATL <=0 && sound1Continue) {
|
||||
gbMemory[NR52] &= 0xfe;
|
||||
sound1On = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(sound1EnvelopeATL) {
|
||||
sound1EnvelopeATL-=soundQuality;
|
||||
|
||||
|
||||
if(sound1EnvelopeATL<=0) {
|
||||
if(sound1EnvelopeUpDown) {
|
||||
if(sound1EnvelopeVolume < 15)
|
||||
|
@ -398,22 +398,22 @@ void gbSoundEvent(register u16 address, register int data)
|
|||
if(sound1EnvelopeVolume)
|
||||
sound1EnvelopeVolume--;
|
||||
}
|
||||
|
||||
|
||||
sound1EnvelopeATL += sound1EnvelopeATLReload;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(sound1SweepATL) {
|
||||
sound1SweepATL-=soundQuality;
|
||||
|
||||
|
||||
if(sound1SweepATL<=0) {
|
||||
freq = (((int)(freq1high & 7)) << 8) | freq1low;
|
||||
|
||||
|
||||
int updown = 1;
|
||||
|
||||
|
||||
if(sound1SweepUpDown)
|
||||
updown = -1;
|
||||
|
||||
|
||||
int newfreq = 0;
|
||||
if(sound1SweepSteps) {
|
||||
newfreq = freq + updown * freq / (1 << sound1SweepSteps);
|
||||
|
@ -421,7 +421,7 @@ void gbSoundEvent(register u16 address, register int data)
|
|||
newfreq = 0;
|
||||
} else
|
||||
newfreq = freq;
|
||||
|
||||
|
||||
if(newfreq < 0) {
|
||||
sound1SweepATL += sound1SweepATLReload;
|
||||
} else if(newfreq > 2047) {
|
||||
|
@ -431,7 +431,7 @@ void gbSoundEvent(register u16 address, register int data)
|
|||
} else {
|
||||
sound1SweepATL += sound1SweepATLReload;
|
||||
sound1Skip = SOUND_MAGIC/(2048 - newfreq);
|
||||
|
||||
|
||||
freq1low = newfreq & 0xff;
|
||||
freq1high = (freq1high & 0xf8) |((newfreq >> 8) & 7);
|
||||
}
|
||||
|
@ -446,29 +446,29 @@ void gbSoundChannel2()
|
|||
int vol = sound2EnvelopeVolume;
|
||||
|
||||
int value = 0;
|
||||
|
||||
|
||||
if(sound2On && (sound2ATL || !sound2Continue)) {
|
||||
sound2Index += soundQuality*sound2Skip;
|
||||
sound2Index &= 0x1fffffff;
|
||||
|
||||
value = ((s8)sound2Wave[sound2Index>>24]) * vol;
|
||||
}
|
||||
|
||||
|
||||
soundBuffer[1][soundIndex] = value;
|
||||
|
||||
|
||||
if(sound2On) {
|
||||
if(sound2ATL) {
|
||||
sound2ATL-=soundQuality;
|
||||
|
||||
|
||||
if(sound2ATL <= 0 && sound2Continue) {
|
||||
gbMemory[NR52] &= 0xfd;
|
||||
sound2On = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(sound2EnvelopeATL) {
|
||||
sound2EnvelopeATL-=soundQuality;
|
||||
|
||||
|
||||
if(sound2EnvelopeATL <= 0) {
|
||||
if(sound2EnvelopeUpDown) {
|
||||
if(sound2EnvelopeVolume < 15)
|
||||
|
@ -481,21 +481,21 @@ void gbSoundChannel2()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gbSoundChannel3()
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
|
||||
if(sound3On && (sound3ATL || !sound3Continue)) {
|
||||
|
||||
value = sound3Last;
|
||||
|
||||
sound3Index += soundQuality*sound3Skip;
|
||||
sound3Index &= 0x1fffffff;
|
||||
|
||||
|
||||
value = gbMemory[0xff30 + (sound3Index>>25)];
|
||||
|
||||
|
||||
if( (sound3Index & 0x01000000)) {
|
||||
value &= 0x0f;
|
||||
} else {
|
||||
|
@ -503,7 +503,7 @@ void gbSoundChannel3()
|
|||
}
|
||||
|
||||
value -= 8;
|
||||
|
||||
|
||||
switch(sound3OutputLevel) {
|
||||
case 0:
|
||||
value = 0;
|
||||
|
@ -519,13 +519,13 @@ void gbSoundChannel3()
|
|||
}
|
||||
sound3Last = value;
|
||||
}
|
||||
|
||||
|
||||
soundBuffer[2][soundIndex] = value;
|
||||
|
||||
|
||||
if(sound3On) {
|
||||
if(sound3ATL) {
|
||||
sound3ATL-=soundQuality;
|
||||
|
||||
|
||||
if(sound3ATL <= 0 && sound3Continue) {
|
||||
gbMemory[NR52] &= 0xfb;
|
||||
sound3On = 0;
|
||||
|
@ -558,34 +558,34 @@ void gbSoundChannel4()
|
|||
(sound4ShiftRight << 13)) & 0x4000) |
|
||||
(sound4ShiftRight >> 1);
|
||||
|
||||
sound4ShiftIndex -= 0x200000;
|
||||
sound4ShiftIndex -= 0x200000;
|
||||
}
|
||||
}
|
||||
|
||||
sound4Index &= 0x1fffff;
|
||||
sound4ShiftIndex &= 0x1fffff;
|
||||
|
||||
sound4Index &= 0x1fffff;
|
||||
sound4ShiftIndex &= 0x1fffff;
|
||||
|
||||
value = ((sound4ShiftRight & 1)*2-1) * vol;
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
soundBuffer[3][soundIndex] = value;
|
||||
|
||||
if(sound4On) {
|
||||
if(sound4ATL) {
|
||||
sound4ATL-=soundQuality;
|
||||
|
||||
|
||||
if(sound4ATL <= 0 && sound4Continue) {
|
||||
gbMemory[NR52] &= 0xf7;
|
||||
sound4On = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(sound4EnvelopeATL) {
|
||||
sound4EnvelopeATL-=soundQuality;
|
||||
|
||||
|
||||
if(sound4EnvelopeATL <= 0) {
|
||||
if(sound4EnvelopeUpDown) {
|
||||
if(sound4EnvelopeVolume < 15)
|
||||
|
@ -621,7 +621,7 @@ void gbSoundMix()
|
|||
res *= soundLevel1*256;
|
||||
else
|
||||
res *= soundLevel1*60;
|
||||
|
||||
|
||||
if(soundEcho) {
|
||||
res *= 2;
|
||||
res += soundFilter[soundEchoIndex];
|
||||
|
@ -653,7 +653,7 @@ void gbSoundMix()
|
|||
res >>= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(res > 32767)
|
||||
res = 32767;
|
||||
if(res < -32768)
|
||||
|
@ -663,7 +663,7 @@ void gbSoundMix()
|
|||
soundFinalWave[++soundBufferIndex] = res;
|
||||
else
|
||||
soundFinalWave[soundBufferIndex++] = res;
|
||||
|
||||
|
||||
res = 0;
|
||||
|
||||
if(soundBalance & 1) {
|
||||
|
@ -683,7 +683,7 @@ void gbSoundMix()
|
|||
res *= soundLevel2*256;
|
||||
else
|
||||
res *= soundLevel2*60;
|
||||
|
||||
|
||||
if(soundEcho) {
|
||||
res *= 2;
|
||||
res += soundFilter[soundEchoIndex];
|
||||
|
@ -691,7 +691,7 @@ void gbSoundMix()
|
|||
soundFilter[soundEchoIndex++] = res;
|
||||
|
||||
if(soundEchoIndex >= 4000)
|
||||
soundEchoIndex = 0;
|
||||
soundEchoIndex = 0;
|
||||
}
|
||||
|
||||
if(soundLowPass) {
|
||||
|
@ -699,7 +699,7 @@ void gbSoundMix()
|
|||
soundRight[3] = soundRight[2];
|
||||
soundRight[2] = soundRight[1];
|
||||
soundRight[1] = soundRight[0];
|
||||
soundRight[0] = res;
|
||||
soundRight[0] = res;
|
||||
res = (soundRight[4] + 2*soundRight[3] + 8*soundRight[2] + 2*soundRight[1] +
|
||||
soundRight[0])/14;
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ void gbSoundMix()
|
|||
res >>= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(res > 32767)
|
||||
res = 32767;
|
||||
if(res < -32768)
|
||||
|
@ -738,21 +738,21 @@ void gbSoundTick()
|
|||
gbSoundChannel2();
|
||||
gbSoundChannel3();
|
||||
gbSoundChannel4();
|
||||
|
||||
|
||||
gbSoundMix();
|
||||
} else {
|
||||
soundFinalWave[soundBufferIndex++] = 0;
|
||||
soundFinalWave[soundBufferIndex++] = 0;
|
||||
}
|
||||
|
||||
|
||||
soundIndex++;
|
||||
|
||||
|
||||
if(2*soundBufferIndex >= soundBufferLen) {
|
||||
if(systemSoundOn) {
|
||||
if(soundPaused) {
|
||||
soundResume();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
systemWriteDataToSoundBuffer();
|
||||
}
|
||||
soundIndex = 0;
|
||||
|
@ -765,7 +765,7 @@ void gbSoundReset()
|
|||
{
|
||||
soundPaused = 1;
|
||||
soundPlay = 0;
|
||||
SOUND_CLOCK_TICKS = soundQuality * 24;
|
||||
SOUND_CLOCK_TICKS = soundQuality * 24;
|
||||
soundTicks = SOUND_CLOCK_TICKS;
|
||||
soundNextPosition = 0;
|
||||
soundMasterOn = 1;
|
||||
|
@ -774,7 +774,7 @@ void gbSoundReset()
|
|||
soundLevel1 = 7;
|
||||
soundLevel2 = 7;
|
||||
soundVIN = 0;
|
||||
|
||||
|
||||
sound1On = 0;
|
||||
sound1ATL = 0;
|
||||
sound1Skip = 0;
|
||||
|
@ -790,7 +790,7 @@ void gbSoundReset()
|
|||
sound1SweepUpDown = 0;
|
||||
sound1SweepStep = 0;
|
||||
sound1Wave = soundWavePattern[2];
|
||||
|
||||
|
||||
sound2On = 0;
|
||||
sound2ATL = 0;
|
||||
sound2Skip = 0;
|
||||
|
@ -801,14 +801,14 @@ void gbSoundReset()
|
|||
sound2EnvelopeUpDown = 0;
|
||||
sound2EnvelopeATLReload = 0;
|
||||
sound2Wave = soundWavePattern[2];
|
||||
|
||||
|
||||
sound3On = 0;
|
||||
sound3ATL = 0;
|
||||
sound3Skip = 0;
|
||||
sound3Index = 0;
|
||||
sound3Continue = 0;
|
||||
sound3OutputLevel = 0;
|
||||
|
||||
|
||||
sound4On = 0;
|
||||
sound4Clock = 0;
|
||||
sound4ATL = 0;
|
||||
|
@ -837,10 +837,10 @@ void gbSoundReset()
|
|||
gbSoundEvent(0xff17, 0x00);
|
||||
gbSoundEvent(0xff19, 0xbf);
|
||||
|
||||
gbSoundEvent(0xff1a, 0x7f);
|
||||
gbSoundEvent(0xff1a, 0x7f);
|
||||
gbSoundEvent(0xff1b, 0xff);
|
||||
gbSoundEvent(0xff1c, 0xbf);
|
||||
gbSoundEvent(0xff1e, 0xbf);
|
||||
gbSoundEvent(0xff1e, 0xbf);
|
||||
|
||||
gbSoundEvent(0xff20, 0xff);
|
||||
gbSoundEvent(0xff21, 0x00);
|
||||
|
@ -864,7 +864,7 @@ void gbSoundReset()
|
|||
sound2On = 0;
|
||||
sound3On = 0;
|
||||
sound4On = 0;
|
||||
|
||||
|
||||
int addr = 0xff30;
|
||||
|
||||
while(addr < 0xff40) {
|
||||
|
@ -1016,7 +1016,7 @@ void gbSoundReadGame(int version,gzFile gzFile)
|
|||
}
|
||||
|
||||
soundBufferIndex = soundIndex * 2;
|
||||
|
||||
|
||||
utilGzRead(gzFile, soundBuffer, 4*735);
|
||||
utilGzRead(gzFile, soundFinalWave, 2*735);
|
||||
|
||||
|
@ -1028,7 +1028,7 @@ void gbSoundReadGame(int version,gzFile gzFile)
|
|||
soundQuality = -1;
|
||||
gbSoundSetQuality(1);
|
||||
}
|
||||
|
||||
|
||||
sound1Wave = soundWavePattern[gbMemory[NR11] >> 6];
|
||||
sound2Wave = soundWavePattern[gbMemory[NR21] >> 6];
|
||||
}
|
||||
|
|
|
@ -1,227 +1,227 @@
|
|||
#include "gbafilter.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
extern int systemColorDepth;
|
||||
extern int systemRedShift;
|
||||
extern int systemGreenShift;
|
||||
extern int systemBlueShift;
|
||||
|
||||
extern u16 systemColorMap16[0x10000];
|
||||
extern u32 systemColorMap32[0x10000];
|
||||
|
||||
static const unsigned char curve[32] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x10, 0x12,
|
||||
0x14, 0x16, 0x18, 0x1c, 0x20, 0x28, 0x30, 0x38,
|
||||
0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x80,
|
||||
0x88, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0};
|
||||
|
||||
// output R G B
|
||||
static const unsigned char influence[3 * 3] = { 16, 4, 4, // red
|
||||
8, 16, 8, // green
|
||||
0, 8, 16};// blue
|
||||
|
||||
inline void swap(short & a, short & b)
|
||||
{
|
||||
short temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
void gbafilter_pal(u16 * buf, int count)
|
||||
{
|
||||
short temp[3 * 3], s;
|
||||
unsigned pix;
|
||||
u8 red, green, blue;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
pix = *buf;
|
||||
|
||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||
temp[3] = s * influence[3];
|
||||
temp[4] = s * influence[4];
|
||||
temp[5] = s * influence[5];
|
||||
|
||||
s = curve[(pix >> systemRedShift) & 0x1f];
|
||||
temp[0] = s * influence[0];
|
||||
temp[1] = s * influence[1];
|
||||
temp[2] = s * influence[2];
|
||||
|
||||
s = curve[(pix >> systemBlueShift) & 0x1f];
|
||||
temp[6] = s * influence[6];
|
||||
temp[7] = s * influence[7];
|
||||
temp[8] = s * influence[8];
|
||||
|
||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
||||
temp[3] <<= 1;
|
||||
temp[0] <<= 2;
|
||||
temp[0] += temp[3] + temp[6];
|
||||
|
||||
red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||
if (red > 31) red = 31;
|
||||
|
||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
||||
temp[5] <<= 1;
|
||||
temp[2] <<= 2;
|
||||
temp[2] += temp[5] + temp[8];
|
||||
|
||||
blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||
if (blue > 31) blue = 31;
|
||||
|
||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
||||
temp[4] <<= 1;
|
||||
temp[1] <<= 2;
|
||||
temp[1] += temp[4] + temp[7];
|
||||
|
||||
green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||
if (green > 31) green = 31;
|
||||
|
||||
pix = red << systemRedShift;
|
||||
pix += green << systemGreenShift;
|
||||
pix += blue << systemBlueShift;
|
||||
|
||||
*buf++ = pix;
|
||||
}
|
||||
}
|
||||
|
||||
void gbafilter_pal32(u32 * buf, int count)
|
||||
{
|
||||
short temp[3 * 3], s;
|
||||
unsigned pix;
|
||||
u8 red, green, blue;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
pix = *buf;
|
||||
|
||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||
temp[3] = s * influence[3];
|
||||
temp[4] = s * influence[4];
|
||||
temp[5] = s * influence[5];
|
||||
|
||||
s = curve[(pix >> systemRedShift) & 0x1f];
|
||||
temp[0] = s * influence[0];
|
||||
temp[1] = s * influence[1];
|
||||
temp[2] = s * influence[2];
|
||||
|
||||
s = curve[(pix >> systemBlueShift) & 0x1f];
|
||||
temp[6] = s * influence[6];
|
||||
temp[7] = s * influence[7];
|
||||
temp[8] = s * influence[8];
|
||||
|
||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
||||
temp[3] <<= 1;
|
||||
temp[0] <<= 2;
|
||||
temp[0] += temp[3] + temp[6];
|
||||
|
||||
//red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||
red = ((int(temp[0]) * 160) >> 14) + 32;
|
||||
|
||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
||||
temp[5] <<= 1;
|
||||
temp[2] <<= 2;
|
||||
temp[2] += temp[5] + temp[8];
|
||||
|
||||
//blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||
blue = ((int(temp[2]) * 160) >> 14) + 32;
|
||||
|
||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
||||
temp[4] <<= 1;
|
||||
temp[1] <<= 2;
|
||||
temp[1] += temp[4] + temp[7];
|
||||
|
||||
//green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||
green = ((int(temp[1]) * 160) >> 14) + 32;
|
||||
|
||||
//pix = red << redshift;
|
||||
//pix += green << greenshift;
|
||||
//pix += blue << blueshift;
|
||||
|
||||
pix = red << (systemRedShift - 3);
|
||||
pix += green << (systemGreenShift - 3);
|
||||
pix += blue << (systemBlueShift - 3);
|
||||
|
||||
*buf++ = pix;
|
||||
}
|
||||
}
|
||||
|
||||
// for palette mode to work with the three spoony filters in 32bpp depth
|
||||
|
||||
void gbafilter_pad(u8 * buf, int count)
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u8 r;
|
||||
u8 g;
|
||||
u8 b;
|
||||
u8 a;
|
||||
} part;
|
||||
unsigned whole;
|
||||
}
|
||||
mask;
|
||||
|
||||
mask.whole = 0x1f << systemRedShift;
|
||||
mask.whole += 0x1f << systemGreenShift;
|
||||
mask.whole += 0x1f << systemBlueShift;
|
||||
|
||||
switch (systemColorDepth)
|
||||
{
|
||||
case 24:
|
||||
while (count--)
|
||||
{
|
||||
*buf++ &= mask.part.r;
|
||||
*buf++ &= mask.part.g;
|
||||
*buf++ &= mask.part.b;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
while (count--)
|
||||
{
|
||||
*((u32*)buf) &= mask.whole;
|
||||
buf += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void UpdateSystemColorMaps(int lcd)
|
||||
{
|
||||
switch(systemColorDepth) {
|
||||
case 16:
|
||||
{
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd == 1) gbafilter_pal(systemColorMap16, 0x10000);
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
{
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd == 1) gbafilter_pal32(systemColorMap32, 0x10000);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
#include "gbafilter.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
extern int systemColorDepth;
|
||||
extern int systemRedShift;
|
||||
extern int systemGreenShift;
|
||||
extern int systemBlueShift;
|
||||
|
||||
extern u16 systemColorMap16[0x10000];
|
||||
extern u32 systemColorMap32[0x10000];
|
||||
|
||||
static const unsigned char curve[32] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x10, 0x12,
|
||||
0x14, 0x16, 0x18, 0x1c, 0x20, 0x28, 0x30, 0x38,
|
||||
0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x80,
|
||||
0x88, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0};
|
||||
|
||||
// output R G B
|
||||
static const unsigned char influence[3 * 3] = { 16, 4, 4, // red
|
||||
8, 16, 8, // green
|
||||
0, 8, 16};// blue
|
||||
|
||||
inline void swap(short & a, short & b)
|
||||
{
|
||||
short temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
void gbafilter_pal(u16 * buf, int count)
|
||||
{
|
||||
short temp[3 * 3], s;
|
||||
unsigned pix;
|
||||
u8 red, green, blue;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
pix = *buf;
|
||||
|
||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||
temp[3] = s * influence[3];
|
||||
temp[4] = s * influence[4];
|
||||
temp[5] = s * influence[5];
|
||||
|
||||
s = curve[(pix >> systemRedShift) & 0x1f];
|
||||
temp[0] = s * influence[0];
|
||||
temp[1] = s * influence[1];
|
||||
temp[2] = s * influence[2];
|
||||
|
||||
s = curve[(pix >> systemBlueShift) & 0x1f];
|
||||
temp[6] = s * influence[6];
|
||||
temp[7] = s * influence[7];
|
||||
temp[8] = s * influence[8];
|
||||
|
||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
||||
temp[3] <<= 1;
|
||||
temp[0] <<= 2;
|
||||
temp[0] += temp[3] + temp[6];
|
||||
|
||||
red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||
if (red > 31) red = 31;
|
||||
|
||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
||||
temp[5] <<= 1;
|
||||
temp[2] <<= 2;
|
||||
temp[2] += temp[5] + temp[8];
|
||||
|
||||
blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||
if (blue > 31) blue = 31;
|
||||
|
||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
||||
temp[4] <<= 1;
|
||||
temp[1] <<= 2;
|
||||
temp[1] += temp[4] + temp[7];
|
||||
|
||||
green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||
if (green > 31) green = 31;
|
||||
|
||||
pix = red << systemRedShift;
|
||||
pix += green << systemGreenShift;
|
||||
pix += blue << systemBlueShift;
|
||||
|
||||
*buf++ = pix;
|
||||
}
|
||||
}
|
||||
|
||||
void gbafilter_pal32(u32 * buf, int count)
|
||||
{
|
||||
short temp[3 * 3], s;
|
||||
unsigned pix;
|
||||
u8 red, green, blue;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
pix = *buf;
|
||||
|
||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||
temp[3] = s * influence[3];
|
||||
temp[4] = s * influence[4];
|
||||
temp[5] = s * influence[5];
|
||||
|
||||
s = curve[(pix >> systemRedShift) & 0x1f];
|
||||
temp[0] = s * influence[0];
|
||||
temp[1] = s * influence[1];
|
||||
temp[2] = s * influence[2];
|
||||
|
||||
s = curve[(pix >> systemBlueShift) & 0x1f];
|
||||
temp[6] = s * influence[6];
|
||||
temp[7] = s * influence[7];
|
||||
temp[8] = s * influence[8];
|
||||
|
||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
||||
temp[3] <<= 1;
|
||||
temp[0] <<= 2;
|
||||
temp[0] += temp[3] + temp[6];
|
||||
|
||||
//red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||
red = ((int(temp[0]) * 160) >> 14) + 32;
|
||||
|
||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
||||
temp[5] <<= 1;
|
||||
temp[2] <<= 2;
|
||||
temp[2] += temp[5] + temp[8];
|
||||
|
||||
//blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||
blue = ((int(temp[2]) * 160) >> 14) + 32;
|
||||
|
||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
||||
temp[4] <<= 1;
|
||||
temp[1] <<= 2;
|
||||
temp[1] += temp[4] + temp[7];
|
||||
|
||||
//green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||
green = ((int(temp[1]) * 160) >> 14) + 32;
|
||||
|
||||
//pix = red << redshift;
|
||||
//pix += green << greenshift;
|
||||
//pix += blue << blueshift;
|
||||
|
||||
pix = red << (systemRedShift - 3);
|
||||
pix += green << (systemGreenShift - 3);
|
||||
pix += blue << (systemBlueShift - 3);
|
||||
|
||||
*buf++ = pix;
|
||||
}
|
||||
}
|
||||
|
||||
// for palette mode to work with the three spoony filters in 32bpp depth
|
||||
|
||||
void gbafilter_pad(u8 * buf, int count)
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u8 r;
|
||||
u8 g;
|
||||
u8 b;
|
||||
u8 a;
|
||||
} part;
|
||||
unsigned whole;
|
||||
}
|
||||
mask;
|
||||
|
||||
mask.whole = 0x1f << systemRedShift;
|
||||
mask.whole += 0x1f << systemGreenShift;
|
||||
mask.whole += 0x1f << systemBlueShift;
|
||||
|
||||
switch (systemColorDepth)
|
||||
{
|
||||
case 24:
|
||||
while (count--)
|
||||
{
|
||||
*buf++ &= mask.part.r;
|
||||
*buf++ &= mask.part.g;
|
||||
*buf++ &= mask.part.b;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
while (count--)
|
||||
{
|
||||
*((u32*)buf) &= mask.whole;
|
||||
buf += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void UpdateSystemColorMaps(int lcd)
|
||||
{
|
||||
switch(systemColorDepth) {
|
||||
case 16:
|
||||
{
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd == 1) gbafilter_pal(systemColorMap16, 0x10000);
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
{
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd == 1) gbafilter_pal32(systemColorMap32, 0x10000);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "System.h"
|
||||
|
||||
void gbafilter_pal(u16 * buf, int count);
|
||||
void gbafilter_pal32(u32 * buf, int count);
|
||||
void gbafilter_pad(u8 * buf, int count);
|
||||
#include "System.h"
|
||||
|
||||
void gbafilter_pal(u16 * buf, int count);
|
||||
void gbafilter_pal32(u32 * buf, int count);
|
||||
void gbafilter_pad(u8 * buf, int count);
|
||||
|
|
28
src/hq2x.cpp
28
src/hq2x.cpp
|
@ -489,15 +489,15 @@ void hq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
{
|
||||
u16 *dst0 = (u16 *)dstPtr;
|
||||
u16 *dst1 = dst0 + (dstPitch >> 1);
|
||||
|
||||
|
||||
u16 *src0 = (u16 *)srcPtr;
|
||||
u16 *src1 = src0 + (srcPitch >> 1);
|
||||
u16 *src2 = src1 + (srcPitch >> 1);
|
||||
|
||||
|
||||
hq2x_16_def(dst0, dst1, src0, src0, src1, width);
|
||||
|
||||
|
||||
int count = height;
|
||||
|
||||
|
||||
count -= 2;
|
||||
while(count) {
|
||||
dst0 += dstPitch;
|
||||
|
@ -518,14 +518,14 @@ void hq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
{
|
||||
u32 *dst0 = (u32 *)dstPtr;
|
||||
u32 *dst1 = dst0 + (dstPitch >> 2);
|
||||
|
||||
|
||||
u32 *src0 = (u32 *)srcPtr;
|
||||
u32 *src1 = src0 + (srcPitch >> 2);
|
||||
u32 *src2 = src1 + (srcPitch >> 2);
|
||||
hq2x_32_def(dst0, dst1, src0, src0, src1, width);
|
||||
|
||||
|
||||
int count = height;
|
||||
|
||||
|
||||
count -= 2;
|
||||
while(count) {
|
||||
dst0 += dstPitch >> 1;
|
||||
|
@ -546,15 +546,15 @@ void lq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
{
|
||||
u16 *dst0 = (u16 *)dstPtr;
|
||||
u16 *dst1 = dst0 + (dstPitch >> 1);
|
||||
|
||||
|
||||
u16 *src0 = (u16 *)srcPtr;
|
||||
u16 *src1 = src0 + (srcPitch >> 1);
|
||||
u16 *src2 = src1 + (srcPitch >> 1);
|
||||
|
||||
|
||||
lq2x_16_def(dst0, dst1, src0, src0, src1, width);
|
||||
|
||||
|
||||
int count = height;
|
||||
|
||||
|
||||
count -= 2;
|
||||
while(count) {
|
||||
dst0 += dstPitch;
|
||||
|
@ -575,14 +575,14 @@ void lq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
{
|
||||
u32 *dst0 = (u32 *)dstPtr;
|
||||
u32 *dst1 = dst0 + (dstPitch >> 2);
|
||||
|
||||
|
||||
u32 *src0 = (u32 *)srcPtr;
|
||||
u32 *src1 = src0 + (srcPitch >> 2);
|
||||
u32 *src2 = src1 + (srcPitch >> 2);
|
||||
lq2x_32_def(dst0, dst1, src0, src0, src1, width);
|
||||
|
||||
|
||||
int count = height;
|
||||
|
||||
|
||||
count -= 2;
|
||||
while(count) {
|
||||
dst0 += dstPitch >> 1;
|
||||
|
|
512
src/hq2x.h
512
src/hq2x.h
File diff suppressed because it is too large
Load Diff
292
src/hq3x32.cpp
292
src/hq3x32.cpp
|
@ -1,146 +1,146 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#include "Util.h"
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void hq3x_16(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq3x_32(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq4x_16(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq4x_32(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
|
||||
unsigned int LUT16to32[65536];
|
||||
unsigned int RGBtoYUV[65536];
|
||||
}
|
||||
|
||||
void InitLUTs(void)
|
||||
{
|
||||
int i, j, k, r, g, b, Y, u, v;
|
||||
|
||||
for (i=0; i<65536; i++)
|
||||
LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3);
|
||||
|
||||
for (i=0; i<32; i++)
|
||||
for (j=0; j<64; j++)
|
||||
for (k=0; k<32; k++)
|
||||
{
|
||||
r = i << 3;
|
||||
g = j << 2;
|
||||
b = k << 3;
|
||||
Y = (r + g + b) >> 2;
|
||||
u = 128 + ((r - b) >> 2);
|
||||
v = 128 + ((-r + 2*g -b)>>3);
|
||||
RGBtoYUV[ (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v;
|
||||
}
|
||||
}
|
||||
|
||||
int hq3xinited=0;
|
||||
extern int realsystemRedShift, realsystemBlueShift;
|
||||
|
||||
void hq3x32(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
// NOTICE! This driver wants 16 bit, not 32 bit input!
|
||||
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq3x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2) );
|
||||
if (realsystemRedShift == 3)
|
||||
{ // damn you opengl...
|
||||
int offset = (dstPitch - (Xres *12)) / 4;
|
||||
unsigned int *p = (unsigned int *)pOut;
|
||||
Yres *= 3;
|
||||
while(Yres--)
|
||||
{
|
||||
for(int i=0;i<Xres*3;i++)
|
||||
{
|
||||
*p = (*p & 0xFF0000) >> 16 |
|
||||
(*p & 0x0000FF) << 16 |
|
||||
(*p & 0x00FF00);
|
||||
p++;
|
||||
}
|
||||
p += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hq3x16(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq3x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
}
|
||||
|
||||
|
||||
void hq4x16(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq4x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
}
|
||||
|
||||
void hq4x32(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
// NOTICE! This driver wants 16 bit, not 32 bit input!
|
||||
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq4x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
if (realsystemRedShift == 3)
|
||||
{ // damn you opengl...
|
||||
int offset = (dstPitch - (Xres *16)) / 4;
|
||||
unsigned int *p = (unsigned int *)pOut;
|
||||
Yres *= 4;
|
||||
while(Yres--)
|
||||
{
|
||||
for(int i=0;i<Xres*4;i++)
|
||||
{
|
||||
*p = (*p & 0xFF0000) >> 16 |
|
||||
(*p & 0x0000FF) << 16 |
|
||||
(*p & 0x00FF00);
|
||||
p++;
|
||||
}
|
||||
p += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#include "Util.h"
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void hq3x_16(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq3x_32(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq4x_16(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq4x_32(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
|
||||
unsigned int LUT16to32[65536];
|
||||
unsigned int RGBtoYUV[65536];
|
||||
}
|
||||
|
||||
void InitLUTs(void)
|
||||
{
|
||||
int i, j, k, r, g, b, Y, u, v;
|
||||
|
||||
for (i=0; i<65536; i++)
|
||||
LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3);
|
||||
|
||||
for (i=0; i<32; i++)
|
||||
for (j=0; j<64; j++)
|
||||
for (k=0; k<32; k++)
|
||||
{
|
||||
r = i << 3;
|
||||
g = j << 2;
|
||||
b = k << 3;
|
||||
Y = (r + g + b) >> 2;
|
||||
u = 128 + ((r - b) >> 2);
|
||||
v = 128 + ((-r + 2*g -b)>>3);
|
||||
RGBtoYUV[ (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v;
|
||||
}
|
||||
}
|
||||
|
||||
int hq3xinited=0;
|
||||
extern int realsystemRedShift, realsystemBlueShift;
|
||||
|
||||
void hq3x32(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
// NOTICE! This driver wants 16 bit, not 32 bit input!
|
||||
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq3x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2) );
|
||||
if (realsystemRedShift == 3)
|
||||
{ // damn you opengl...
|
||||
int offset = (dstPitch - (Xres *12)) / 4;
|
||||
unsigned int *p = (unsigned int *)pOut;
|
||||
Yres *= 3;
|
||||
while(Yres--)
|
||||
{
|
||||
for(int i=0;i<Xres*3;i++)
|
||||
{
|
||||
*p = (*p & 0xFF0000) >> 16 |
|
||||
(*p & 0x0000FF) << 16 |
|
||||
(*p & 0x00FF00);
|
||||
p++;
|
||||
}
|
||||
p += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hq3x16(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq3x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
}
|
||||
|
||||
|
||||
void hq4x16(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq4x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
}
|
||||
|
||||
void hq4x32(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
// NOTICE! This driver wants 16 bit, not 32 bit input!
|
||||
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq4x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
if (realsystemRedShift == 3)
|
||||
{ // damn you opengl...
|
||||
int offset = (dstPitch - (Xres *16)) / 4;
|
||||
unsigned int *p = (unsigned int *)pOut;
|
||||
Yres *= 4;
|
||||
while(Yres--)
|
||||
{
|
||||
for(int i=0;i<Xres*4;i++)
|
||||
{
|
||||
*p = (*p & 0xFF0000) >> 16 |
|
||||
(*p & 0x0000FF) << 16 |
|
||||
(*p & 0x00FF00);
|
||||
p++;
|
||||
}
|
||||
p += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
7268
src/hq3x32.h
7268
src/hq3x32.h
File diff suppressed because it is too large
Load Diff
5052
src/hq3x_16.asm
5052
src/hq3x_16.asm
File diff suppressed because it is too large
Load Diff
5140
src/hq3x_32.asm
5140
src/hq3x_32.asm
File diff suppressed because it is too large
Load Diff
7914
src/hq4x_16.asm
7914
src/hq4x_16.asm
File diff suppressed because it is too large
Load Diff
7856
src/hq4x_32.asm
7856
src/hq4x_32.asm
File diff suppressed because it is too large
Load Diff
|
@ -134,7 +134,7 @@ void Interp3(unsigned char * pc, unsigned int c1, unsigned int c2)
|
|||
void Interp4(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
#ifdef MMX
|
||||
#ifdef MMX
|
||||
__asm
|
||||
{
|
||||
mov eax, pc
|
||||
|
@ -290,7 +290,7 @@ bool Diff(unsigned int c1, unsigned int c2)
|
|||
pcmpgtd mm4, trV
|
||||
por mm2, mm3
|
||||
por mm2, mm4
|
||||
|
||||
|
||||
movd retval, mm2
|
||||
|
||||
EMMS
|
||||
|
|
|
@ -1,90 +1,90 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#define SIZE_PIXEL 4 // 32bit = 4 bytes
|
||||
|
||||
#define abs32(value) (value & 0x7FFFFFFF)
|
||||
|
||||
#define PIXEL00_1M Interp1( pOut, c[5], c[1] );
|
||||
#define PIXEL00_1U Interp1( pOut, c[5], c[2] );
|
||||
#define PIXEL00_1L Interp1( pOut, c[5], c[4] );
|
||||
#define PIXEL00_2 Interp2( pOut, c[5], c[4], c[2] );
|
||||
#define PIXEL00_4 Interp4( pOut, c[5], c[4], c[2] );
|
||||
#define PIXEL00_5 Interp5( pOut, c[4], c[2] );
|
||||
#define PIXEL00_C *((unsigned int*)(pOut)) = c[5];
|
||||
|
||||
#define PIXEL01_1 Interp1( pOut+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL01_3 Interp3( pOut+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL01_6 Interp1( pOut+SIZE_PIXEL, c[2], c[5] );
|
||||
#define PIXEL01_C *((unsigned int*)(pOut+4)) = c[5];
|
||||
|
||||
#define PIXEL02_1M Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3] );
|
||||
#define PIXEL02_1U Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL02_1R Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL02_2 Interp2( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] );
|
||||
#define PIXEL02_4 Interp4( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] );
|
||||
#define PIXEL02_5 Interp5( pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6] );
|
||||
#define PIXEL02_C *((unsigned int*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL10_1 Interp1( pOut+dstPitch, c[5], c[4] );
|
||||
#define PIXEL10_3 Interp3( pOut+dstPitch, c[5], c[4] );
|
||||
#define PIXEL10_6 Interp1( pOut+dstPitch, c[4], c[5] );
|
||||
#define PIXEL10_C *((unsigned int*)(pOut+dstPitch)) = c[5];
|
||||
|
||||
#define PIXEL11 *((unsigned int*)(pOut+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL12_1 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL12_3 Interp3( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL12_6 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5] );
|
||||
#define PIXEL12_C *((unsigned int*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL20_1M Interp1( pOut+dstPitch+dstPitch, c[5], c[7] );
|
||||
#define PIXEL20_1D Interp1( pOut+dstPitch+dstPitch, c[5], c[8] );
|
||||
#define PIXEL20_1L Interp1( pOut+dstPitch+dstPitch, c[5], c[4] );
|
||||
#define PIXEL20_2 Interp2( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
|
||||
#define PIXEL20_4 Interp4( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
|
||||
#define PIXEL20_5 Interp5( pOut+dstPitch+dstPitch, c[8], c[4] );
|
||||
#define PIXEL20_C *((unsigned int*)(pOut+dstPitch+dstPitch)) = c[5];
|
||||
|
||||
#define PIXEL21_1 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL21_3 Interp3( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL21_6 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5] );
|
||||
#define PIXEL21_C *((unsigned int*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL22_1M Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9] );
|
||||
#define PIXEL22_1D Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL22_1R Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL22_2 Interp2( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] );
|
||||
#define PIXEL22_4 Interp4( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] );
|
||||
#define PIXEL22_5 Interp5( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[8] );
|
||||
#define PIXEL22_C *((unsigned int*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
const int Ymask = 0x00FF0000;
|
||||
const int Umask = 0x0000FF00;
|
||||
const int Vmask = 0x000000FF;
|
||||
const int trY = 0x00300000;
|
||||
const int trU = 0x00000700;
|
||||
const int trV = 0x00000006;
|
||||
|
||||
void Interp1(unsigned char * pc, unsigned int c1, unsigned int c2);
|
||||
void Interp2(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3);
|
||||
void Interp3(unsigned char * pc, unsigned int c1, unsigned int c2);
|
||||
void Interp4(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3);
|
||||
void Interp5(unsigned char * pc, unsigned int c1, unsigned int c2);
|
||||
bool Diff(unsigned int c1, unsigned int c2);
|
||||
unsigned int RGBtoYUV(unsigned int c);
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#define SIZE_PIXEL 4 // 32bit = 4 bytes
|
||||
|
||||
#define abs32(value) (value & 0x7FFFFFFF)
|
||||
|
||||
#define PIXEL00_1M Interp1( pOut, c[5], c[1] );
|
||||
#define PIXEL00_1U Interp1( pOut, c[5], c[2] );
|
||||
#define PIXEL00_1L Interp1( pOut, c[5], c[4] );
|
||||
#define PIXEL00_2 Interp2( pOut, c[5], c[4], c[2] );
|
||||
#define PIXEL00_4 Interp4( pOut, c[5], c[4], c[2] );
|
||||
#define PIXEL00_5 Interp5( pOut, c[4], c[2] );
|
||||
#define PIXEL00_C *((unsigned int*)(pOut)) = c[5];
|
||||
|
||||
#define PIXEL01_1 Interp1( pOut+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL01_3 Interp3( pOut+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL01_6 Interp1( pOut+SIZE_PIXEL, c[2], c[5] );
|
||||
#define PIXEL01_C *((unsigned int*)(pOut+4)) = c[5];
|
||||
|
||||
#define PIXEL02_1M Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3] );
|
||||
#define PIXEL02_1U Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL02_1R Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL02_2 Interp2( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] );
|
||||
#define PIXEL02_4 Interp4( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] );
|
||||
#define PIXEL02_5 Interp5( pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6] );
|
||||
#define PIXEL02_C *((unsigned int*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL10_1 Interp1( pOut+dstPitch, c[5], c[4] );
|
||||
#define PIXEL10_3 Interp3( pOut+dstPitch, c[5], c[4] );
|
||||
#define PIXEL10_6 Interp1( pOut+dstPitch, c[4], c[5] );
|
||||
#define PIXEL10_C *((unsigned int*)(pOut+dstPitch)) = c[5];
|
||||
|
||||
#define PIXEL11 *((unsigned int*)(pOut+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL12_1 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL12_3 Interp3( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL12_6 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5] );
|
||||
#define PIXEL12_C *((unsigned int*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL20_1M Interp1( pOut+dstPitch+dstPitch, c[5], c[7] );
|
||||
#define PIXEL20_1D Interp1( pOut+dstPitch+dstPitch, c[5], c[8] );
|
||||
#define PIXEL20_1L Interp1( pOut+dstPitch+dstPitch, c[5], c[4] );
|
||||
#define PIXEL20_2 Interp2( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
|
||||
#define PIXEL20_4 Interp4( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
|
||||
#define PIXEL20_5 Interp5( pOut+dstPitch+dstPitch, c[8], c[4] );
|
||||
#define PIXEL20_C *((unsigned int*)(pOut+dstPitch+dstPitch)) = c[5];
|
||||
|
||||
#define PIXEL21_1 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL21_3 Interp3( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL21_6 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5] );
|
||||
#define PIXEL21_C *((unsigned int*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL22_1M Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9] );
|
||||
#define PIXEL22_1D Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL22_1R Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL22_2 Interp2( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] );
|
||||
#define PIXEL22_4 Interp4( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] );
|
||||
#define PIXEL22_5 Interp5( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[8] );
|
||||
#define PIXEL22_C *((unsigned int*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
const int Ymask = 0x00FF0000;
|
||||
const int Umask = 0x0000FF00;
|
||||
const int Vmask = 0x000000FF;
|
||||
const int trY = 0x00300000;
|
||||
const int trU = 0x00000700;
|
||||
const int trV = 0x00000006;
|
||||
|
||||
void Interp1(unsigned char * pc, unsigned int c1, unsigned int c2);
|
||||
void Interp2(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3);
|
||||
void Interp3(unsigned char * pc, unsigned int c1, unsigned int c2);
|
||||
void Interp4(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3);
|
||||
void Interp5(unsigned char * pc, unsigned int c1, unsigned int c2);
|
||||
bool Diff(unsigned int c1, unsigned int c2);
|
||||
unsigned int RGBtoYUV(unsigned int c);
|
||||
|
|
|
@ -65,9 +65,9 @@ static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
u16 *src1 = (u16 *)frm1;
|
||||
u16 *src2 = (u16 *)frm2;
|
||||
u16 *src3 = (u16 *)frm3;
|
||||
|
||||
|
||||
int count = width >> 2;
|
||||
|
||||
|
||||
for(int i = 0; i < height; i++) {
|
||||
#ifdef __GNUC__
|
||||
asm volatile (
|
||||
|
@ -97,15 +97,15 @@ static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
"paddw %%mm2, %%mm1\n" // E+F
|
||||
"pand %%mm4, %%mm1\n" // (E+F) & res
|
||||
"pandn %%mm0, %%mm4\n" // color& !res
|
||||
|
||||
|
||||
"por %%mm1, %%mm4\n"
|
||||
"movq %%mm4, 0(%0)\n" // src0 = res
|
||||
|
||||
|
||||
"addl $8, %0\n"
|
||||
"addl $8, %1\n"
|
||||
"addl $8, %2\n"
|
||||
"addl $8, %3\n"
|
||||
|
||||
|
||||
"decl %4\n"
|
||||
"jnz 0b\n"
|
||||
"pop %4\n"
|
||||
|
@ -126,7 +126,7 @@ static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
movq mm1, qword ptr [ebx]; // src1
|
||||
movq mm2, qword ptr [ecx]; // src2
|
||||
movq mm3, qword ptr [edx]; // src3
|
||||
movq qword ptr [edx], mm0; // src3 = src0
|
||||
movq qword ptr [edx], mm0; // src3 = src0
|
||||
movq mm4, mm0;
|
||||
movq mm5, mm1;
|
||||
pcmpeqw mm5, mm2; // src1 == src2 (A)
|
||||
|
@ -145,10 +145,10 @@ static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
paddw mm1, mm2; // E+F
|
||||
pand mm1, mm4; // (E+F) & res
|
||||
pandn mm4, mm0; // color & !res
|
||||
|
||||
|
||||
por mm4, mm1;
|
||||
movq qword ptr [eax], mm4; // src0 = res
|
||||
|
||||
|
||||
add eax, 8;
|
||||
add ebx, 8;
|
||||
add ecx, 8;
|
||||
|
@ -168,12 +168,12 @@ static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
src2+=2;
|
||||
src3+=2;
|
||||
}
|
||||
|
||||
|
||||
/* Swap buffers around */
|
||||
u8 *temp = frm1;
|
||||
frm1 = frm3;
|
||||
frm3 = frm2;
|
||||
frm2 = temp;
|
||||
frm2 = temp;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -190,7 +190,7 @@ void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
#endif
|
||||
|
||||
u16 colorMask = ~RGB_LOW_BITS_MASK;
|
||||
|
||||
|
||||
u16 *src0 = (u16 *)srcPtr;
|
||||
u16 *src1 = (u16 *)frm1;
|
||||
u16 *src2 = (u16 *)frm2;
|
||||
|
@ -211,7 +211,7 @@ void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
src3[pos] = color; /* oldest buffer now holds newest frame */
|
||||
pos++;
|
||||
}
|
||||
|
||||
|
||||
/* Swap buffers around */
|
||||
u8 *temp = frm1;
|
||||
frm1 = frm3;
|
||||
|
@ -228,9 +228,9 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
u32 *src3 = (u32 *)frm3;
|
||||
|
||||
int count = width >> 1;
|
||||
|
||||
|
||||
for(int i = 0; i < height; i++) {
|
||||
#ifdef __GNUC__
|
||||
#ifdef __GNUC__
|
||||
asm volatile (
|
||||
"push %4\n"
|
||||
"movq 0(%5), %%mm7\n" // colorMask
|
||||
|
@ -258,15 +258,15 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
"paddd %%mm2, %%mm1\n" // E+F
|
||||
"pand %%mm4, %%mm1\n" // (E+F) & res
|
||||
"pandn %%mm0, %%mm4\n" // color& !res
|
||||
|
||||
|
||||
"por %%mm1, %%mm4\n"
|
||||
"movq %%mm4, 0(%0)\n" // src0 = res
|
||||
|
||||
|
||||
"addl $8, %0\n"
|
||||
"addl $8, %1\n"
|
||||
"addl $8, %2\n"
|
||||
"addl $8, %3\n"
|
||||
|
||||
|
||||
"decl %4\n"
|
||||
"jnz 0b\n"
|
||||
"pop %4\n"
|
||||
|
@ -287,7 +287,7 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
movq mm1, qword ptr [ebx]; // src1
|
||||
movq mm2, qword ptr [ecx]; // src2
|
||||
movq mm3, qword ptr [edx]; // src3
|
||||
movq qword ptr [edx], mm0; // src3 = src0
|
||||
movq qword ptr [edx], mm0; // src3 = src0
|
||||
movq mm4, mm0;
|
||||
movq mm5, mm1;
|
||||
pcmpeqd mm5, mm2; // src1 == src2 (A)
|
||||
|
@ -306,10 +306,10 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
paddd mm1, mm2; // E+F
|
||||
pand mm1, mm4; // (E+F) & res
|
||||
pandn mm4, mm0; // color & !res
|
||||
|
||||
|
||||
por mm4, mm1;
|
||||
movq qword ptr [eax], mm4; // src0 = res
|
||||
|
||||
|
||||
add eax, 8;
|
||||
add ebx, 8;
|
||||
add ecx, 8;
|
||||
|
@ -324,7 +324,7 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
emms;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
src0++;
|
||||
src1++;
|
||||
src2++;
|
||||
|
@ -334,7 +334,7 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
u8 *temp = frm1;
|
||||
frm1 = frm3;
|
||||
frm3 = frm2;
|
||||
frm2 = temp;
|
||||
frm2 = temp;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -349,7 +349,7 @@ void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 *src0 = (u32 *)srcPtr;
|
||||
u32 *src1 = (u32 *)frm1;
|
||||
u32 *src2 = (u32 *)frm2;
|
||||
|
@ -372,7 +372,7 @@ void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
src3[pos] = color; /* oldest buffer now holds newest frame */
|
||||
pos++;
|
||||
}
|
||||
|
||||
|
||||
/* Swap buffers around */
|
||||
u8 *temp = frm1;
|
||||
frm1 = frm3;
|
||||
|
@ -387,9 +387,9 @@ static void MotionBlurIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
u16 *src1 = (u16 *)frm1;
|
||||
|
||||
int count = width >> 2;
|
||||
|
||||
|
||||
for(int i = 0; i < height; i++) {
|
||||
#ifdef __GNUC__
|
||||
#ifdef __GNUC__
|
||||
asm volatile (
|
||||
"push %2\n"
|
||||
"movq 0(%3), %%mm7\n" // colorMask
|
||||
|
@ -404,10 +404,10 @@ static void MotionBlurIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
"paddw %%mm1, %%mm0\n" // E+F
|
||||
|
||||
"movq %%mm0, 0(%0)\n" // src0 = res
|
||||
|
||||
|
||||
"addl $8, %0\n"
|
||||
"addl $8, %1\n"
|
||||
|
||||
|
||||
"decl %2\n"
|
||||
"jnz 0b\n"
|
||||
"pop %2\n"
|
||||
|
@ -432,7 +432,7 @@ static void MotionBlurIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
paddw mm0, mm1; // E+F
|
||||
|
||||
movq qword ptr [eax], mm0; // src0 = res
|
||||
|
||||
|
||||
add eax, 8;
|
||||
add ebx, 8;
|
||||
|
||||
|
@ -461,9 +461,9 @@ void MotionBlurIB(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u16 colorMask = ~RGB_LOW_BITS_MASK;
|
||||
|
||||
|
||||
u16 *src0 = (u16 *)srcPtr;
|
||||
u16 *src1 = (u16 *)frm1;
|
||||
|
||||
|
@ -486,10 +486,10 @@ static void MotionBlurIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
u32 *src0 = (u32 *)srcPtr;
|
||||
u32 *src1 = (u32 *)frm1;
|
||||
|
||||
int count = width >> 1;
|
||||
int count = width >> 1;
|
||||
|
||||
for(int i = 0; i < height; i++) {
|
||||
#ifdef __GNUC__
|
||||
#ifdef __GNUC__
|
||||
asm volatile (
|
||||
"push %2\n"
|
||||
"movq 0(%3), %%mm7\n" // colorMask
|
||||
|
@ -504,10 +504,10 @@ static void MotionBlurIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
"paddd %%mm1, %%mm0\n" // E+F
|
||||
|
||||
"movq %%mm0, 0(%0)\n" // src0 = res
|
||||
|
||||
|
||||
"addl $8, %0\n"
|
||||
"addl $8, %1\n"
|
||||
|
||||
|
||||
"decl %2\n"
|
||||
"jnz 0b\n"
|
||||
"pop %2\n"
|
||||
|
@ -532,7 +532,7 @@ static void MotionBlurIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
paddd mm0, mm1; // E+F
|
||||
|
||||
movq qword ptr [eax], mm0; // src0 = res
|
||||
|
||||
|
||||
add eax, 8;
|
||||
add ebx, 8;
|
||||
|
||||
|
@ -561,7 +561,7 @@ void MotionBlurIB32(u8 *srcPtr, u32 srcPitch, int width, int height)
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
u32 *src0 = (u32 *)srcPtr;
|
||||
u32 *src1 = (u32 *)frm1;
|
||||
|
||||
|
|
|
@ -93,11 +93,11 @@ void lrsLpFilter(double c[], int N, double frq, double Beta, int Num)
|
|||
c[i] = sin(2.0*temp*frq)/temp; /* Analog sinc function, cutoff = frq */
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Calculate and Apply Kaiser window to ideal lowpass filter.
|
||||
* Note: last window value is IBeta which is NOT zero.
|
||||
* You're supposed to really truncate the window here, not ramp
|
||||
* it to zero. This helps reduce the first sidelobe.
|
||||
* it to zero. This helps reduce the first sidelobe.
|
||||
*/
|
||||
IBeta = 1.0/Izero(Beta);
|
||||
inm1 = 1.0/((double)(N-1));
|
||||
|
@ -125,7 +125,7 @@ float lrsFilterUp(float Imp[], /* impulse response */
|
|||
float v, t;
|
||||
|
||||
Ph *= Npc; /* Npc is number of values per 1/delta in impulse response */
|
||||
|
||||
|
||||
v = 0.0; /* The output value */
|
||||
Hp = &Imp[(int)Ph];
|
||||
End = &Imp[Nwing];
|
||||
|
@ -153,8 +153,8 @@ float lrsFilterUp(float Imp[], /* impulse response */
|
|||
v += t; /* The filter output */
|
||||
Hp += Npc; /* Filter coeff step */
|
||||
Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
while (Hp < End) {
|
||||
t = *Hp; /* Get filter coeff */
|
||||
t *= *Xp; /* Mult coeff by input sample */
|
||||
|
@ -162,7 +162,7 @@ float lrsFilterUp(float Imp[], /* impulse response */
|
|||
Hp += Npc; /* Filter coeff step */
|
||||
Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */
|
||||
}
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ float lrsFilterUD(float Imp[], /* impulse response */
|
|||
float *Hp, *Hdp, *End;
|
||||
float v, t;
|
||||
double Ho;
|
||||
|
||||
|
||||
v = 0.0; /* The output value */
|
||||
Ho = Ph*dhb;
|
||||
End = &Imp[Nwing];
|
||||
|
@ -202,7 +202,7 @@ float lrsFilterUD(float Imp[], /* impulse response */
|
|||
Ho += dhb; /* IR step */
|
||||
Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */
|
||||
}
|
||||
else
|
||||
else
|
||||
while ((Hp = &Imp[(int)Ho]) < End) {
|
||||
t = *Hp; /* Get IR sample */
|
||||
t *= *Xp; /* Mult coeff by input sample */
|
||||
|
|
|
@ -73,7 +73,7 @@ void *resample_dup(const void * handle)
|
|||
memcpy(hp->Y, cpy->Y, hp->YSize * sizeof(float));
|
||||
hp->Yp = cpy->Yp;
|
||||
hp->Time = cpy->Time;
|
||||
|
||||
|
||||
return (void *)hp;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ void *resample_open(int highQuality, double minFactor, double maxFactor)
|
|||
|
||||
hp->minFactor = minFactor;
|
||||
hp->maxFactor = maxFactor;
|
||||
|
||||
|
||||
if (highQuality)
|
||||
hp->Nmult = 35;
|
||||
else
|
||||
|
@ -145,7 +145,7 @@ void *resample_open(int highQuality, double minFactor, double maxFactor)
|
|||
hp->X = (float *)malloc((hp->XSize + hp->Xoff) * sizeof(float));
|
||||
hp->Xp = hp->Xoff;
|
||||
hp->Xread = hp->Xoff;
|
||||
|
||||
|
||||
/* Need Xoff zeros at begining of X buffer */
|
||||
for(i=0; i<hp->Xoff; i++)
|
||||
hp->X[i]=0;
|
||||
|
@ -157,7 +157,7 @@ void *resample_open(int highQuality, double minFactor, double maxFactor)
|
|||
hp->Yp = 0;
|
||||
|
||||
hp->Time = (double)hp->Xoff; /* Current-time pointer for converter */
|
||||
|
||||
|
||||
return (void *)hp;
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ int resample_process(void *handle,
|
|||
#ifdef DEBUG
|
||||
printf("Nout: %d\n", Nout);
|
||||
#endif
|
||||
|
||||
|
||||
hp->Time -= Nx; /* Move converter Nx samples back in time */
|
||||
hp->Xp += Nx; /* Advance by number of samples processed */
|
||||
|
||||
|
@ -303,7 +303,7 @@ int resample_process(void *handle,
|
|||
|
||||
hp->Xread = Nreuse; /* Pos in input buff to read new data into */
|
||||
hp->Xp = hp->Xoff;
|
||||
|
||||
|
||||
/* Check to see if output buff overflowed (shouldn't happen!) */
|
||||
if (Nout > hp->YSize) {
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -40,13 +40,13 @@ int lrsSrcUp(float X[],
|
|||
{
|
||||
float *Xp, *Ystart;
|
||||
float v;
|
||||
|
||||
|
||||
double CurrentTime = *TimePtr;
|
||||
double dt; /* Step through input signal */
|
||||
double dt; /* Step through input signal */
|
||||
double endTime; /* When Time reaches EndTime, return to user */
|
||||
|
||||
|
||||
dt = 1.0/factor; /* Output sampling period */
|
||||
|
||||
|
||||
Ystart = Y;
|
||||
endTime = CurrentTime + Nx;
|
||||
while (CurrentTime < endTime)
|
||||
|
@ -59,7 +59,7 @@ int lrsSrcUp(float X[],
|
|||
v = lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp,
|
||||
LeftPhase, -1);
|
||||
/* Perform right-wing inner product */
|
||||
v += lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp+1,
|
||||
v += lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp+1,
|
||||
RightPhase, 1);
|
||||
|
||||
v *= LpScl; /* Normalize for unity filter gain */
|
||||
|
@ -92,11 +92,11 @@ int lrsSrcUD(float X[],
|
|||
double dh; /* Step through filter impulse response */
|
||||
double dt; /* Step through input signal */
|
||||
double endTime; /* When Time reaches EndTime, return to user */
|
||||
|
||||
|
||||
dt = 1.0/factor; /* Output sampling period */
|
||||
|
||||
|
||||
dh = MIN(Npc, factor*Npc); /* Filter sampling period */
|
||||
|
||||
|
||||
Ystart = Y;
|
||||
endTime = CurrentTime + Nx;
|
||||
while (CurrentTime < endTime)
|
||||
|
@ -109,12 +109,12 @@ int lrsSrcUD(float X[],
|
|||
v = lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp,
|
||||
LeftPhase, -1, dh);
|
||||
/* Perform right-wing inner product */
|
||||
v += lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp+1,
|
||||
v += lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp+1,
|
||||
RightPhase, 1, dh);
|
||||
|
||||
v *= LpScl; /* Normalize for unity filter gain */
|
||||
*Y++ = v; /* Deposit output */
|
||||
|
||||
|
||||
CurrentTime += dt; /* Move to next sample by time increment */
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ int main(int argc, char **argv)
|
|||
dstinfo.format = formatinfo.format |
|
||||
(srcinfo.format & SF_FORMAT_SUBMASK);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void runtest(int srclen, double freq, double factor,
|
|||
printf(" Expected ~%d, got %d samples out\n",
|
||||
expectedlen, out);
|
||||
}
|
||||
|
||||
|
||||
sum = 0.0;
|
||||
sumsq = 0.0;
|
||||
errcount = 0.0;
|
||||
|
|
512
src/lq2x.h
512
src/lq2x.h
|
@ -1,141 +1,141 @@
|
|||
case 0 :
|
||||
case 2 :
|
||||
case 4 :
|
||||
case 6 :
|
||||
case 8 :
|
||||
case 12 :
|
||||
case 16 :
|
||||
case 20 :
|
||||
case 24 :
|
||||
case 28 :
|
||||
case 32 :
|
||||
case 34 :
|
||||
case 36 :
|
||||
case 38 :
|
||||
case 40 :
|
||||
case 44 :
|
||||
case 48 :
|
||||
case 52 :
|
||||
case 56 :
|
||||
case 60 :
|
||||
case 64 :
|
||||
case 66 :
|
||||
case 68 :
|
||||
case 70 :
|
||||
case 96 :
|
||||
case 98 :
|
||||
case 100 :
|
||||
case 102 :
|
||||
case 128 :
|
||||
case 130 :
|
||||
case 132 :
|
||||
case 134 :
|
||||
case 136 :
|
||||
case 140 :
|
||||
case 144 :
|
||||
case 148 :
|
||||
case 152 :
|
||||
case 156 :
|
||||
case 160 :
|
||||
case 162 :
|
||||
case 164 :
|
||||
case 166 :
|
||||
case 168 :
|
||||
case 172 :
|
||||
case 176 :
|
||||
case 180 :
|
||||
case 184 :
|
||||
case 188 :
|
||||
case 192 :
|
||||
case 194 :
|
||||
case 196 :
|
||||
case 198 :
|
||||
case 224 :
|
||||
case 226 :
|
||||
case 228 :
|
||||
case 230 :
|
||||
case 0 :
|
||||
case 2 :
|
||||
case 4 :
|
||||
case 6 :
|
||||
case 8 :
|
||||
case 12 :
|
||||
case 16 :
|
||||
case 20 :
|
||||
case 24 :
|
||||
case 28 :
|
||||
case 32 :
|
||||
case 34 :
|
||||
case 36 :
|
||||
case 38 :
|
||||
case 40 :
|
||||
case 44 :
|
||||
case 48 :
|
||||
case 52 :
|
||||
case 56 :
|
||||
case 60 :
|
||||
case 64 :
|
||||
case 66 :
|
||||
case 68 :
|
||||
case 70 :
|
||||
case 96 :
|
||||
case 98 :
|
||||
case 100 :
|
||||
case 102 :
|
||||
case 128 :
|
||||
case 130 :
|
||||
case 132 :
|
||||
case 134 :
|
||||
case 136 :
|
||||
case 140 :
|
||||
case 144 :
|
||||
case 148 :
|
||||
case 152 :
|
||||
case 156 :
|
||||
case 160 :
|
||||
case 162 :
|
||||
case 164 :
|
||||
case 166 :
|
||||
case 168 :
|
||||
case 172 :
|
||||
case 176 :
|
||||
case 180 :
|
||||
case 184 :
|
||||
case 188 :
|
||||
case 192 :
|
||||
case 194 :
|
||||
case 196 :
|
||||
case 198 :
|
||||
case 224 :
|
||||
case 226 :
|
||||
case 228 :
|
||||
case 230 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
P2 = IC(0);
|
||||
P3 = IC(0);
|
||||
} break;
|
||||
case 1 :
|
||||
case 5 :
|
||||
case 9 :
|
||||
case 13 :
|
||||
case 17 :
|
||||
case 21 :
|
||||
case 25 :
|
||||
case 29 :
|
||||
case 33 :
|
||||
case 37 :
|
||||
case 41 :
|
||||
case 45 :
|
||||
case 49 :
|
||||
case 53 :
|
||||
case 57 :
|
||||
case 61 :
|
||||
case 65 :
|
||||
case 69 :
|
||||
case 97 :
|
||||
case 101 :
|
||||
case 129 :
|
||||
case 133 :
|
||||
case 137 :
|
||||
case 141 :
|
||||
case 145 :
|
||||
case 149 :
|
||||
case 153 :
|
||||
case 157 :
|
||||
case 161 :
|
||||
case 165 :
|
||||
case 169 :
|
||||
case 173 :
|
||||
case 177 :
|
||||
case 181 :
|
||||
case 185 :
|
||||
case 189 :
|
||||
case 193 :
|
||||
case 197 :
|
||||
case 225 :
|
||||
case 229 :
|
||||
case 1 :
|
||||
case 5 :
|
||||
case 9 :
|
||||
case 13 :
|
||||
case 17 :
|
||||
case 21 :
|
||||
case 25 :
|
||||
case 29 :
|
||||
case 33 :
|
||||
case 37 :
|
||||
case 41 :
|
||||
case 45 :
|
||||
case 49 :
|
||||
case 53 :
|
||||
case 57 :
|
||||
case 61 :
|
||||
case 65 :
|
||||
case 69 :
|
||||
case 97 :
|
||||
case 101 :
|
||||
case 129 :
|
||||
case 133 :
|
||||
case 137 :
|
||||
case 141 :
|
||||
case 145 :
|
||||
case 149 :
|
||||
case 153 :
|
||||
case 157 :
|
||||
case 161 :
|
||||
case 165 :
|
||||
case 169 :
|
||||
case 173 :
|
||||
case 177 :
|
||||
case 181 :
|
||||
case 185 :
|
||||
case 189 :
|
||||
case 193 :
|
||||
case 197 :
|
||||
case 225 :
|
||||
case 229 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
P2 = IC(1);
|
||||
P3 = IC(1);
|
||||
} break;
|
||||
case 3 :
|
||||
case 35 :
|
||||
case 67 :
|
||||
case 99 :
|
||||
case 131 :
|
||||
case 163 :
|
||||
case 195 :
|
||||
case 227 :
|
||||
case 3 :
|
||||
case 35 :
|
||||
case 67 :
|
||||
case 99 :
|
||||
case 131 :
|
||||
case 163 :
|
||||
case 195 :
|
||||
case 227 :
|
||||
{
|
||||
P0 = IC(2);
|
||||
P1 = IC(2);
|
||||
P2 = IC(2);
|
||||
P3 = IC(2);
|
||||
} break;
|
||||
case 7 :
|
||||
case 39 :
|
||||
case 71 :
|
||||
case 103 :
|
||||
case 135 :
|
||||
case 167 :
|
||||
case 199 :
|
||||
case 231 :
|
||||
case 7 :
|
||||
case 39 :
|
||||
case 71 :
|
||||
case 103 :
|
||||
case 135 :
|
||||
case 167 :
|
||||
case 199 :
|
||||
case 231 :
|
||||
{
|
||||
P0 = IC(3);
|
||||
P1 = IC(3);
|
||||
P2 = IC(3);
|
||||
P3 = IC(3);
|
||||
} break;
|
||||
case 10 :
|
||||
case 138 :
|
||||
case 10 :
|
||||
case 138 :
|
||||
{
|
||||
P1 = IC(0);
|
||||
P2 = IC(0);
|
||||
|
@ -146,12 +146,12 @@ case 138 :
|
|||
P0 = I211(0, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 11 :
|
||||
case 27 :
|
||||
case 75 :
|
||||
case 139 :
|
||||
case 155 :
|
||||
case 203 :
|
||||
case 11 :
|
||||
case 27 :
|
||||
case 75 :
|
||||
case 139 :
|
||||
case 155 :
|
||||
case 203 :
|
||||
{
|
||||
P1 = IC(2);
|
||||
P2 = IC(2);
|
||||
|
@ -162,8 +162,8 @@ case 203 :
|
|||
P0 = I211(2, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 14 :
|
||||
case 142 :
|
||||
case 14 :
|
||||
case 142 :
|
||||
{
|
||||
P2 = IC(0);
|
||||
P3 = IC(0);
|
||||
|
@ -175,9 +175,9 @@ case 142 :
|
|||
P1 = I31(0, 1);
|
||||
}
|
||||
} break;
|
||||
case 15 :
|
||||
case 143 :
|
||||
case 207 :
|
||||
case 15 :
|
||||
case 143 :
|
||||
case 207 :
|
||||
{
|
||||
P2 = IC(4);
|
||||
P3 = IC(4);
|
||||
|
@ -189,14 +189,14 @@ case 207 :
|
|||
P1 = I31(4, 1);
|
||||
}
|
||||
} break;
|
||||
case 18 :
|
||||
case 22 :
|
||||
case 30 :
|
||||
case 50 :
|
||||
case 54 :
|
||||
case 62 :
|
||||
case 86 :
|
||||
case 118 :
|
||||
case 18 :
|
||||
case 22 :
|
||||
case 30 :
|
||||
case 50 :
|
||||
case 54 :
|
||||
case 62 :
|
||||
case 86 :
|
||||
case 118 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P2 = IC(0);
|
||||
|
@ -207,8 +207,8 @@ case 118 :
|
|||
P1 = I211(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 19 :
|
||||
case 51 :
|
||||
case 19 :
|
||||
case 51 :
|
||||
{
|
||||
P2 = IC(2);
|
||||
P3 = IC(2);
|
||||
|
@ -220,9 +220,9 @@ case 51 :
|
|||
P1 = I332(1, 5, 2);
|
||||
}
|
||||
} break;
|
||||
case 23 :
|
||||
case 55 :
|
||||
case 119 :
|
||||
case 23 :
|
||||
case 55 :
|
||||
case 119 :
|
||||
{
|
||||
P2 = IC(3);
|
||||
P3 = IC(3);
|
||||
|
@ -234,7 +234,7 @@ case 119 :
|
|||
P1 = I332(1, 5, 3);
|
||||
}
|
||||
} break;
|
||||
case 26 :
|
||||
case 26 :
|
||||
{
|
||||
P2 = IC(0);
|
||||
P3 = IC(0);
|
||||
|
@ -249,8 +249,8 @@ case 26 :
|
|||
P1 = I211(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 31 :
|
||||
case 95 :
|
||||
case 31 :
|
||||
case 95 :
|
||||
{
|
||||
P2 = IC(4);
|
||||
P3 = IC(4);
|
||||
|
@ -265,8 +265,8 @@ case 95 :
|
|||
P1 = I211(4, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 42 :
|
||||
case 170 :
|
||||
case 42 :
|
||||
case 170 :
|
||||
{
|
||||
P1 = IC(0);
|
||||
P3 = IC(0);
|
||||
|
@ -278,9 +278,9 @@ case 170 :
|
|||
P2 = I31(0, 3);
|
||||
}
|
||||
} break;
|
||||
case 43 :
|
||||
case 171 :
|
||||
case 187 :
|
||||
case 43 :
|
||||
case 171 :
|
||||
case 187 :
|
||||
{
|
||||
P1 = IC(2);
|
||||
P3 = IC(2);
|
||||
|
@ -292,8 +292,8 @@ case 187 :
|
|||
P2 = I31(2, 3);
|
||||
}
|
||||
} break;
|
||||
case 46 :
|
||||
case 174 :
|
||||
case 46 :
|
||||
case 174 :
|
||||
{
|
||||
P1 = IC(0);
|
||||
P2 = IC(0);
|
||||
|
@ -304,8 +304,8 @@ case 174 :
|
|||
P0 = I611(0, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 47 :
|
||||
case 175 :
|
||||
case 47 :
|
||||
case 175 :
|
||||
{
|
||||
P1 = IC(4);
|
||||
P2 = IC(4);
|
||||
|
@ -316,9 +316,9 @@ case 175 :
|
|||
P0 = I1411(4, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 58 :
|
||||
case 154 :
|
||||
case 186 :
|
||||
case 58 :
|
||||
case 154 :
|
||||
case 186 :
|
||||
{
|
||||
P2 = IC(0);
|
||||
P3 = IC(0);
|
||||
|
@ -333,7 +333,7 @@ case 186 :
|
|||
P1 = I611(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 59 :
|
||||
case 59 :
|
||||
{
|
||||
P2 = IC(2);
|
||||
P3 = IC(2);
|
||||
|
@ -348,7 +348,7 @@ case 59 :
|
|||
P1 = I611(2, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 63 :
|
||||
case 63 :
|
||||
{
|
||||
P2 = IC(4);
|
||||
P3 = IC(4);
|
||||
|
@ -363,14 +363,14 @@ case 63 :
|
|||
P1 = I211(4, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 72 :
|
||||
case 76 :
|
||||
case 104 :
|
||||
case 106 :
|
||||
case 108 :
|
||||
case 110 :
|
||||
case 120 :
|
||||
case 124 :
|
||||
case 72 :
|
||||
case 76 :
|
||||
case 104 :
|
||||
case 106 :
|
||||
case 108 :
|
||||
case 110 :
|
||||
case 120 :
|
||||
case 124 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
|
@ -381,11 +381,11 @@ case 124 :
|
|||
P2 = I211(0, 3, 7);
|
||||
}
|
||||
} break;
|
||||
case 73 :
|
||||
case 77 :
|
||||
case 105 :
|
||||
case 109 :
|
||||
case 125 :
|
||||
case 73 :
|
||||
case 77 :
|
||||
case 105 :
|
||||
case 109 :
|
||||
case 125 :
|
||||
{
|
||||
P1 = IC(1);
|
||||
P3 = IC(1);
|
||||
|
@ -397,7 +397,7 @@ case 125 :
|
|||
P2 = I332(3, 7, 1);
|
||||
}
|
||||
} break;
|
||||
case 74 :
|
||||
case 74 :
|
||||
{
|
||||
P1 = IC(0);
|
||||
P3 = IC(0);
|
||||
|
@ -412,9 +412,9 @@ case 74 :
|
|||
P0 = I211(0, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 78 :
|
||||
case 202 :
|
||||
case 206 :
|
||||
case 78 :
|
||||
case 202 :
|
||||
case 206 :
|
||||
{
|
||||
P1 = IC(0);
|
||||
P3 = IC(0);
|
||||
|
@ -429,7 +429,7 @@ case 206 :
|
|||
P0 = I611(0, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 79 :
|
||||
case 79 :
|
||||
{
|
||||
P1 = IC(4);
|
||||
P3 = IC(4);
|
||||
|
@ -444,10 +444,10 @@ case 79 :
|
|||
P0 = I211(4, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 80 :
|
||||
case 208 :
|
||||
case 210 :
|
||||
case 216 :
|
||||
case 80 :
|
||||
case 208 :
|
||||
case 210 :
|
||||
case 216 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
|
@ -458,9 +458,9 @@ case 216 :
|
|||
P3 = I211(0, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 81 :
|
||||
case 209 :
|
||||
case 217 :
|
||||
case 81 :
|
||||
case 209 :
|
||||
case 217 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
|
@ -471,9 +471,9 @@ case 217 :
|
|||
P3 = I211(1, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 82 :
|
||||
case 214 :
|
||||
case 222 :
|
||||
case 82 :
|
||||
case 214 :
|
||||
case 222 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P2 = IC(0);
|
||||
|
@ -488,8 +488,8 @@ case 222 :
|
|||
P1 = I211(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 83 :
|
||||
case 115 :
|
||||
case 83 :
|
||||
case 115 :
|
||||
{
|
||||
P0 = IC(2);
|
||||
P2 = IC(2);
|
||||
|
@ -504,8 +504,8 @@ case 115 :
|
|||
P1 = I611(2, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 84 :
|
||||
case 212 :
|
||||
case 84 :
|
||||
case 212 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P2 = IC(0);
|
||||
|
@ -517,9 +517,9 @@ case 212 :
|
|||
P3 = I332(5, 7, 0);
|
||||
}
|
||||
} break;
|
||||
case 85 :
|
||||
case 213 :
|
||||
case 221 :
|
||||
case 85 :
|
||||
case 213 :
|
||||
case 221 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P2 = IC(1);
|
||||
|
@ -531,7 +531,7 @@ case 221 :
|
|||
P3 = I332(5, 7, 1);
|
||||
}
|
||||
} break;
|
||||
case 87 :
|
||||
case 87 :
|
||||
{
|
||||
P0 = IC(3);
|
||||
P2 = IC(3);
|
||||
|
@ -546,9 +546,9 @@ case 87 :
|
|||
P1 = I211(3, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 88 :
|
||||
case 248 :
|
||||
case 250 :
|
||||
case 88 :
|
||||
case 248 :
|
||||
case 250 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
|
@ -563,8 +563,8 @@ case 250 :
|
|||
P3 = I211(0, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 89 :
|
||||
case 93 :
|
||||
case 89 :
|
||||
case 93 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
|
@ -579,7 +579,7 @@ case 93 :
|
|||
P3 = I611(1, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 90 :
|
||||
case 90 :
|
||||
{
|
||||
if (MDL) {
|
||||
P2 = IC(0);
|
||||
|
@ -602,7 +602,7 @@ case 90 :
|
|||
P1 = I611(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 91 :
|
||||
case 91 :
|
||||
{
|
||||
if (MDL) {
|
||||
P2 = IC(2);
|
||||
|
@ -625,7 +625,7 @@ case 91 :
|
|||
P1 = I611(2, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 92 :
|
||||
case 92 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
|
@ -640,7 +640,7 @@ case 92 :
|
|||
P3 = I611(0, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 94 :
|
||||
case 94 :
|
||||
{
|
||||
if (MDL) {
|
||||
P2 = IC(0);
|
||||
|
@ -663,8 +663,8 @@ case 94 :
|
|||
P1 = I211(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 107 :
|
||||
case 123 :
|
||||
case 107 :
|
||||
case 123 :
|
||||
{
|
||||
P1 = IC(2);
|
||||
P3 = IC(2);
|
||||
|
@ -679,7 +679,7 @@ case 123 :
|
|||
P0 = I211(2, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 111 :
|
||||
case 111 :
|
||||
{
|
||||
P1 = IC(4);
|
||||
P3 = IC(4);
|
||||
|
@ -694,8 +694,8 @@ case 111 :
|
|||
P0 = I1411(4, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 112 :
|
||||
case 240 :
|
||||
case 112 :
|
||||
case 240 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
|
@ -707,8 +707,8 @@ case 240 :
|
|||
P3 = I332(5, 7, 0);
|
||||
}
|
||||
} break;
|
||||
case 113 :
|
||||
case 241 :
|
||||
case 113 :
|
||||
case 241 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
|
@ -720,7 +720,7 @@ case 241 :
|
|||
P3 = I332(5, 7, 1);
|
||||
}
|
||||
} break;
|
||||
case 114 :
|
||||
case 114 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P2 = IC(0);
|
||||
|
@ -735,7 +735,7 @@ case 114 :
|
|||
P1 = I611(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 116 :
|
||||
case 116 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
|
@ -746,7 +746,7 @@ case 116 :
|
|||
P3 = I611(0, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 117 :
|
||||
case 117 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
|
@ -757,7 +757,7 @@ case 117 :
|
|||
P3 = I611(1, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 121 :
|
||||
case 121 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
|
@ -772,7 +772,7 @@ case 121 :
|
|||
P3 = I611(1, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 122 :
|
||||
case 122 :
|
||||
{
|
||||
if (MDL) {
|
||||
P2 = IC(0);
|
||||
|
@ -795,7 +795,7 @@ case 122 :
|
|||
P1 = I611(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 126 :
|
||||
case 126 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P3 = IC(0);
|
||||
|
@ -810,7 +810,7 @@ case 126 :
|
|||
P1 = I211(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 127 :
|
||||
case 127 :
|
||||
{
|
||||
P3 = IC(4);
|
||||
if (MDL) {
|
||||
|
@ -829,11 +829,11 @@ case 127 :
|
|||
P1 = I211(4, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 146 :
|
||||
case 150 :
|
||||
case 178 :
|
||||
case 182 :
|
||||
case 190 :
|
||||
case 146 :
|
||||
case 150 :
|
||||
case 178 :
|
||||
case 182 :
|
||||
case 190 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P2 = IC(0);
|
||||
|
@ -845,8 +845,8 @@ case 190 :
|
|||
P3 = I31(0, 5);
|
||||
}
|
||||
} break;
|
||||
case 147 :
|
||||
case 179 :
|
||||
case 147 :
|
||||
case 179 :
|
||||
{
|
||||
P0 = IC(2);
|
||||
P2 = IC(2);
|
||||
|
@ -857,8 +857,8 @@ case 179 :
|
|||
P1 = I611(2, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 151 :
|
||||
case 183 :
|
||||
case 151 :
|
||||
case 183 :
|
||||
{
|
||||
P0 = IC(3);
|
||||
P2 = IC(3);
|
||||
|
@ -869,7 +869,7 @@ case 183 :
|
|||
P1 = I1411(3, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 158 :
|
||||
case 158 :
|
||||
{
|
||||
P2 = IC(0);
|
||||
P3 = IC(0);
|
||||
|
@ -884,7 +884,7 @@ case 158 :
|
|||
P1 = I211(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 159 :
|
||||
case 159 :
|
||||
{
|
||||
P2 = IC(4);
|
||||
P3 = IC(4);
|
||||
|
@ -899,7 +899,7 @@ case 159 :
|
|||
P1 = I1411(4, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 191 :
|
||||
case 191 :
|
||||
{
|
||||
P2 = IC(4);
|
||||
P3 = IC(4);
|
||||
|
@ -914,11 +914,11 @@ case 191 :
|
|||
P1 = I1411(4, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 200 :
|
||||
case 204 :
|
||||
case 232 :
|
||||
case 236 :
|
||||
case 238 :
|
||||
case 200 :
|
||||
case 204 :
|
||||
case 232 :
|
||||
case 236 :
|
||||
case 238 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
|
@ -930,8 +930,8 @@ case 238 :
|
|||
P3 = I31(0, 7);
|
||||
}
|
||||
} break;
|
||||
case 201 :
|
||||
case 205 :
|
||||
case 201 :
|
||||
case 205 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
|
@ -942,7 +942,7 @@ case 205 :
|
|||
P2 = I611(1, 3, 7);
|
||||
}
|
||||
} break;
|
||||
case 211 :
|
||||
case 211 :
|
||||
{
|
||||
P0 = IC(2);
|
||||
P1 = IC(2);
|
||||
|
@ -953,7 +953,7 @@ case 211 :
|
|||
P3 = I211(2, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 215 :
|
||||
case 215 :
|
||||
{
|
||||
P0 = IC(3);
|
||||
P2 = IC(3);
|
||||
|
@ -968,7 +968,7 @@ case 215 :
|
|||
P1 = I1411(3, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 218 :
|
||||
case 218 :
|
||||
{
|
||||
if (MDL) {
|
||||
P2 = IC(0);
|
||||
|
@ -991,7 +991,7 @@ case 218 :
|
|||
P1 = I611(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 219 :
|
||||
case 219 :
|
||||
{
|
||||
P1 = IC(2);
|
||||
P2 = IC(2);
|
||||
|
@ -1006,7 +1006,7 @@ case 219 :
|
|||
P0 = I211(2, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 220 :
|
||||
case 220 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
|
@ -1021,7 +1021,7 @@ case 220 :
|
|||
P3 = I211(0, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 223 :
|
||||
case 223 :
|
||||
{
|
||||
P2 = IC(4);
|
||||
if (MDR) {
|
||||
|
@ -1040,8 +1040,8 @@ case 223 :
|
|||
P1 = I1411(4, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 233 :
|
||||
case 237 :
|
||||
case 233 :
|
||||
case 237 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
|
@ -1052,7 +1052,7 @@ case 237 :
|
|||
P2 = I1411(1, 3, 7);
|
||||
}
|
||||
} break;
|
||||
case 234 :
|
||||
case 234 :
|
||||
{
|
||||
P1 = IC(0);
|
||||
P3 = IC(0);
|
||||
|
@ -1067,7 +1067,7 @@ case 234 :
|
|||
P0 = I611(0, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 235 :
|
||||
case 235 :
|
||||
{
|
||||
P1 = IC(2);
|
||||
P3 = IC(2);
|
||||
|
@ -1082,7 +1082,7 @@ case 235 :
|
|||
P0 = I211(2, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 239 :
|
||||
case 239 :
|
||||
{
|
||||
P1 = IC(4);
|
||||
P3 = IC(4);
|
||||
|
@ -1097,7 +1097,7 @@ case 239 :
|
|||
P0 = I1411(4, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 242 :
|
||||
case 242 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P2 = IC(0);
|
||||
|
@ -1112,7 +1112,7 @@ case 242 :
|
|||
P1 = I611(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 243 :
|
||||
case 243 :
|
||||
{
|
||||
P0 = IC(2);
|
||||
P1 = IC(2);
|
||||
|
@ -1124,7 +1124,7 @@ case 243 :
|
|||
P3 = I332(5, 7, 2);
|
||||
}
|
||||
} break;
|
||||
case 244 :
|
||||
case 244 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
|
@ -1135,7 +1135,7 @@ case 244 :
|
|||
P3 = I1411(0, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 245 :
|
||||
case 245 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
|
@ -1146,7 +1146,7 @@ case 245 :
|
|||
P3 = I1411(1, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 246 :
|
||||
case 246 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P2 = IC(0);
|
||||
|
@ -1161,7 +1161,7 @@ case 246 :
|
|||
P1 = I211(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 247 :
|
||||
case 247 :
|
||||
{
|
||||
P0 = IC(3);
|
||||
P2 = IC(3);
|
||||
|
@ -1176,7 +1176,7 @@ case 247 :
|
|||
P1 = I1411(3, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 249 :
|
||||
case 249 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
|
@ -1191,7 +1191,7 @@ case 249 :
|
|||
P3 = I211(1, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 251 :
|
||||
case 251 :
|
||||
{
|
||||
P1 = IC(2);
|
||||
if (MDL) {
|
||||
|
@ -1210,7 +1210,7 @@ case 251 :
|
|||
P0 = I211(2, 1, 3);
|
||||
}
|
||||
} break;
|
||||
case 252 :
|
||||
case 252 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
P1 = IC(0);
|
||||
|
@ -1225,7 +1225,7 @@ case 252 :
|
|||
P3 = I1411(0, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 253 :
|
||||
case 253 :
|
||||
{
|
||||
P0 = IC(1);
|
||||
P1 = IC(1);
|
||||
|
@ -1240,7 +1240,7 @@ case 253 :
|
|||
P3 = I1411(1, 5, 7);
|
||||
}
|
||||
} break;
|
||||
case 254 :
|
||||
case 254 :
|
||||
{
|
||||
P0 = IC(0);
|
||||
if (MDL) {
|
||||
|
@ -1259,7 +1259,7 @@ case 254 :
|
|||
P1 = I211(0, 1, 5);
|
||||
}
|
||||
} break;
|
||||
case 255 :
|
||||
case 255 :
|
||||
{
|
||||
if (MDL) {
|
||||
P2 = IC(4);
|
||||
|
|
|
@ -118,7 +118,7 @@ local MEMFILE *memOpen(char *memory, int available, char mode)
|
|||
memory[3] = ' ';
|
||||
*((int *)(memory+4)) = 0;
|
||||
} else {
|
||||
if(memory[0] != 'V' || memory[1] != 'B' || memory[2] != 'A' ||
|
||||
if(memory[0] != 'V' || memory[1] != 'B' || memory[2] != 'A' ||
|
||||
memory[3] != ' ') {
|
||||
free(f);
|
||||
return NULL;
|
||||
|
@ -130,11 +130,11 @@ local MEMFILE *memOpen(char *memory, int available, char mode)
|
|||
return f;
|
||||
}
|
||||
|
||||
local size_t memWrite(const void *buffer, size_t size, size_t count,
|
||||
local size_t memWrite(const void *buffer, size_t size, size_t count,
|
||||
MEMFILE *file)
|
||||
{
|
||||
size_t total = size*count;
|
||||
|
||||
|
||||
if(file->mode != 'w') {
|
||||
file->error = 1;
|
||||
return 0;
|
||||
|
@ -149,11 +149,11 @@ local size_t memWrite(const void *buffer, size_t size, size_t count,
|
|||
return total;
|
||||
}
|
||||
|
||||
local size_t memRead(void *buffer, size_t size, size_t count,
|
||||
local size_t memRead(void *buffer, size_t size, size_t count,
|
||||
MEMFILE *file)
|
||||
{
|
||||
size_t total = size*count;
|
||||
|
||||
|
||||
if(file->mode != 'r') {
|
||||
file->error = 1;
|
||||
return 0;
|
||||
|
@ -211,7 +211,7 @@ local int memPrintf(MEMFILE *f, const char *format, ...)
|
|||
char buffer[80];
|
||||
va_list list;
|
||||
int len;
|
||||
|
||||
|
||||
va_start(list, format);
|
||||
len = vsprintf(buffer, format, list);
|
||||
va_end(list);
|
||||
|
@ -272,7 +272,7 @@ local gzFile gz_open (memory, available, mode)
|
|||
}
|
||||
} while (*p++ && m != fmode + sizeof(fmode));
|
||||
if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
|
||||
|
||||
|
||||
if (s->mode == 'w') {
|
||||
#ifdef NO_DEFLATE
|
||||
err = Z_STREAM_ERROR;
|
||||
|
@ -324,7 +324,7 @@ local gzFile gz_open (memory, available, mode)
|
|||
check_header(s); /* skip the .gz header */
|
||||
s->startpos = (memTell(s->file) - s->stream.avail_in);
|
||||
}
|
||||
|
||||
|
||||
return (gzFile)s;
|
||||
}
|
||||
|
||||
|
@ -621,10 +621,10 @@ local int do_flush (file, flush)
|
|||
if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
|
||||
|
||||
/* deflate has finished flushing only when it hasn't used up
|
||||
* all the available space in the output buffer:
|
||||
* all the available space in the output buffer:
|
||||
*/
|
||||
done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
|
||||
|
||||
|
||||
if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
|
||||
}
|
||||
return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
|
||||
|
@ -694,6 +694,6 @@ long ZEXPORT memtell(file)
|
|||
mem_stream *s = (mem_stream*)file;
|
||||
|
||||
if (s == NULL) return Z_STREAM_ERROR;
|
||||
|
||||
|
||||
return memTell(s->file);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Adapted from original gzio.c from zlib library by Forgotten
|
||||
*/
|
||||
|
||||
#if defined(HAVE_ZUTIL_H) || defined(_WIN32)
|
||||
#if defined(HAVE_ZUTIL_H) || defined(_WIN32)
|
||||
# include <zutil.h>
|
||||
#else
|
||||
#include <zlib.h>
|
||||
|
|
|
@ -26,9 +26,9 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
u8 *nextLine, *finish;
|
||||
u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
|
||||
u32 lowPixelMask = RGB_LOW_BITS_MASK;
|
||||
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *xP = (u32 *) deltaPtr;
|
||||
|
@ -38,11 +38,11 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
u32 nextPixel;
|
||||
u32 currentDelta;
|
||||
u32 nextDelta;
|
||||
|
||||
|
||||
finish = (u8 *) bP + ((width+2) << 1);
|
||||
nextPixel = *bP++;
|
||||
nextDelta = *xP++;
|
||||
|
||||
|
||||
do {
|
||||
currentPixel = nextPixel;
|
||||
currentDelta = nextDelta;
|
||||
|
@ -51,7 +51,7 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
|
||||
if(currentPixel != currentDelta) {
|
||||
u32 colorA, product, colorB;
|
||||
|
||||
|
||||
*(xP - 2) = currentPixel;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
colorA = currentPixel >> 16;
|
||||
|
@ -64,7 +64,7 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
product = ((((colorA & colorMask) >> 1) +
|
||||
((colorB & colorMask) >> 1) +
|
||||
(colorA & colorB & lowPixelMask)));
|
||||
|
||||
|
||||
*(dP) = product | product << 16;
|
||||
*(nL) = product | product << 16;
|
||||
|
||||
|
@ -78,21 +78,21 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
product = ((((colorA & colorMask) >> 1) +
|
||||
((colorB & colorMask) >> 1) +
|
||||
(colorA & colorB & lowPixelMask)));
|
||||
|
||||
|
||||
*(dP + 1) = product | product << 16;
|
||||
*(nL + 1) = product | product << 16;
|
||||
} else {
|
||||
u32 colorA, product;
|
||||
|
||||
|
||||
*(xP - 2) = currentPixel;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
colorA = currentPixel >> 16;
|
||||
#else
|
||||
colorA = currentPixel & 0xffff;
|
||||
#endif
|
||||
|
||||
|
||||
product = colorA;
|
||||
|
||||
|
||||
*(dP) = product | product << 16;
|
||||
*(nL) = product | product << 16;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
|
@ -101,15 +101,15 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
colorA = currentPixel >> 16;
|
||||
#endif
|
||||
product = colorA;
|
||||
|
||||
|
||||
*(dP + 1) = product | product << 16;
|
||||
*(nL + 1) = product | product << 16;
|
||||
*(nL + 1) = product | product << 16;
|
||||
}
|
||||
|
||||
|
||||
dP += 2;
|
||||
nL += 2;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
|
||||
deltaPtr += srcPitch;
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
|
@ -124,9 +124,9 @@ void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
u8 *nextLine, *finish;
|
||||
u32 colorMask = ~RGB_LOW_BITS_MASK;
|
||||
u32 lowPixelMask = RGB_LOW_BITS_MASK;
|
||||
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *xP = (u32 *) deltaPtr;
|
||||
|
@ -136,11 +136,11 @@ void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
u32 nextPixel;
|
||||
u32 currentDelta;
|
||||
u32 nextDelta;
|
||||
|
||||
|
||||
finish = (u8 *) bP + ((width+1) << 2);
|
||||
nextPixel = *bP++;
|
||||
nextDelta = *xP++;
|
||||
|
||||
|
||||
do {
|
||||
currentPixel = nextPixel;
|
||||
currentDelta = nextDelta;
|
||||
|
@ -152,11 +152,11 @@ void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
*(xP - 2) = currentPixel;
|
||||
colorA = currentPixel;
|
||||
colorB = currentDelta;
|
||||
|
||||
|
||||
product = ((((colorA & colorMask) >> 1) +
|
||||
((colorB & colorMask) >> 1) +
|
||||
(colorA & colorB & lowPixelMask)));
|
||||
|
||||
|
||||
*(dP) = product;
|
||||
*(dP+1) = product;
|
||||
*(nL) = product;
|
||||
|
@ -166,11 +166,11 @@ void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
|
||||
colorA = nextPixel;
|
||||
colorB = nextDelta;
|
||||
|
||||
|
||||
product = ((((colorA & colorMask) >> 1) +
|
||||
((colorB & colorMask) >> 1) +
|
||||
(colorA & colorB & lowPixelMask)));
|
||||
|
||||
|
||||
*(dP + 2) = product;
|
||||
*(dP + 3) = product;
|
||||
*(nL + 2) = product;
|
||||
|
@ -178,11 +178,11 @@ void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
|
||||
nextPixel = *bP++;
|
||||
nextDelta = *xP++;
|
||||
|
||||
|
||||
dP += 4;
|
||||
nL += 4;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
|
||||
deltaPtr += srcPitch;
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
|
|
|
@ -25,9 +25,9 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
{
|
||||
u8 *nextLine, *finish;
|
||||
u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
|
||||
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *xP = (u32 *) deltaPtr;
|
||||
|
@ -37,20 +37,20 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
u32 nextPixel;
|
||||
u32 currentDelta;
|
||||
u32 nextDelta;
|
||||
|
||||
|
||||
finish = (u8 *) bP + ((width+2) << 1);
|
||||
nextPixel = *bP++;
|
||||
nextDelta = *xP++;
|
||||
|
||||
|
||||
do {
|
||||
currentPixel = nextPixel;
|
||||
currentDelta = nextDelta;
|
||||
nextPixel = *bP++;
|
||||
nextDelta = *xP++;
|
||||
|
||||
|
||||
if ((nextPixel != nextDelta) || (currentPixel != currentDelta)) {
|
||||
u32 colorA, colorB, product;
|
||||
|
||||
|
||||
*(xP - 2) = currentPixel;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
colorA = currentPixel >> 16;
|
||||
|
@ -60,7 +60,7 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
colorB = currentPixel >> 16;
|
||||
#endif
|
||||
product = (((colorA & colorMask) >> 1) & colorMask) >> 1;
|
||||
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
*(nL) = (product << 16) | (product);
|
||||
*(dP) = (colorA << 16) | product;
|
||||
|
@ -68,7 +68,7 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
*(nL) = product | (product << 16);
|
||||
*(dP) = colorA | (product << 16);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
colorA = nextPixel >> 16;
|
||||
#else
|
||||
|
@ -83,11 +83,11 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
|
|||
*(dP + 1) = (colorB) | (product << 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
dP += 2;
|
||||
nL += 2;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
|
||||
deltaPtr += srcPitch;
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
|
@ -101,9 +101,9 @@ void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
{
|
||||
u8 *nextLine, *finish;
|
||||
u32 colorMask = ~RGB_LOW_BITS_MASK;
|
||||
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
// u32 *xP = (u32 *) deltaPtr;
|
||||
|
@ -111,16 +111,16 @@ void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
u32 nextPixel;
|
||||
|
||||
|
||||
finish = (u8 *) bP + ((width+1) << 2);
|
||||
nextPixel = *bP++;
|
||||
|
||||
|
||||
do {
|
||||
currentPixel = nextPixel;
|
||||
nextPixel = *bP++;
|
||||
|
||||
|
||||
u32 colorA, colorB, product;
|
||||
|
||||
|
||||
colorA = currentPixel;
|
||||
colorB = nextPixel;
|
||||
|
||||
|
@ -137,11 +137,11 @@ void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
*(nL + 3) = product;
|
||||
*(dP + 2) = colorB;
|
||||
*(dP + 3) = product;
|
||||
|
||||
|
||||
dP += 4;
|
||||
nL += 4;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* 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.
|
||||
* 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, write to the Free Software
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* 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.
|
||||
* 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, write to the Free Software
|
||||
|
|
|
@ -91,22 +91,22 @@ bool remoteTcpInit()
|
|||
int error = WSAStartup(MAKEWORD(1,1),&wsaData);
|
||||
#endif // _WIN32
|
||||
SOCKET s = socket(PF_INET, SOCK_STREAM, 0);
|
||||
|
||||
|
||||
remoteListenSocket = s;
|
||||
|
||||
|
||||
if(s < 0) {
|
||||
fprintf(stderr,"Error opening socket\n");
|
||||
exit(-1);
|
||||
}
|
||||
int tmp = 1;
|
||||
setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp));
|
||||
|
||||
setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp));
|
||||
|
||||
// char hostname[256];
|
||||
// gethostname(hostname, 256);
|
||||
|
||||
|
||||
// hostent *ent = gethostbyname(hostname);
|
||||
// unsigned long a = *((unsigned long *)ent->h_addr);
|
||||
|
||||
|
||||
sockaddr_in addr;
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(remotePort);
|
||||
|
@ -122,10 +122,10 @@ bool remoteTcpInit()
|
|||
fprintf(stderr,"Error binding \n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
fprintf(stderr,"Listening for a connection at port %d\n",
|
||||
ntohs(addr.sin_port));
|
||||
|
||||
|
||||
if(listen(s, 1)) {
|
||||
fprintf(stderr, "Error listening\n");
|
||||
exit(-1);
|
||||
|
@ -133,7 +133,7 @@ bool remoteTcpInit()
|
|||
socklen_t len = sizeof(addr);
|
||||
|
||||
#ifdef _WIN32
|
||||
int flag = 0;
|
||||
int flag = 0;
|
||||
ioctlsocket(s, FIONBIO, (unsigned long *)&flag);
|
||||
#endif // _WIN32
|
||||
SOCKET s2 = accept(s, (sockaddr *)&addr, &len);
|
||||
|
@ -166,10 +166,10 @@ void remoteTcpCleanUp()
|
|||
remoteSocket = -1;
|
||||
}
|
||||
if(remoteListenSocket > 0) {
|
||||
fprintf(stderr, "Closing listen socket\n");
|
||||
fprintf(stderr, "Closing listen socket\n");
|
||||
close(remoteListenSocket);
|
||||
remoteListenSocket = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int remotePipeSend(char *data, int len)
|
||||
|
@ -192,7 +192,7 @@ bool remotePipeInit()
|
|||
fprintf(stderr, "ACK not received\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ void remoteSetProtocol(int p)
|
|||
remoteSendFnc = remotePipeSend;
|
||||
remoteRecvFnc = remotePipeRecv;
|
||||
remoteInitFnc = remotePipeInit;
|
||||
remoteCleanUpFnc = remotePipeCleanUp;
|
||||
remoteCleanUpFnc = remotePipeCleanUp;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ void remoteInit()
|
|||
|
||||
void remotePutPacket(const char *packet)
|
||||
{
|
||||
const char *hex = "0123456789abcdef";
|
||||
const char *hex = "0123456789abcdef";
|
||||
char buffer[1024];
|
||||
|
||||
size_t count = strlen(packet);
|
||||
|
@ -237,7 +237,7 @@ void remotePutPacket(const char *packet)
|
|||
|
||||
char *p = buffer;
|
||||
*p++ = '$';
|
||||
|
||||
|
||||
for(size_t i = 0 ;i < count; i++) {
|
||||
csum += packet[i];
|
||||
*p++ = packet[i];
|
||||
|
@ -283,7 +283,7 @@ void remoteOutput(char *s, u32 addr)
|
|||
|
||||
char *d = buffer;
|
||||
*d++ = 'O';
|
||||
|
||||
|
||||
if(s) {
|
||||
char c = *s++;
|
||||
while(c) {
|
||||
|
@ -339,10 +339,10 @@ void remoteSendStatus()
|
|||
(v >> 8) & 255,
|
||||
(v >> 16) & 255,
|
||||
(v >> 24) & 255);
|
||||
s += 12;
|
||||
s += 12;
|
||||
*s = 0;
|
||||
// printf("Sending %s\n", buffer);
|
||||
remotePutPacket(buffer);
|
||||
remotePutPacket(buffer);
|
||||
}
|
||||
|
||||
void remoteBinaryWrite(char *p)
|
||||
|
@ -368,8 +368,8 @@ void remoteBinaryWrite(char *p)
|
|||
break;
|
||||
}
|
||||
}
|
||||
// printf("ROM is %08x\n", debuggerReadMemory(0x8000254));
|
||||
remotePutPacket("OK");
|
||||
// printf("ROM is %08x\n", debuggerReadMemory(0x8000254));
|
||||
remotePutPacket("OK");
|
||||
}
|
||||
|
||||
void remoteMemoryWrite(char *p)
|
||||
|
@ -397,7 +397,7 @@ void remoteMemoryWrite(char *p)
|
|||
address++;
|
||||
}
|
||||
// printf("ROM is %08x\n", debuggerReadMemory(0x8000254));
|
||||
remotePutPacket("OK");
|
||||
remotePutPacket("OK");
|
||||
}
|
||||
|
||||
void remoteMemoryRead(char *p)
|
||||
|
@ -409,7 +409,7 @@ void remoteMemoryRead(char *p)
|
|||
|
||||
char buffer[1024];
|
||||
|
||||
char *s = buffer;
|
||||
char *s = buffer;
|
||||
for(int i = 0; i < count; i++) {
|
||||
u8 b = debuggerReadByte(address);
|
||||
sprintf(s, "%02x", b);
|
||||
|
@ -452,14 +452,14 @@ void remoteWriteWatch(char *p, bool active)
|
|||
remotePutPacket("E01");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(address > 0x203ffff && address < 0x3000000) {
|
||||
remotePutPacket("E01");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
u32 final = address + count;
|
||||
|
||||
|
||||
if(address < 0x2040000 && final > 0x2040000) {
|
||||
remotePutPacket("E01");
|
||||
return;
|
||||
|
@ -474,8 +474,8 @@ void remoteWriteWatch(char *p, bool active)
|
|||
else
|
||||
freezeInternalRAM[address & 0x7fff] = active;
|
||||
address++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
remotePutPacket("OK");
|
||||
}
|
||||
|
||||
|
@ -531,9 +531,9 @@ void remoteWriteRegister(char *p)
|
|||
u32 v = 0;
|
||||
|
||||
u8 data[4] = {0,0,0,0};
|
||||
|
||||
|
||||
int i = 0;
|
||||
|
||||
|
||||
while(c != '#') {
|
||||
u8 b = 0;
|
||||
if(c <= '9')
|
||||
|
@ -574,11 +574,11 @@ void remoteStubMain()
|
|||
remoteSendStatus();
|
||||
remoteResumed = false;
|
||||
}
|
||||
|
||||
|
||||
while(1) {
|
||||
char buffer[1024];
|
||||
int res = remoteRecvFnc(buffer, 1024);
|
||||
|
||||
|
||||
if(res == -1) {
|
||||
fprintf(stderr, "GDB connection lost\n");
|
||||
#ifdef SDL
|
||||
|
@ -675,13 +675,13 @@ void remoteStubMain()
|
|||
break;
|
||||
default:
|
||||
{
|
||||
*(strchr(p, '#') + 3) = 0;
|
||||
*(strchr(p, '#') + 3) = 0;
|
||||
fprintf(stderr, "Unknown packet %s\n", --p);
|
||||
remotePutPacket("");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void remoteStubSignal(int sig, int number)
|
||||
|
|
|
@ -24,24 +24,24 @@ void Scanlines (u8 *srcPtr, u32 srcPitch, u8 *,
|
|||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
u8 *nextLine, *finish;
|
||||
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *dP = (u32 *) dstPtr;
|
||||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
u32 nextPixel;
|
||||
|
||||
|
||||
finish = (u8 *) bP + ((width+2) << 1);
|
||||
nextPixel = *bP++;
|
||||
|
||||
|
||||
do {
|
||||
currentPixel = nextPixel;
|
||||
nextPixel = *bP++;
|
||||
u32 colorA, colorB;
|
||||
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
colorA = currentPixel >> 16;
|
||||
colorB = currentPixel & 0xffff;
|
||||
|
@ -61,11 +61,11 @@ void Scanlines (u8 *srcPtr, u32 srcPitch, u8 *,
|
|||
|
||||
*(dP + 1) = colorB | (colorB << 16);
|
||||
*(nL + 1) = 0;
|
||||
|
||||
|
||||
dP += 2;
|
||||
nL += 2;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
|
@ -77,25 +77,25 @@ void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
u8 *nextLine, *finish;
|
||||
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *dP = (u32 *) dstPtr;
|
||||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
u32 nextPixel;
|
||||
|
||||
|
||||
finish = (u8 *) bP + ((width+1) << 2);
|
||||
nextPixel = *bP++;
|
||||
|
||||
|
||||
do {
|
||||
currentPixel = nextPixel;
|
||||
nextPixel = *bP++;
|
||||
|
||||
|
||||
u32 colorA, colorB;
|
||||
|
||||
|
||||
colorA = currentPixel;
|
||||
colorB = nextPixel;
|
||||
|
||||
|
@ -106,15 +106,15 @@ void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
|
||||
*(dP + 2) = colorB;
|
||||
*(dP + 3) = colorB;
|
||||
*(nL+2) = 0;
|
||||
*(nL+2) = 0;
|
||||
*(nL+3) = 0;
|
||||
|
||||
|
||||
nextPixel = *bP++;
|
||||
|
||||
dP += 4;
|
||||
nL += 4;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
|
@ -127,23 +127,23 @@ void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
{
|
||||
u8 *nextLine, *finish;
|
||||
u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
|
||||
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *dP = (u32 *) dstPtr;
|
||||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
u32 nextPixel;
|
||||
|
||||
|
||||
finish = (u8 *) bP + ((width+2) << 1);
|
||||
nextPixel = *bP++;
|
||||
|
||||
|
||||
do {
|
||||
currentPixel = nextPixel;
|
||||
nextPixel = *bP++;
|
||||
|
||||
|
||||
u32 colorA, colorB;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
|
@ -153,7 +153,7 @@ void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
colorA = currentPixel & 0xFFFF;
|
||||
colorB = currentPixel >> 16;
|
||||
#endif
|
||||
|
||||
|
||||
*(dP) = colorA = colorA | ((((colorA & colorMask) >> 1) +
|
||||
((colorB & colorMask) >> 1))) << 16;
|
||||
colorA = ((colorA & colorMask) >> 1);
|
||||
|
@ -167,12 +167,12 @@ void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
colorB = ((colorB & colorMask) >> 1);
|
||||
colorB += ((colorB & colorMask) >> 1);
|
||||
|
||||
*(nL + 1) = colorB;
|
||||
|
||||
*(nL + 1) = colorB;
|
||||
|
||||
dP += 2;
|
||||
nL += 2;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
|
@ -185,28 +185,28 @@ void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
{
|
||||
u8 *nextLine, *finish;
|
||||
u32 colorMask = ~RGB_LOW_BITS_MASK;
|
||||
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *dP = (u32 *) dstPtr;
|
||||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
u32 nextPixel;
|
||||
|
||||
|
||||
finish = (u8 *) bP + ((width+1) << 2);
|
||||
nextPixel = *bP++;
|
||||
|
||||
|
||||
do {
|
||||
currentPixel = nextPixel;
|
||||
nextPixel = *bP++;
|
||||
|
||||
|
||||
u32 colorA, colorB, temp;
|
||||
|
||||
colorA = currentPixel;
|
||||
colorB = nextPixel;
|
||||
|
||||
|
||||
*(dP) = colorA;
|
||||
*(dP+1) = temp = ((colorA & colorMask) >> 1) +
|
||||
((colorB & colorMask) >> 1);
|
||||
|
@ -221,7 +221,7 @@ void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
|||
dP += 2;
|
||||
nL += 2;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
|
|
278
src/sdl/SDL.cpp
278
src/sdl/SDL.cpp
|
@ -64,11 +64,11 @@ extern bool soundLowPass;
|
|||
extern bool soundReverse;
|
||||
extern int Init_2xSaI(u32);
|
||||
extern void _2xSaI(u8*,u32,u8*,u8*,u32,int,int);
|
||||
extern void _2xSaI32(u8*,u32,u8*,u8*,u32,int,int);
|
||||
extern void _2xSaI32(u8*,u32,u8*,u8*,u32,int,int);
|
||||
extern void Super2xSaI(u8*,u32,u8*,u8*,u32,int,int);
|
||||
extern void Super2xSaI32(u8*,u32,u8*,u8*,u32,int,int);
|
||||
extern void SuperEagle(u8*,u32,u8*,u8*,u32,int,int);
|
||||
extern void SuperEagle32(u8*,u32,u8*,u8*,u32,int,int);
|
||||
extern void SuperEagle32(u8*,u32,u8*,u8*,u32,int,int);
|
||||
extern void Pixelate(u8*,u32,u8*,u8*,u32,int,int);
|
||||
extern void Pixelate32(u8*,u32,u8*,u8*,u32,int,int);
|
||||
extern void MotionBlur(u8*,u32,u8*,u8*,u32,int,int);
|
||||
|
@ -192,7 +192,7 @@ static int rewindTimer = 0;
|
|||
#define _stricmp strcasecmp
|
||||
|
||||
bool sdlButtons[4][12] = {
|
||||
{ false, false, false, false, false, false,
|
||||
{ false, false, false, false, false, false,
|
||||
false, false, false, false, false, false },
|
||||
{ false, false, false, false, false, false,
|
||||
false, false, false, false, false, false },
|
||||
|
@ -308,7 +308,7 @@ u16 defaultMotion[4] = {
|
|||
|
||||
struct option sdlOptions[] = {
|
||||
{ "agb-print", no_argument, &sdlAgbPrint, 1 },
|
||||
{ "auto-frameskip", no_argument, &autoFrameSkip, 1 },
|
||||
{ "auto-frameskip", no_argument, &autoFrameSkip, 1 },
|
||||
{ "bios", required_argument, 0, 'b' },
|
||||
{ "config", required_argument, 0, 'c' },
|
||||
{ "debug", no_argument, 0, 'd' },
|
||||
|
@ -360,7 +360,7 @@ struct option sdlOptions[] = {
|
|||
{ "show-speed-normal", no_argument, &showSpeed, 1 },
|
||||
{ "show-speed-detailed", no_argument, &showSpeed, 2 },
|
||||
{ "throttle", required_argument, 0, 'T' },
|
||||
{ "verbose", required_argument, 0, 'v' },
|
||||
{ "verbose", required_argument, 0, 'v' },
|
||||
{ "video-1x", no_argument, &sizeOption, 0 },
|
||||
{ "video-2x", no_argument, &sizeOption, 1 },
|
||||
{ "video-3x", no_argument, &sizeOption, 2 },
|
||||
|
@ -400,21 +400,21 @@ extern bool gbIsGameboyRom(char *);
|
|||
sdlStretcher[sdlStretcherPos++] = 0x06;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0xc6;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x02;
|
||||
sdlStretcher[sdlStretcherPos++] = 0x02;
|
||||
|
||||
#define SDL_LOADL \
|
||||
sdlStretcher[sdlStretcherPos++] = 0x8b;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x06;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0xc6;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x04;
|
||||
sdlStretcher[sdlStretcherPos++] = 0x04;
|
||||
|
||||
#define SDL_LOADL2 \
|
||||
sdlStretcher[sdlStretcherPos++] = 0x8b;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x06;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0xc6;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x03;
|
||||
sdlStretcher[sdlStretcherPos++] = 0x03;
|
||||
|
||||
#define SDL_STOREW \
|
||||
sdlStretcher[sdlStretcherPos++] = 0x66;\
|
||||
|
@ -422,21 +422,21 @@ extern bool gbIsGameboyRom(char *);
|
|||
sdlStretcher[sdlStretcherPos++] = 0x07;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0xc7;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x02;
|
||||
sdlStretcher[sdlStretcherPos++] = 0x02;
|
||||
|
||||
#define SDL_STOREL \
|
||||
sdlStretcher[sdlStretcherPos++] = 0x89;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x07;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0xc7;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x04;
|
||||
sdlStretcher[sdlStretcherPos++] = 0x04;
|
||||
|
||||
#define SDL_STOREL2 \
|
||||
sdlStretcher[sdlStretcherPos++] = 0x89;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x07;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x83;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0xc7;\
|
||||
sdlStretcher[sdlStretcherPos++] = 0x03;
|
||||
sdlStretcher[sdlStretcherPos++] = 0x03;
|
||||
|
||||
#define SDL_RET \
|
||||
sdlStretcher[sdlStretcherPos++] = 0xc3;
|
||||
|
@ -823,7 +823,7 @@ void sdlCheckDirectory(char *dir)
|
|||
if(*p == '/' ||
|
||||
*p == '\\')
|
||||
*p = 0;
|
||||
|
||||
|
||||
if(stat(dir, &buf) == 0) {
|
||||
if(!(buf.st_mode & S_IFDIR)) {
|
||||
fprintf(stderr, "Error: %s is not a directory\n", dir);
|
||||
|
@ -840,9 +840,9 @@ char *sdlGetFilename(char *name)
|
|||
static char filebuffer[2048];
|
||||
|
||||
int len = strlen(name);
|
||||
|
||||
|
||||
char *p = name + len - 1;
|
||||
|
||||
|
||||
while(true) {
|
||||
if(*p == '/' ||
|
||||
*p == '\\') {
|
||||
|
@ -854,7 +854,7 @@ char *sdlGetFilename(char *name)
|
|||
if(len == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(len == 0)
|
||||
strcpy(filebuffer, name);
|
||||
else
|
||||
|
@ -878,11 +878,11 @@ FILE *sdlFindFile(const char *name)
|
|||
#endif // ! _WIN32
|
||||
|
||||
fprintf(stderr, "Searching for file %s\n", name);
|
||||
|
||||
|
||||
if(GETCWD(buffer, 2048)) {
|
||||
fprintf(stderr, "Searching current directory: %s\n", buffer);
|
||||
}
|
||||
|
||||
|
||||
FILE *f = fopen(name, "r");
|
||||
if(f != NULL) {
|
||||
return f;
|
||||
|
@ -924,7 +924,7 @@ FILE *sdlFindFile(const char *name)
|
|||
strncpy(buffer, path, 4096);
|
||||
buffer[4095] = 0;
|
||||
char *tok = strtok(buffer, PATH_SEP);
|
||||
|
||||
|
||||
while(tok) {
|
||||
sprintf(path, "%s%c%s", tok, FILE_SEP, EXE_NAME);
|
||||
f = fopen(path, "r");
|
||||
|
@ -960,7 +960,7 @@ FILE *sdlFindFile(const char *name)
|
|||
void sdlReadPreferences(FILE *f)
|
||||
{
|
||||
char buffer[2048];
|
||||
|
||||
|
||||
while(1) {
|
||||
char *s = fgets(buffer, 2048, f);
|
||||
|
||||
|
@ -968,10 +968,10 @@ void sdlReadPreferences(FILE *f)
|
|||
break;
|
||||
|
||||
char *p = strchr(s, '#');
|
||||
|
||||
|
||||
if(p)
|
||||
*p = 0;
|
||||
|
||||
|
||||
char *token = strtok(s, " \t\n\r=");
|
||||
|
||||
if(!token)
|
||||
|
@ -1099,7 +1099,7 @@ void sdlReadPreferences(FILE *f)
|
|||
} else if(!strcmp(key, "gbFrameSkip")) {
|
||||
gbFrameSkip = sdlFromHex(value);
|
||||
if(gbFrameSkip < 0 || gbFrameSkip > 9)
|
||||
gbFrameSkip = 0;
|
||||
gbFrameSkip = 0;
|
||||
} else if(!strcmp(key, "video")) {
|
||||
sizeOption = sdlFromHex(value);
|
||||
if(sizeOption < 0 || sizeOption > 3)
|
||||
|
@ -1147,7 +1147,7 @@ void sdlReadPreferences(FILE *f)
|
|||
case 4:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown sound quality %d. Defaulting to 22Khz\n",
|
||||
fprintf(stderr, "Unknown sound quality %d. Defaulting to 22Khz\n",
|
||||
soundQuality);
|
||||
soundQuality = 2;
|
||||
break;
|
||||
|
@ -1251,7 +1251,7 @@ static void sdlApplyPerImagePreferences()
|
|||
char readBuffer[2048];
|
||||
|
||||
bool found = false;
|
||||
|
||||
|
||||
while(1) {
|
||||
char *s = fgets(readBuffer, 2048, f);
|
||||
|
||||
|
@ -1259,10 +1259,10 @@ static void sdlApplyPerImagePreferences()
|
|||
break;
|
||||
|
||||
char *p = strchr(s, ';');
|
||||
|
||||
|
||||
if(p)
|
||||
*p = 0;
|
||||
|
||||
|
||||
char *token = strtok(s, " \t\n\r=");
|
||||
|
||||
if(!token)
|
||||
|
@ -1298,7 +1298,7 @@ static void sdlApplyPerImagePreferences()
|
|||
char *value = strtok(NULL, "\t\n\r=");
|
||||
if(value == NULL)
|
||||
continue;
|
||||
|
||||
|
||||
if(!strcmp(token, "rtcEnabled"))
|
||||
rtcEnable(atoi(value) == 0 ? false : true);
|
||||
else if(!strcmp(token, "flashSize")) {
|
||||
|
@ -1320,7 +1320,7 @@ static void sdlApplyPerImagePreferences()
|
|||
static int sdlCalculateShift(u32 mask)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
|
||||
while(mask) {
|
||||
m++;
|
||||
mask >>= 1;
|
||||
|
@ -1358,7 +1358,7 @@ void sdlWriteState(int num)
|
|||
num+1);
|
||||
else
|
||||
sprintf(stateName,"%s%d.sgm", filename, num+1);
|
||||
|
||||
|
||||
if(emulator.emuWriteState)
|
||||
emulator.emuWriteState(stateName);
|
||||
|
||||
|
@ -1393,7 +1393,7 @@ void sdlWriteBattery()
|
|||
|
||||
if(batteryDir[0])
|
||||
sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename));
|
||||
else
|
||||
else
|
||||
sprintf(buffer, "%s.sav", filename);
|
||||
|
||||
emulator.emuWriteBattery(buffer);
|
||||
|
@ -1404,12 +1404,12 @@ void sdlWriteBattery()
|
|||
void sdlReadBattery()
|
||||
{
|
||||
char buffer[1048];
|
||||
|
||||
|
||||
if(batteryDir[0])
|
||||
sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename));
|
||||
else
|
||||
else
|
||||
sprintf(buffer, "%s.sav", filename);
|
||||
|
||||
|
||||
bool res = false;
|
||||
|
||||
res = emulator.emuReadBattery(buffer);
|
||||
|
@ -1453,7 +1453,7 @@ void sdlUpdateJoyButton(int which,
|
|||
int b = joypad[j][i] & 0xfff;
|
||||
if(dev) {
|
||||
dev--;
|
||||
|
||||
|
||||
if((dev == which) && (b >= 128) && (b == (button+128))) {
|
||||
sdlButtons[j][i] = pressed;
|
||||
}
|
||||
|
@ -1470,7 +1470,7 @@ void sdlUpdateJoyButton(int which,
|
|||
sdlMotionButtons[i] = pressed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sdlUpdateJoyHat(int which,
|
||||
|
@ -1484,7 +1484,7 @@ void sdlUpdateJoyHat(int which,
|
|||
int a = joypad[j][i] & 0xfff;
|
||||
if(dev) {
|
||||
dev--;
|
||||
|
||||
|
||||
if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) {
|
||||
int dir = a & 3;
|
||||
int v = 0;
|
||||
|
@ -1533,7 +1533,7 @@ void sdlUpdateJoyHat(int which,
|
|||
sdlMotionButtons[i] = (v ? true : false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sdlUpdateJoyAxis(int which,
|
||||
|
@ -1547,7 +1547,7 @@ void sdlUpdateJoyAxis(int which,
|
|||
int a = joypad[j][i] & 0xfff;
|
||||
if(dev) {
|
||||
dev--;
|
||||
|
||||
|
||||
if((dev == which) && (a < 32) && ((a>>1) == axis)) {
|
||||
sdlButtons[j][i] = (a & 1) ? (value > 16384) : (value < -16384);
|
||||
}
|
||||
|
@ -1564,7 +1564,7 @@ void sdlUpdateJoyAxis(int which,
|
|||
sdlMotionButtons[i] = (a & 1) ? (value > 16384) : (value < -16384);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool sdlCheckJoyKey(int key)
|
||||
|
@ -1579,7 +1579,7 @@ bool sdlCheckJoyKey(int key)
|
|||
if(button >= SDL_JoystickNumButtons(sdlDevices[dev]))
|
||||
return false;
|
||||
} else if (what < 0x20) {
|
||||
// joystick axis
|
||||
// joystick axis
|
||||
what >>= 1;
|
||||
if(what >= SDL_JoystickNumAxes(sdlDevices[dev]))
|
||||
return false;
|
||||
|
@ -1612,18 +1612,18 @@ void sdlCheckKeys()
|
|||
if(dev) {
|
||||
dev--;
|
||||
bool ok = false;
|
||||
|
||||
|
||||
if(sdlDevices) {
|
||||
if(dev < sdlNumDevices) {
|
||||
if(sdlDevices[dev] == NULL) {
|
||||
sdlDevices[dev] = SDL_JoystickOpen(dev);
|
||||
}
|
||||
|
||||
|
||||
ok = sdlCheckJoyKey(joypad[j][i]);
|
||||
} else
|
||||
ok = false;
|
||||
}
|
||||
|
||||
|
||||
if(!ok)
|
||||
joypad[j][i] = defaultJoypad[i];
|
||||
else
|
||||
|
@ -1637,18 +1637,18 @@ void sdlCheckKeys()
|
|||
if(dev) {
|
||||
dev--;
|
||||
bool ok = false;
|
||||
|
||||
|
||||
if(sdlDevices) {
|
||||
if(dev < sdlNumDevices) {
|
||||
if(sdlDevices[dev] == NULL) {
|
||||
sdlDevices[dev] = SDL_JoystickOpen(dev);
|
||||
}
|
||||
|
||||
|
||||
ok = sdlCheckJoyKey(motion[i]);
|
||||
} else
|
||||
ok = false;
|
||||
}
|
||||
|
||||
|
||||
if(!ok)
|
||||
motion[i] = defaultMotion[i];
|
||||
else
|
||||
|
@ -1682,7 +1682,7 @@ void sdlPollEvents()
|
|||
if(emulating)
|
||||
soundPause();
|
||||
}
|
||||
|
||||
|
||||
memset(delta,255,sizeof(delta));
|
||||
}
|
||||
}
|
||||
|
@ -1729,10 +1729,10 @@ void sdlPollEvents()
|
|||
case SDLK_b:
|
||||
if(!(event.key.keysym.mod & MOD_NOCTRL) &&
|
||||
(event.key.keysym.mod & KMOD_CTRL)) {
|
||||
if(emulating && emulator.emuReadMemState && rewindMemory
|
||||
if(emulating && emulator.emuReadMemState && rewindMemory
|
||||
&& rewindCount) {
|
||||
rewindPos = (rewindPos - 1) & 7;
|
||||
emulator.emuReadMemState(&rewindMemory[REWIND_SIZE*rewindPos],
|
||||
emulator.emuReadMemState(&rewindMemory[REWIND_SIZE*rewindPos],
|
||||
REWIND_SIZE);
|
||||
rewindCount--;
|
||||
rewindCounter = 0;
|
||||
|
@ -1799,12 +1799,12 @@ void sdlPollEvents()
|
|||
case SDLK_4:
|
||||
if(!(event.key.keysym.mod & MOD_NOALT) &&
|
||||
(event.key.keysym.mod & KMOD_ALT)) {
|
||||
const char *disableMessages[4] =
|
||||
const char *disableMessages[4] =
|
||||
{ "autofire A disabled",
|
||||
"autofire B disabled",
|
||||
"autofire R disabled",
|
||||
"autofire L disabled"};
|
||||
const char *enableMessages[4] =
|
||||
const char *enableMessages[4] =
|
||||
{ "autofire A",
|
||||
"autofire B",
|
||||
"autofire R",
|
||||
|
@ -1950,12 +1950,12 @@ int main(int argc, char **argv)
|
|||
fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", VERSION);
|
||||
|
||||
arg0 = argv[0];
|
||||
|
||||
|
||||
captureDir[0] = 0;
|
||||
saveDir[0] = 0;
|
||||
batteryDir[0] = 0;
|
||||
ipsname[0] = 0;
|
||||
|
||||
|
||||
int op = -1;
|
||||
|
||||
frameSkip = 2;
|
||||
|
@ -1966,7 +1966,7 @@ int main(int argc, char **argv)
|
|||
sdlReadPreferences();
|
||||
|
||||
sdlPrintUsage = 0;
|
||||
|
||||
|
||||
while((op = getopt_long(argc,
|
||||
argv,
|
||||
"FNT:Y:G:D:b:c:df:hi:p::s:t:v:1234",
|
||||
|
@ -2128,7 +2128,7 @@ int main(int argc, char **argv)
|
|||
case 'v':
|
||||
if(optarg) {
|
||||
systemVerbose = atoi(optarg);
|
||||
} else
|
||||
} else
|
||||
systemVerbose = 0;
|
||||
break;
|
||||
case '1':
|
||||
|
@ -2169,7 +2169,7 @@ int main(int argc, char **argv)
|
|||
|
||||
rtcEnable(sdlRtcEnable ? true : false);
|
||||
agbPrintEnable(sdlAgbPrint ? true : false);
|
||||
|
||||
|
||||
if(!debuggerStub) {
|
||||
if(optind >= argc) {
|
||||
systemMessage(0,"Missing image name");
|
||||
|
@ -2194,7 +2194,7 @@ int main(int argc, char **argv)
|
|||
if(optind < argc) {
|
||||
char *szFile = argv[optind];
|
||||
u32 len = strlen(szFile);
|
||||
if (len > SYSMSG_BUFFER_SIZE)
|
||||
if (len > SYSMSG_BUFFER_SIZE)
|
||||
{
|
||||
fprintf(stderr,"%s :%s: File name too long\n",argv[0],szFile);
|
||||
exit(-1);
|
||||
|
@ -2208,7 +2208,7 @@ int main(int argc, char **argv)
|
|||
|
||||
if(ipsname[0] == 0)
|
||||
sprintf(ipsname, "%s.ips", filename);
|
||||
|
||||
|
||||
bool failed = false;
|
||||
|
||||
IMAGE_TYPE type = utilFindType(szFile);
|
||||
|
@ -2218,12 +2218,12 @@ int main(int argc, char **argv)
|
|||
exit(-1);
|
||||
}
|
||||
cartridgeType = (int)type;
|
||||
|
||||
|
||||
if(type == IMAGE_GB) {
|
||||
failed = !gbLoadRom(szFile);
|
||||
if(!failed) {
|
||||
gbGetHardwareType();
|
||||
|
||||
|
||||
// used for the handling of the gb Boot Rom
|
||||
if (gbHardware & 5)
|
||||
{
|
||||
|
@ -2236,7 +2236,7 @@ int main(int argc, char **argv)
|
|||
gbCPUInit(tempName, useBios);
|
||||
}
|
||||
else useBios = false;
|
||||
|
||||
|
||||
gbReset();
|
||||
cartridgeType = IMAGE_GB;
|
||||
emulator = GBSystem;
|
||||
|
@ -2257,7 +2257,7 @@ int main(int argc, char **argv)
|
|||
sdlApplyPerImagePreferences();
|
||||
|
||||
doMirroring(mirroringEnable);
|
||||
|
||||
|
||||
cartridgeType = 0;
|
||||
emulator = GBASystem;
|
||||
|
||||
|
@ -2266,7 +2266,7 @@ int main(int argc, char **argv)
|
|||
WRITE32LE(&rom[0], 0xea00002e);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
CPUInit(biosFileName, useBios);
|
||||
CPUReset();
|
||||
if(sdlAutoIPS) {
|
||||
|
@ -2278,7 +2278,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(failed) {
|
||||
systemMessage(0, "Failed to load file %s", szFile);
|
||||
exit(-1);
|
||||
|
@ -2297,22 +2297,22 @@ int main(int argc, char **argv)
|
|||
ioMem = (u8 *)calloc(1, 0x400);
|
||||
|
||||
emulator = GBASystem;
|
||||
|
||||
|
||||
CPUInit(biosFileName, useBios);
|
||||
CPUReset();
|
||||
CPUReset();
|
||||
}
|
||||
|
||||
|
||||
sdlReadBattery();
|
||||
|
||||
if(debuggerStub)
|
||||
|
||||
if(debuggerStub)
|
||||
remoteInit();
|
||||
|
||||
|
||||
int flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO|
|
||||
SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE;
|
||||
|
||||
if(soundOffFlag)
|
||||
flags ^= SDL_INIT_AUDIO;
|
||||
|
||||
|
||||
if(SDL_Init(flags)) {
|
||||
systemMessage(0, "Failed to init SDL: %s", SDL_GetError());
|
||||
exit(-1);
|
||||
|
@ -2321,9 +2321,9 @@ int main(int argc, char **argv)
|
|||
if(SDL_InitSubSystem(SDL_INIT_JOYSTICK)) {
|
||||
systemMessage(0, "Failed to init joystick support: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
|
||||
sdlCheckKeys();
|
||||
|
||||
|
||||
if(cartridgeType == 0) {
|
||||
srcWidth = 240;
|
||||
srcHeight = 160;
|
||||
|
@ -2335,7 +2335,7 @@ int main(int argc, char **argv)
|
|||
gbBorderLineSkip = 256;
|
||||
gbBorderColumnSkip = 48;
|
||||
gbBorderRowSkip = 40;
|
||||
} else {
|
||||
} else {
|
||||
srcWidth = 160;
|
||||
srcHeight = 144;
|
||||
gbBorderLineSkip = 160;
|
||||
|
@ -2347,24 +2347,24 @@ int main(int argc, char **argv)
|
|||
srcWidth = 320;
|
||||
srcHeight = 240;
|
||||
}
|
||||
|
||||
|
||||
destWidth = (sizeOption+1)*srcWidth;
|
||||
destHeight = (sizeOption+1)*srcHeight;
|
||||
|
||||
|
||||
surface = SDL_SetVideoMode(destWidth, destHeight, 16,
|
||||
SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF|
|
||||
(fullscreen ? SDL_FULLSCREEN : 0));
|
||||
|
||||
|
||||
if(surface == NULL) {
|
||||
systemMessage(0, "Failed to set video mode");
|
||||
SDL_Quit();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
systemRedShift = sdlCalculateShift(surface->format->Rmask);
|
||||
systemGreenShift = sdlCalculateShift(surface->format->Gmask);
|
||||
systemBlueShift = sdlCalculateShift(surface->format->Bmask);
|
||||
|
||||
|
||||
systemColorDepth = surface->format->BitsPerPixel;
|
||||
if(systemColorDepth == 15)
|
||||
systemColorDepth = 16;
|
||||
|
@ -2376,7 +2376,7 @@ int main(int argc, char **argv)
|
|||
systemGreenShift = 11;
|
||||
systemBlueShift = 19;
|
||||
}
|
||||
|
||||
|
||||
if(systemColorDepth != 16 && systemColorDepth != 24 &&
|
||||
systemColorDepth != 32) {
|
||||
fprintf(stderr,"Unsupported color depth '%d'.\nOnly 16, 24 and 32 bit color depths are supported\n", systemColorDepth);
|
||||
|
@ -2403,7 +2403,7 @@ int main(int argc, char **argv)
|
|||
#endif
|
||||
|
||||
fprintf(stderr,"Color depth: %d\n", systemColorDepth);
|
||||
|
||||
|
||||
if(systemColorDepth == 16) {
|
||||
if(sdlCalculateMaskWidth(surface->format->Gmask) == 6) {
|
||||
Init_2xSaI(565);
|
||||
|
@ -2520,7 +2520,7 @@ int main(int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(systemColorDepth == 16) {
|
||||
switch(ifbType) {
|
||||
case 0:
|
||||
|
@ -2554,7 +2554,7 @@ int main(int argc, char **argv)
|
|||
delta = (u8*)malloc(322*242*4);
|
||||
memset(delta, 255, 322*242*4);
|
||||
}
|
||||
|
||||
|
||||
emulating = 1;
|
||||
renderedFrames = 0;
|
||||
|
||||
|
@ -2562,7 +2562,7 @@ int main(int argc, char **argv)
|
|||
soundInit();
|
||||
|
||||
autoFrameSkipLastTime = throttleLastTime = systemGetClock();
|
||||
|
||||
|
||||
SDL_WM_SetCaption("VisualBoyAdvance", NULL);
|
||||
|
||||
while(emulating) {
|
||||
|
@ -2576,7 +2576,7 @@ int main(int argc, char **argv)
|
|||
if(rewindCount > 8)
|
||||
rewindCount = 8;
|
||||
if(emulator.emuWriteMemState &&
|
||||
emulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE],
|
||||
emulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE],
|
||||
REWIND_SIZE)) {
|
||||
rewindPos = (rewindPos + 1) & 7;
|
||||
if(rewindCount == 8)
|
||||
|
@ -2596,7 +2596,7 @@ int main(int argc, char **argv)
|
|||
SDL_ShowCursor(SDL_DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
emulating = 0;
|
||||
fprintf(stderr,"Shutting down\n");
|
||||
remoteCleanUp();
|
||||
|
@ -2611,7 +2611,7 @@ int main(int argc, char **argv)
|
|||
free(delta);
|
||||
delta = NULL;
|
||||
}
|
||||
|
||||
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
@ -2620,10 +2620,10 @@ void systemMessage(int num, const char *msg, ...)
|
|||
{
|
||||
char buffer[SYSMSG_BUFFER_SIZE*2];
|
||||
va_list valist;
|
||||
|
||||
|
||||
va_start(valist, msg);
|
||||
vsprintf(buffer, msg, valist);
|
||||
|
||||
|
||||
fprintf(stderr, "%s\n", buffer);
|
||||
va_end(valist);
|
||||
}
|
||||
|
@ -2631,12 +2631,12 @@ void systemMessage(int num, const char *msg, ...)
|
|||
void systemDrawScreen()
|
||||
{
|
||||
renderedFrames++;
|
||||
|
||||
|
||||
if(yuv) {
|
||||
Draw_Overlay(surface, sizeOption+1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SDL_LockSurface(surface);
|
||||
|
||||
if(screenMessage) {
|
||||
|
@ -2646,7 +2646,7 @@ void systemDrawScreen()
|
|||
if(((systemGetClock() - screenMessageTime) < 3000) &&
|
||||
!disableStatusMessages) {
|
||||
drawText(pix, srcPitch, 10, srcHeight - 20,
|
||||
screenMessageBuffer);
|
||||
screenMessageBuffer);
|
||||
} else {
|
||||
screenMessage = false;
|
||||
}
|
||||
|
@ -2658,7 +2658,7 @@ void systemDrawScreen()
|
|||
else
|
||||
ifbFunction(pix+destWidth*2+4, destWidth*2+4, srcWidth, srcHeight);
|
||||
}
|
||||
|
||||
|
||||
if(filterFunction) {
|
||||
if(systemColorDepth == 16)
|
||||
filterFunction(pix+destWidth+4,destWidth+4, delta,
|
||||
|
@ -2694,7 +2694,7 @@ void systemDrawScreen()
|
|||
break;
|
||||
case 1:
|
||||
for(i = 0; i < srcHeight; i++) {
|
||||
SDL_CALL_STRETCHER;
|
||||
SDL_CALL_STRETCHER;
|
||||
dest += destPitch;
|
||||
SDL_CALL_STRETCHER;
|
||||
src += srcPitch;
|
||||
|
@ -2747,8 +2747,8 @@ void systemDrawScreen()
|
|||
surface->pitch,
|
||||
10,
|
||||
surface->h-20,
|
||||
buffer);
|
||||
}
|
||||
buffer);
|
||||
}
|
||||
|
||||
SDL_UnlockSurface(surface);
|
||||
// SDL_UpdateRect(surface, 0, 0, destWidth, destHeight);
|
||||
|
@ -2764,9 +2764,9 @@ u32 systemReadJoypad(int which)
|
|||
{
|
||||
if(which < 0 || which > 3)
|
||||
which = sdlDefaultJoypad;
|
||||
|
||||
|
||||
u32 res = 0;
|
||||
|
||||
|
||||
if(sdlButtons[which][KEY_BUTTON_A])
|
||||
res |= 1;
|
||||
if(sdlButtons[which][KEY_BUTTON_B])
|
||||
|
@ -2805,7 +2805,7 @@ u32 systemReadJoypad(int which)
|
|||
res |= autoFire;
|
||||
autoFireToggle = !autoFireToggle;
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -2819,7 +2819,7 @@ void systemShowSpeed(int speed)
|
|||
systemSpeed = speed;
|
||||
|
||||
showRenderedFrames = renderedFrames;
|
||||
renderedFrames = 0;
|
||||
renderedFrames = 0;
|
||||
|
||||
if(!fullscreen && showSpeed) {
|
||||
char buffer[80];
|
||||
|
@ -2840,14 +2840,14 @@ void systemFrame()
|
|||
|
||||
void system10Frames(int rate)
|
||||
{
|
||||
u32 time = systemGetClock();
|
||||
u32 time = systemGetClock();
|
||||
if(!wasPaused && autoFrameSkip && !throttle) {
|
||||
u32 diff = time - autoFrameSkipLastTime;
|
||||
int speed = 100;
|
||||
|
||||
if(diff)
|
||||
speed = (1000000/rate)/diff;
|
||||
|
||||
|
||||
if(speed >= 98) {
|
||||
frameskipadjust++;
|
||||
|
||||
|
@ -2867,15 +2867,15 @@ void system10Frames(int rate)
|
|||
if(systemFrameSkip < 9)
|
||||
systemFrameSkip++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!wasPaused && throttle) {
|
||||
if(!speedup) {
|
||||
u32 diff = time - throttleLastTime;
|
||||
|
||||
|
||||
int target = (1000000/(rate*throttle));
|
||||
int d = (target - diff);
|
||||
|
||||
|
||||
if(d > 0) {
|
||||
SDL_Delay(d);
|
||||
}
|
||||
|
@ -3102,7 +3102,7 @@ void systemUpdateMotionSensor()
|
|||
sensorY += 2;
|
||||
if(sensorY > 2047)
|
||||
sensorY = 2047;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int systemGetSensorX()
|
||||
|
@ -3127,7 +3127,7 @@ void systemScreenMessage(const char *msg)
|
|||
strncpy(screenMessageBuffer, msg, 20);
|
||||
screenMessageBuffer[20] = 0;
|
||||
} else
|
||||
strcpy(screenMessageBuffer, msg);
|
||||
strcpy(screenMessageBuffer, msg);
|
||||
}
|
||||
|
||||
bool systemCanChangeSoundQuality()
|
||||
|
@ -3153,7 +3153,7 @@ bool systemPauseOnFrame()
|
|||
|
||||
void Init_Overlay(SDL_Surface *gbascreen, int overlaytype)
|
||||
{
|
||||
|
||||
|
||||
overlay = SDL_CreateYUVOverlay( GBA_WIDTH,
|
||||
GBA_HEIGHT,
|
||||
overlaytype, gbascreen);
|
||||
|
@ -3170,7 +3170,7 @@ void Init_Overlay(SDL_Surface *gbascreen, int overlaytype)
|
|||
|
||||
void Quit_Overlay(void)
|
||||
{
|
||||
|
||||
|
||||
SDL_FreeYUVOverlay(overlay);
|
||||
}
|
||||
|
||||
|
@ -3189,16 +3189,16 @@ inline void ConvertRGBtoYV12(SDL_Overlay *o)
|
|||
int x,y;
|
||||
int yuv[3];
|
||||
Uint8 *p,*op[3];
|
||||
|
||||
|
||||
SDL_LockYUVOverlay(o);
|
||||
|
||||
|
||||
/* Black initialization */
|
||||
/*
|
||||
memset(o->pixels[0],0,o->pitches[0]*o->h);
|
||||
memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
|
||||
memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
|
||||
*/
|
||||
|
||||
|
||||
/* Convert */
|
||||
for(y=0; y<160 && y<o->h; y++) {
|
||||
p=(Uint8 *)pix+srcPitch*y;
|
||||
|
@ -3215,7 +3215,7 @@ inline void ConvertRGBtoYV12(SDL_Overlay *o)
|
|||
p+=4;//s->format->BytesPerPixel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SDL_UnlockYUVOverlay(o);
|
||||
}
|
||||
|
||||
|
@ -3224,16 +3224,16 @@ inline void ConvertRGBtoIYUV(SDL_Overlay *o)
|
|||
int x,y;
|
||||
int yuv[3];
|
||||
Uint8 *p,*op[3];
|
||||
|
||||
|
||||
SDL_LockYUVOverlay(o);
|
||||
|
||||
|
||||
/* Black initialization */
|
||||
/*
|
||||
memset(o->pixels[0],0,o->pitches[0]*o->h);
|
||||
memset(o->pixels[1],128,o->pitches[1]*((o->h+1)/2));
|
||||
memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
|
||||
*/
|
||||
|
||||
|
||||
/* Convert */
|
||||
for(y=0; y<160 && y<o->h; y++) {
|
||||
p=(Uint8 *)pix+srcPitch*y;
|
||||
|
@ -3250,7 +3250,7 @@ inline void ConvertRGBtoIYUV(SDL_Overlay *o)
|
|||
p+=4; //s->format->BytesPerPixel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SDL_UnlockYUVOverlay(o);
|
||||
}
|
||||
|
||||
|
@ -3259,9 +3259,9 @@ inline void ConvertRGBtoUYVY(SDL_Overlay *o)
|
|||
int x,y;
|
||||
int yuv[3];
|
||||
Uint8 *p,*op;
|
||||
|
||||
|
||||
SDL_LockYUVOverlay(o);
|
||||
|
||||
|
||||
for(y=0; y<160 && y<o->h; y++) {
|
||||
p=(Uint8 *)pix+srcPitch*y;
|
||||
op=o->pixels[0]+o->pitches[0]*y;
|
||||
|
@ -3273,11 +3273,11 @@ inline void ConvertRGBtoUYVY(SDL_Overlay *o)
|
|||
*(op++)=yuv[2];
|
||||
} else
|
||||
*(op++)=yuv[0];
|
||||
|
||||
|
||||
p+=4; //s->format->BytesPerPixel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SDL_UnlockYUVOverlay(o);
|
||||
}
|
||||
|
||||
|
@ -3286,9 +3286,9 @@ inline void ConvertRGBtoYVYU(SDL_Overlay *o)
|
|||
int x,y;
|
||||
int yuv[3];
|
||||
Uint8 *p,*op;
|
||||
|
||||
|
||||
SDL_LockYUVOverlay(o);
|
||||
|
||||
|
||||
for(y=0; y<160 && y<o->h; y++) {
|
||||
p=(Uint8 *)pix+srcPitch*y;
|
||||
op=o->pixels[0]+o->pitches[0]*y;
|
||||
|
@ -3302,11 +3302,11 @@ inline void ConvertRGBtoYVYU(SDL_Overlay *o)
|
|||
*op=yuv[0];
|
||||
op+=2;
|
||||
}
|
||||
|
||||
|
||||
p+=4; //s->format->BytesPerPixel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SDL_UnlockYUVOverlay(o);
|
||||
}
|
||||
|
||||
|
@ -3315,9 +3315,9 @@ inline void ConvertRGBtoYUY2(SDL_Overlay *o)
|
|||
int x,y;
|
||||
int yuv[3];
|
||||
Uint8 *p,*op;
|
||||
|
||||
|
||||
SDL_LockYUVOverlay(o);
|
||||
|
||||
|
||||
for(y=0; y<160 && y<o->h; y++) {
|
||||
p=(Uint8 *)pix+srcPitch*y;
|
||||
op=o->pixels[0]+o->pitches[0]*y;
|
||||
|
@ -3331,11 +3331,11 @@ inline void ConvertRGBtoYUY2(SDL_Overlay *o)
|
|||
*op=yuv[0];
|
||||
op+=2;
|
||||
}
|
||||
|
||||
|
||||
p+=4; //s->format->BytesPerPixel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SDL_UnlockYUVOverlay(o);
|
||||
}
|
||||
|
||||
|
@ -3362,16 +3362,16 @@ inline void Convert32bit(SDL_Surface *display)
|
|||
exit(1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline void Draw_Overlay(SDL_Surface *display, int size)
|
||||
{
|
||||
SDL_LockYUVOverlay(overlay);
|
||||
|
||||
|
||||
Convert32bit(display);
|
||||
|
||||
|
||||
overlay_rect.x = 0;
|
||||
overlay_rect.y = 0;
|
||||
overlay_rect.w = GBA_WIDTH * size;
|
||||
|
@ -3391,10 +3391,10 @@ void systemGbBorderOn()
|
|||
|
||||
destWidth = (sizeOption+1)*srcWidth;
|
||||
destHeight = (sizeOption+1)*srcHeight;
|
||||
|
||||
|
||||
surface = SDL_SetVideoMode(destWidth, destHeight, 16,
|
||||
SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF|
|
||||
(fullscreen ? SDL_FULLSCREEN : 0));
|
||||
(fullscreen ? SDL_FULLSCREEN : 0));
|
||||
#ifndef C_CORE
|
||||
sdlMakeStretcher(srcWidth);
|
||||
#else
|
||||
|
@ -3420,19 +3420,19 @@ void systemGbBorderOn()
|
|||
RGB_LOW_BITS_MASK = 0x821;
|
||||
} else {
|
||||
Init_2xSaI(555);
|
||||
RGB_LOW_BITS_MASK = 0x421;
|
||||
RGB_LOW_BITS_MASK = 0x421;
|
||||
}
|
||||
if(cartridgeType == 2) {
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap16[i] = (((i >> 1) & 0x1f) << systemBlueShift) |
|
||||
(((i & 0x7c0) >> 6) << systemGreenShift) |
|
||||
(((i & 0xf800) >> 11) << systemRedShift);
|
||||
}
|
||||
(((i & 0xf800) >> 11) << systemRedShift);
|
||||
}
|
||||
} else {
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
}
|
||||
srcPitch = srcWidth * 2+4;
|
||||
|
@ -3446,7 +3446,7 @@ void systemGbBorderOn()
|
|||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if(systemColorDepth == 32)
|
||||
srcPitch = srcWidth*4 + 4;
|
||||
|
|
|
@ -220,11 +220,11 @@ static void debuggerPrefetch()
|
|||
static void debuggerApplyBreakpoint(u32 address, int num, int size)
|
||||
{
|
||||
if(size)
|
||||
debuggerWriteMemory(address, (u32)(0xe1200070 |
|
||||
(num & 0xf) |
|
||||
debuggerWriteMemory(address, (u32)(0xe1200070 |
|
||||
(num & 0xf) |
|
||||
((num<<4)&0xf0)));
|
||||
else
|
||||
debuggerWriteHalfWord(address,
|
||||
debuggerWriteHalfWord(address,
|
||||
(u16)(0xbe00 | num));
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ static void debuggerDisableBreakpoints()
|
|||
debuggerBreakpointList[i].value);
|
||||
else
|
||||
debuggerWriteHalfWord(debuggerBreakpointList[i].address,
|
||||
debuggerBreakpointList[i].value);
|
||||
debuggerBreakpointList[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ static void debuggerEnableBreakpoints(bool skipPC)
|
|||
debuggerApplyBreakpoint(debuggerBreakpointList[i].address,
|
||||
i,
|
||||
debuggerBreakpointList[i].size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void debuggerUsage(const char *cmd)
|
||||
|
@ -257,8 +257,8 @@ static void debuggerUsage(const char *cmd)
|
|||
for(int i = 0; ; i++) {
|
||||
if(debuggerCommands[i].name) {
|
||||
if(!strcmp(debuggerCommands[i].name, cmd)) {
|
||||
printf("%s %s\n\n%s\n",
|
||||
debuggerCommands[i].name,
|
||||
printf("%s %s\n\n%s\n",
|
||||
debuggerCommands[i].name,
|
||||
debuggerCommands[i].syntax ? debuggerCommands[i].syntax : "",
|
||||
debuggerCommands[i].help);
|
||||
break;
|
||||
|
@ -267,7 +267,7 @@ static void debuggerUsage(const char *cmd)
|
|||
printf("Unrecognized command '%s'.", cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void debuggerPrintBaseType(Type *t, u32 value, u32 location,
|
||||
|
@ -325,7 +325,7 @@ static void debuggerPrintBaseType(Type *t, u32 value, u32 location,
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch(t->encoding) {
|
||||
case DW_ATE_boolean:
|
||||
if(value)
|
||||
|
@ -367,9 +367,9 @@ static void debuggerPrintBaseType(Type *t, u32 value, u32 location,
|
|||
|
||||
static const char *debuggerPrintType(Type *t)
|
||||
{
|
||||
char buffer[1024];
|
||||
char buffer[1024];
|
||||
static char buffer2[1024];
|
||||
|
||||
|
||||
if(t->type == TYPE_pointer) {
|
||||
if(t->pointer)
|
||||
strcpy(buffer, debuggerPrintType(t->pointer));
|
||||
|
@ -380,7 +380,7 @@ static const char *debuggerPrintType(Type *t)
|
|||
} else if(t->type == TYPE_reference) {
|
||||
strcpy(buffer, debuggerPrintType(t->pointer));
|
||||
sprintf(buffer2, "%s &", buffer);
|
||||
return buffer2;
|
||||
return buffer2;
|
||||
}
|
||||
return t->name;
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ static void debuggerPrintMember(Function *f,
|
|||
v = debuggerReadHalfWord(location);
|
||||
else if(size == 4)
|
||||
v = debuggerReadMemory(location);
|
||||
|
||||
|
||||
while(bitSize) {
|
||||
int top = size*8 - off;
|
||||
int bot = top - bitSize;
|
||||
|
@ -467,7 +467,7 @@ static void debuggerPrintMember(Function *f,
|
|||
} else {
|
||||
debuggerPrintValueInternal(f, m->type, m->location, m->bitSize,
|
||||
m->bitOffset, objLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void debuggerPrintStructure(Function *f, Type *t, u32 objLocation)
|
||||
|
@ -555,14 +555,14 @@ static void debuggerPrintValueInternal(Function *f, Type *t,
|
|||
default:
|
||||
printf("%08x", value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void debuggerPrintValueInternal(Function *f, Type *t, ELFBlock *loc,
|
||||
int bitSize, int bitOffset,
|
||||
int bitSize, int bitOffset,
|
||||
u32 objLocation)
|
||||
{
|
||||
LocationType type;
|
||||
LocationType type;
|
||||
u32 location;
|
||||
if(loc) {
|
||||
if(objLocation)
|
||||
|
@ -580,7 +580,7 @@ static void debuggerPrintValueInternal(Function *f, Type *t, ELFBlock *loc,
|
|||
static void debuggerPrintValue(Function *f, Object *o)
|
||||
{
|
||||
debuggerPrintValueInternal(f, o->type, o->location, 0, 0, 0);
|
||||
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
@ -593,7 +593,7 @@ static void debuggerSymbols(int argc, char **argv)
|
|||
bool match = false;
|
||||
int matchSize = 0;
|
||||
const char *matchStr = NULL;
|
||||
|
||||
|
||||
if(argc == 2) {
|
||||
match = true;
|
||||
matchSize = strlen(argv[1]);
|
||||
|
@ -665,7 +665,7 @@ static void debuggerPrint(int argc, char **argv)
|
|||
u32 pc = armNextPC;
|
||||
Function *f = NULL;
|
||||
CompileUnit *u = NULL;
|
||||
|
||||
|
||||
elfGetCurrentFunction(pc,
|
||||
&f, &u);
|
||||
|
||||
|
@ -686,8 +686,8 @@ static void debuggerPrint(int argc, char **argv)
|
|||
printf("Unknown option %s\n", argv[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const char *s = argc == 2 ? argv[1] : argv[2];
|
||||
|
||||
extern const char *exprString;
|
||||
|
@ -748,7 +748,7 @@ static void debuggerDebug(int n, char **args)
|
|||
systemDebug = v;
|
||||
printf("Debug level set to %d\n", systemDebug);
|
||||
} else
|
||||
debuggerUsage("trace");
|
||||
debuggerUsage("trace");
|
||||
}
|
||||
|
||||
static void debuggerVerbose(int n, char **args)
|
||||
|
@ -759,7 +759,7 @@ static void debuggerVerbose(int n, char **args)
|
|||
systemVerbose = v;
|
||||
printf("Verbose level set to %d\n", systemVerbose);
|
||||
} else
|
||||
debuggerUsage("verbose");
|
||||
debuggerUsage("verbose");
|
||||
}
|
||||
|
||||
static void debuggerWhere(int n, char **args)
|
||||
|
@ -791,11 +791,11 @@ static void debuggerLocals(int n, char **args)
|
|||
printf("%s=", o->name);
|
||||
debuggerPrintValue(f, o);
|
||||
}
|
||||
o = o->next;
|
||||
o = o->next;
|
||||
}
|
||||
} else {
|
||||
printf("No information for current address\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void debuggerNext(int n, char **args)
|
||||
|
@ -820,7 +820,7 @@ static void debuggerNext(int n, char **args)
|
|||
if(elfGetCurrentFunction(a, &f, &u)) {
|
||||
const char *file;
|
||||
int line = elfFindLine(u, f, a, &file);
|
||||
|
||||
|
||||
printf("File %s, function %s, line %d\n", file, f->name,
|
||||
line);
|
||||
}
|
||||
|
@ -864,7 +864,7 @@ static void debuggerContinue(int n, char **args)
|
|||
|
||||
Function *f = NULL;
|
||||
CompileUnit *u = NULL;
|
||||
|
||||
|
||||
if(elfGetCurrentFunction(armNextPC, &f, &u)) {
|
||||
const char *file;
|
||||
int line = elfFindLine(u,f,armNextPC,&file);
|
||||
|
@ -900,11 +900,11 @@ static void debuggerBreakDelete(int n, char **args)
|
|||
n++;
|
||||
if(n < debuggerNumOfBreakpoints) {
|
||||
for(int i = n; i < debuggerNumOfBreakpoints; i++) {
|
||||
debuggerBreakpointList[i-1].address =
|
||||
debuggerBreakpointList[i-1].address =
|
||||
debuggerBreakpointList[i].address;
|
||||
debuggerBreakpointList[i-1].value =
|
||||
debuggerBreakpointList[i-1].value =
|
||||
debuggerBreakpointList[i].value;
|
||||
debuggerBreakpointList[i-1].size =
|
||||
debuggerBreakpointList[i-1].size =
|
||||
debuggerBreakpointList[i].size;
|
||||
}
|
||||
}
|
||||
|
@ -913,7 +913,7 @@ static void debuggerBreakDelete(int n, char **args)
|
|||
else
|
||||
printf("No breakpoints are set\n");
|
||||
} else
|
||||
debuggerUsage("bd");
|
||||
debuggerUsage("bd");
|
||||
}
|
||||
|
||||
static void debuggerBreak(int n, char **args)
|
||||
|
@ -933,7 +933,7 @@ static void debuggerBreak(int n, char **args)
|
|||
u32 addr;
|
||||
Function *f;
|
||||
CompileUnit *u;
|
||||
|
||||
|
||||
if(elfFindLineInModule(&addr, name, line)) {
|
||||
if(elfGetCurrentFunction(addr, &f, &u)) {
|
||||
u32 addr2;
|
||||
|
@ -956,7 +956,7 @@ static void debuggerBreak(int n, char **args)
|
|||
Function *f;
|
||||
CompileUnit *u;
|
||||
u32 addr;
|
||||
|
||||
|
||||
if(elfGetCurrentFunction(armNextPC, &f, &u)) {
|
||||
if(elfFindLineInUnit(&addr, u, line)) {
|
||||
if(elfGetCurrentFunction(addr, &f, &u)) {
|
||||
|
@ -997,14 +997,14 @@ static void debuggerBreak(int n, char **args)
|
|||
// debuggerApplyBreakpoint(address, i, size);
|
||||
debuggerNumOfBreakpoints++;
|
||||
if(size)
|
||||
printf("Added ARM breakpoint at %08x\n", address);
|
||||
printf("Added ARM breakpoint at %08x\n", address);
|
||||
else
|
||||
printf("Added THUMB breakpoint at %08x\n", address);
|
||||
} else {
|
||||
printf("%s is not a function symbol\n", args[1]);
|
||||
printf("%s is not a function symbol\n", args[1]);
|
||||
}
|
||||
} else
|
||||
debuggerUsage("break");
|
||||
debuggerUsage("break");
|
||||
}
|
||||
|
||||
static void debuggerBreakThumb(int n, char **args)
|
||||
|
@ -1020,7 +1020,7 @@ static void debuggerBreakThumb(int n, char **args)
|
|||
debuggerNumOfBreakpoints++;
|
||||
printf("Added THUMB breakpoint at %08x\n", address);
|
||||
} else
|
||||
debuggerUsage("bt");
|
||||
debuggerUsage("bt");
|
||||
}
|
||||
|
||||
static void debuggerBreakArm(int n, char **args)
|
||||
|
@ -1039,7 +1039,7 @@ static void debuggerBreakArm(int n, char **args)
|
|||
debuggerUsage("ba");
|
||||
}
|
||||
|
||||
/*extern*/ void debuggerBreakOnWrite(u32 address, u32 oldvalue, u32 value,
|
||||
/*extern*/ void debuggerBreakOnWrite(u32 address, u32 oldvalue, u32 value,
|
||||
int size, int t)
|
||||
{
|
||||
const char *type = "write";
|
||||
|
@ -1047,13 +1047,13 @@ static void debuggerBreakArm(int n, char **args)
|
|||
type = "change";
|
||||
|
||||
if(size == 2)
|
||||
printf("Breakpoint (on %s) address %08x old:%08x new:%08x\n",
|
||||
printf("Breakpoint (on %s) address %08x old:%08x new:%08x\n",
|
||||
type, address, oldvalue, value);
|
||||
else if(size == 1)
|
||||
printf("Breakpoint (on %s) address %08x old:%04x new:%04x\n",
|
||||
printf("Breakpoint (on %s) address %08x old:%04x new:%04x\n",
|
||||
type, address, (u16)oldvalue,(u16)value);
|
||||
else
|
||||
printf("Breakpoint (on %s) address %08x old:%02x new:%02x\n",
|
||||
printf("Breakpoint (on %s) address %08x old:%02x new:%02x\n",
|
||||
type, address, (u8)oldvalue, (u8)value);
|
||||
debugger = true;
|
||||
}
|
||||
|
@ -1070,12 +1070,12 @@ static void debuggerBreakWriteClear(int n, char **args)
|
|||
(address >= 0x03000000 && address < 0x03008000) ||
|
||||
(address >= 0x05000000 && address < 0x05000400) ||
|
||||
(address >= 0x06000000 && address < 0x06018000) ||
|
||||
(address >= 0x07000000 && address < 0x07000400))) {
|
||||
(address >= 0x07000000 && address < 0x07000400))) {
|
||||
printf("Invalid address: %08x\n", address);
|
||||
return;
|
||||
}
|
||||
|
||||
u32 final = address + n;
|
||||
|
||||
u32 final = address + n;
|
||||
switch(address >> 24) {
|
||||
case 2:
|
||||
{
|
||||
|
@ -1173,12 +1173,12 @@ static void debuggerBreakWrite(int n, char **args)
|
|||
sscanf(args[1], "%x", &address);
|
||||
int n = 0;
|
||||
sscanf(args[2], "%d", &n);
|
||||
|
||||
|
||||
if (! ((address >= 0x02000000 && address < 0x02040000) ||
|
||||
(address >= 0x03000000 && address < 0x03008000) ||
|
||||
(address >= 0x05000000 && address < 0x05000400) ||
|
||||
(address >= 0x06000000 && address < 0x06018000) ||
|
||||
(address >= 0x07000000 && address < 0x07000400))) {
|
||||
(address >= 0x07000000 && address < 0x07000400))) {
|
||||
printf("Invalid address: %08x\n", address);
|
||||
return;
|
||||
}
|
||||
|
@ -1227,9 +1227,9 @@ static void debuggerBreakWrite(int n, char **args)
|
|||
freezeOAM[(address + i) & 0x3ff] = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
} else
|
||||
debuggerUsage("bpw");
|
||||
debuggerUsage("bpw");
|
||||
}
|
||||
|
||||
static void debuggerBreakChangeClear(int n, char **args)
|
||||
|
@ -1239,17 +1239,17 @@ static void debuggerBreakChangeClear(int n, char **args)
|
|||
sscanf(args[1], "%x", &address);
|
||||
int n = 0;
|
||||
sscanf(args[2], "%d", &n);
|
||||
|
||||
|
||||
if (! ((address >= 0x02000000 && address < 0x02040000) ||
|
||||
(address >= 0x03000000 && address < 0x03008000) ||
|
||||
(address >= 0x05000000 && address < 0x05000400) ||
|
||||
(address >= 0x06000000 && address < 0x06018000) ||
|
||||
(address >= 0x07000000 && address < 0x07000400))) {
|
||||
(address >= 0x07000000 && address < 0x07000400))) {
|
||||
printf("Invalid address: %08x\n", address);
|
||||
return;
|
||||
}
|
||||
|
||||
u32 final = address + n;
|
||||
|
||||
u32 final = address + n;
|
||||
switch(address >> 24) {
|
||||
case 2:
|
||||
{
|
||||
|
@ -1329,7 +1329,7 @@ static void debuggerBreakChangeClear(int n, char **args)
|
|||
for(i = 0; i < 0x400; i++)
|
||||
if(freezeOAM[i] == 2)
|
||||
freezeOAM[i] = 0;
|
||||
|
||||
|
||||
printf("Cleared all break on change\n");
|
||||
} else
|
||||
debuggerUsage("bpcc");
|
||||
|
@ -1346,12 +1346,12 @@ static void debuggerBreakChange(int n, char **args)
|
|||
sscanf(args[1], "%x", &address);
|
||||
int n = 0;
|
||||
sscanf(args[2], "%d", &n);
|
||||
|
||||
|
||||
if (! ((address >= 0x02000000 && address < 0x02040000) ||
|
||||
(address >= 0x03000000 && address < 0x03008000) ||
|
||||
(address >= 0x05000000 && address < 0x05000400) ||
|
||||
(address >= 0x06000000 && address < 0x06018000) ||
|
||||
(address >= 0x07000000 && address < 0x07000400))) {
|
||||
(address >= 0x07000000 && address < 0x07000400))) {
|
||||
printf("Invalid address: %08x\n", address);
|
||||
return;
|
||||
}
|
||||
|
@ -1372,7 +1372,7 @@ static void debuggerBreakChange(int n, char **args)
|
|||
return;
|
||||
}
|
||||
printf("Added break on change at %08x for %d bytes\n", address, n);
|
||||
|
||||
|
||||
switch(address >> 24) {
|
||||
case 2:
|
||||
for (int i = 0; i < n; i++)
|
||||
|
@ -1431,8 +1431,8 @@ static void debuggerDisassembleThumb(FILE *f, u32 pc, int count)
|
|||
if(l > len)
|
||||
len = l;
|
||||
}
|
||||
sprintf(format, "%%08x %%-%ds %%s\n", len);
|
||||
|
||||
sprintf(format, "%%08x %%-%ds %%s\n", len);
|
||||
|
||||
for(i = 0; i < count; i++) {
|
||||
u32 addr = pc;
|
||||
pc += disThumb(pc, buffer, 2);
|
||||
|
@ -1455,7 +1455,7 @@ static void debuggerDisassembleArm(int n, char **args)
|
|||
if(n >= 3) {
|
||||
sscanf(args[2], "%d", &count);
|
||||
}
|
||||
debuggerDisassembleArm(stdout, pc, count);
|
||||
debuggerDisassembleArm(stdout, pc, count);
|
||||
}
|
||||
|
||||
static void debuggerDisassembleThumb(int n, char **args)
|
||||
|
@ -1508,7 +1508,7 @@ static void debuggerFileDisassembleArm(int n, char **args)
|
|||
if(n >= 4) {
|
||||
sscanf(args[3], "%d", &count);
|
||||
}
|
||||
debuggerDisassembleArm(f, pc, count);
|
||||
debuggerDisassembleArm(f, pc, count);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
@ -1526,7 +1526,7 @@ static void debuggerFileDisassembleThumb(int n, char **args)
|
|||
printf("Error: cannot open file %s\n", args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(n >= 3) {
|
||||
sscanf(args[2], "%x", &pc);
|
||||
}
|
||||
|
@ -1547,7 +1547,7 @@ void debuggerFindText(int n, char **args)
|
|||
{
|
||||
SearchResults = 0;
|
||||
sscanf(args[1], "%x", &SearchStart);
|
||||
|
||||
|
||||
if (n == 4)
|
||||
{
|
||||
sscanf(args[2], "%u", &SearchMaxMatches);
|
||||
|
@ -1567,7 +1567,7 @@ void debuggerFindText(int n, char **args)
|
|||
};
|
||||
|
||||
debuggerDoSearch ();
|
||||
|
||||
|
||||
} else
|
||||
debuggerUsage("ft");
|
||||
};
|
||||
|
@ -1578,7 +1578,7 @@ void debuggerFindHex(int n, char **args)
|
|||
{
|
||||
SearchResults = 0;
|
||||
sscanf(args[1], "%x", &SearchStart);
|
||||
|
||||
|
||||
char SearchHex [128];
|
||||
if (n == 4)
|
||||
{
|
||||
|
@ -1609,9 +1609,9 @@ void debuggerFindHex(int n, char **args)
|
|||
sscanf (&SearchHex [i << 1], "%02x", &cbuf);
|
||||
SearchData [i] = cbuf;
|
||||
};
|
||||
|
||||
|
||||
debuggerDoSearch ();
|
||||
|
||||
|
||||
} else
|
||||
debuggerUsage("fh");
|
||||
};
|
||||
|
@ -1626,10 +1626,10 @@ void debuggerFindResume(int n, char **args)
|
|||
debuggerUsage("fr");
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
if (n == 2)
|
||||
sscanf(args[1], "%u", &SearchMaxMatches);
|
||||
|
||||
|
||||
debuggerDoSearch();
|
||||
|
||||
} else
|
||||
|
@ -1857,16 +1857,16 @@ static void debuggerIoDMA()
|
|||
{
|
||||
printf("DM0SAD = %08x\n", (DM0SAD_H<<16)|DM0SAD_L);
|
||||
printf("DM0DAD = %08x\n", (DM0DAD_H<<16)|DM0DAD_L);
|
||||
printf("DM0CNT = %08x\n", (DM0CNT_H<<16)|DM0CNT_L);
|
||||
printf("DM0CNT = %08x\n", (DM0CNT_H<<16)|DM0CNT_L);
|
||||
printf("DM1SAD = %08x\n", (DM1SAD_H<<16)|DM1SAD_L);
|
||||
printf("DM1DAD = %08x\n", (DM1DAD_H<<16)|DM1DAD_L);
|
||||
printf("DM1CNT = %08x\n", (DM1CNT_H<<16)|DM1CNT_L);
|
||||
printf("DM1CNT = %08x\n", (DM1CNT_H<<16)|DM1CNT_L);
|
||||
printf("DM2SAD = %08x\n", (DM2SAD_H<<16)|DM2SAD_L);
|
||||
printf("DM2DAD = %08x\n", (DM2DAD_H<<16)|DM2DAD_L);
|
||||
printf("DM2CNT = %08x\n", (DM2CNT_H<<16)|DM2CNT_L);
|
||||
printf("DM2CNT = %08x\n", (DM2CNT_H<<16)|DM2CNT_L);
|
||||
printf("DM3SAD = %08x\n", (DM3SAD_H<<16)|DM3SAD_L);
|
||||
printf("DM3DAD = %08x\n", (DM3DAD_H<<16)|DM3DAD_L);
|
||||
printf("DM3CNT = %08x\n", (DM3CNT_H<<16)|DM3CNT_L);
|
||||
printf("DM3CNT = %08x\n", (DM3CNT_H<<16)|DM3CNT_L);
|
||||
}
|
||||
|
||||
static void debuggerIoTimer()
|
||||
|
@ -1883,7 +1883,7 @@ static void debuggerIoTimer()
|
|||
|
||||
static void debuggerIoMisc()
|
||||
{
|
||||
printf("P1 = %04x\n", P1);
|
||||
printf("P1 = %04x\n", P1);
|
||||
printf("IE = %04x\n", IE);
|
||||
printf("IF = %04x\n", IF);
|
||||
printf("IME = %04x\n", IME);
|
||||
|
@ -1917,7 +1917,7 @@ static void debuggerEditByte(int n, char **args)
|
|||
sscanf(args[2], "%x", &byte);
|
||||
debuggerWriteByte(address, (u8)byte);
|
||||
} else
|
||||
debuggerUsage("eb");
|
||||
debuggerUsage("eb");
|
||||
}
|
||||
|
||||
static void debuggerEditHalfWord(int n, char **args)
|
||||
|
@ -1933,7 +1933,7 @@ static void debuggerEditHalfWord(int n, char **args)
|
|||
sscanf(args[2], "%x", &HalfWord);
|
||||
debuggerWriteHalfWord(address, (u16)HalfWord);
|
||||
} else
|
||||
debuggerUsage("eh");
|
||||
debuggerUsage("eh");
|
||||
}
|
||||
|
||||
static void debuggerEditRegister(int n, char **args)
|
||||
|
@ -1951,7 +1951,7 @@ static void debuggerEditRegister(int n, char **args)
|
|||
reg[r].I=val;
|
||||
printf("Register changed.\n");
|
||||
} else
|
||||
debuggerUsage("er");
|
||||
debuggerUsage("er");
|
||||
}
|
||||
|
||||
static void debuggerEdit(int n, char **args)
|
||||
|
@ -1967,7 +1967,7 @@ static void debuggerEdit(int n, char **args)
|
|||
sscanf(args[2], "%x", &byte);
|
||||
debuggerWriteMemory(address, (u32)byte);
|
||||
} else
|
||||
debuggerUsage("ew");
|
||||
debuggerUsage("ew");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1995,7 +1995,7 @@ static void debuggerMemoryByte(int n, char **args)
|
|||
int n = debuggerReadByte(addr+13);
|
||||
int o = debuggerReadByte(addr+14);
|
||||
int p = debuggerReadByte(addr+15);
|
||||
|
||||
|
||||
printf("%08x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
|
||||
addr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,
|
||||
ASCII(a),ASCII(b),ASCII(c),ASCII(d),
|
||||
|
@ -2005,7 +2005,7 @@ static void debuggerMemoryByte(int n, char **args)
|
|||
addr += 16;
|
||||
}
|
||||
} else
|
||||
debuggerUsage("mb");
|
||||
debuggerUsage("mb");
|
||||
}
|
||||
|
||||
static void debuggerMemoryHalfWord(int n, char **args)
|
||||
|
@ -2031,7 +2031,7 @@ static void debuggerMemoryHalfWord(int n, char **args)
|
|||
int n = debuggerReadByte(addr+13);
|
||||
int o = debuggerReadByte(addr+14);
|
||||
int p = debuggerReadByte(addr+15);
|
||||
|
||||
|
||||
printf("%08x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
|
||||
addr,b,a,d,c,f,e,h,g,j,i,l,k,n,m,p,o,
|
||||
ASCII(a),ASCII(b),ASCII(c),ASCII(d),
|
||||
|
@ -2041,7 +2041,7 @@ static void debuggerMemoryHalfWord(int n, char **args)
|
|||
addr += 16;
|
||||
}
|
||||
} else
|
||||
debuggerUsage("mh");
|
||||
debuggerUsage("mh");
|
||||
}
|
||||
|
||||
static void debuggerMemory(int n, char **args)
|
||||
|
@ -2070,7 +2070,7 @@ static void debuggerMemory(int n, char **args)
|
|||
int n = debuggerReadByte(addr+13);
|
||||
int o = debuggerReadByte(addr+14);
|
||||
int p = debuggerReadByte(addr+15);
|
||||
|
||||
|
||||
printf("%08x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
|
||||
addr,d,c,b,a,h,g,f,e,l,k,j,i,p,o,n,m,
|
||||
ASCII(a),ASCII(b),ASCII(c),ASCII(d),
|
||||
|
@ -2080,7 +2080,7 @@ static void debuggerMemory(int n, char **args)
|
|||
addr += 16;
|
||||
}
|
||||
} else
|
||||
debuggerUsage("mw");
|
||||
debuggerUsage("mw");
|
||||
}
|
||||
|
||||
static void debuggerQuit(int, char **)
|
||||
|
@ -2088,7 +2088,7 @@ static void debuggerQuit(int, char **)
|
|||
char buffer[10];
|
||||
printf("Are you sure you want to quit (y/n)? ");
|
||||
fgets(buffer, 1024, stdin);
|
||||
|
||||
|
||||
if(buffer[0] == 'y' || buffer[0] == 'Y') {
|
||||
debugger = false;
|
||||
emulating = false;
|
||||
|
@ -2131,22 +2131,22 @@ static void debuggerDumpLoad(int n, char** args)
|
|||
const char *file;
|
||||
FILE *f;
|
||||
int c;
|
||||
|
||||
|
||||
if(n==3) {
|
||||
file=args[1];
|
||||
|
||||
|
||||
sscanf(args[2],"%x",&address);
|
||||
|
||||
|
||||
f=fopen(file,"rb");
|
||||
if(!f) {
|
||||
printf("Error opening file.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
fseek(f,0,SEEK_END);
|
||||
int size=ftell(f);
|
||||
fseek(f,0,SEEK_SET);
|
||||
|
||||
|
||||
for(int i=0;i<size;i++) {
|
||||
c = fgetc(f);
|
||||
if(c == -1)
|
||||
|
@ -2166,23 +2166,23 @@ static void debuggerDumpSave(int n, char** args)
|
|||
u32 size = 0;
|
||||
const char *file;
|
||||
FILE *f;
|
||||
|
||||
|
||||
if(n==4) {
|
||||
file=args[1];
|
||||
sscanf(args[2],"%x",&address);
|
||||
sscanf(args[3],"%x",&size);
|
||||
|
||||
|
||||
f=fopen(file,"wb");
|
||||
if(!f) {
|
||||
printf("Error opening file.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for(u32 i = 0; i < size; i++) {
|
||||
fputc(debuggerReadByte(address), f);
|
||||
address++;
|
||||
}
|
||||
|
||||
|
||||
fclose(f);
|
||||
} else
|
||||
debuggerUsage("dsave");
|
||||
|
@ -2192,14 +2192,14 @@ static void debuggerCondBreakThumb(int n, char **args)
|
|||
{
|
||||
if(n > 4) { //conditional args handled separately
|
||||
int i = debuggerNumOfBreakpoints;
|
||||
|
||||
|
||||
u32 address = 0;
|
||||
sscanf(args[1],"%x", &address);
|
||||
|
||||
|
||||
debuggerBreakpointList[i].address = address;
|
||||
debuggerBreakpointList[i].value = debuggerReadHalfWord(address);
|
||||
debuggerBreakpointList[i].size = 0;
|
||||
|
||||
|
||||
debuggerCondValidate(n, args,2);
|
||||
} else
|
||||
debuggerUsage("cbt");
|
||||
|
@ -2209,10 +2209,10 @@ static void debuggerCondBreakThumb(int n, char **args)
|
|||
static void debuggerCondBreakArm(int n, char **args)
|
||||
{
|
||||
if(n > 4) { //conditional args handled separately
|
||||
|
||||
|
||||
int i = debuggerNumOfBreakpoints;
|
||||
u32 address = 0;
|
||||
|
||||
|
||||
sscanf(args[1],"%x", &address);
|
||||
debuggerBreakpointList[i].address = address;
|
||||
debuggerBreakpointList[i].value = debuggerReadMemory(address);
|
||||
|
@ -2230,29 +2230,29 @@ static void debuggerCondValidate(int n, char **args,int start)
|
|||
2: value
|
||||
3: size
|
||||
*/
|
||||
|
||||
|
||||
int i=debuggerNumOfBreakpoints;
|
||||
|
||||
|
||||
char *address=args[start];
|
||||
const char *op=args[start+1];
|
||||
char *value=args[start+2];
|
||||
const char *tsize,*taddress,*tvalue;
|
||||
|
||||
int rel=0;
|
||||
|
||||
|
||||
u32 value1=0;
|
||||
u32 value2=0;
|
||||
|
||||
|
||||
char size=0;
|
||||
int j=1;
|
||||
|
||||
|
||||
if(n==6) {
|
||||
size = args[start+3][0];
|
||||
if(size != 'b' && size != 'h' && size != 'w') {
|
||||
printf("Invalid size.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch(size) {
|
||||
case 'b':
|
||||
debuggerBreakpointList[i].cond_size=1;
|
||||
|
@ -2276,7 +2276,7 @@ static void debuggerCondValidate(int n, char **args,int start)
|
|||
j++;
|
||||
}
|
||||
address[j-1]=0;
|
||||
|
||||
|
||||
sscanf(address,"%x",&value1);
|
||||
switch(size) {
|
||||
case 'h':
|
||||
|
@ -2307,7 +2307,7 @@ static void debuggerCondValidate(int n, char **args,int start)
|
|||
}
|
||||
address[j-1]=0;
|
||||
sscanf(address,"%d",&value1);
|
||||
|
||||
|
||||
if(value1 > 16) {
|
||||
printf("Invalid Register.\n");
|
||||
return;
|
||||
|
@ -2324,12 +2324,12 @@ static void debuggerCondValidate(int n, char **args,int start)
|
|||
|
||||
debuggerBreakpointList[i].cond_address = value1;
|
||||
|
||||
// Check op
|
||||
// Check op
|
||||
switch(op[0]) {
|
||||
case '=': // 1
|
||||
if (op[1] == '=' && op[2]==0)
|
||||
rel=1;
|
||||
else
|
||||
else
|
||||
goto error;
|
||||
break;
|
||||
case '!': //2
|
||||
|
@ -2359,7 +2359,7 @@ static void debuggerCondValidate(int n, char **args,int start)
|
|||
printf("Invalid comparison operator.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(op==0) {
|
||||
printf("Invalid comparison operator.\n");
|
||||
return;
|
||||
|
@ -2404,7 +2404,7 @@ static void debuggerCondValidate(int n, char **args,int start)
|
|||
}
|
||||
value[j-1]=0;
|
||||
sscanf(value,"%d",&value2);
|
||||
|
||||
|
||||
if(value2 > 16) {
|
||||
printf("Invalid Register.\n");
|
||||
return;
|
||||
|
@ -2416,7 +2416,7 @@ static void debuggerCondValidate(int n, char **args,int start)
|
|||
sscanf(value, "%x",&value2);
|
||||
debuggerBreakpointList[i].ia2=false;
|
||||
tvalue="0x";
|
||||
|
||||
|
||||
switch(size) {
|
||||
case 'b':
|
||||
value2 &=0xFF;
|
||||
|
@ -2431,10 +2431,10 @@ static void debuggerCondValidate(int n, char **args,int start)
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
debuggerBreakpointList[i].cond_value = value2;
|
||||
debuggerNumOfBreakpoints++;
|
||||
|
||||
|
||||
// At here, everything's set. Display message.
|
||||
switch(size) {
|
||||
case 0:
|
||||
|
@ -2477,13 +2477,13 @@ static bool debuggerCondEvaluate(int num)
|
|||
// check if there is a condition
|
||||
if(debuggerBreakpointList[num].cond_rel == 0)
|
||||
return true;
|
||||
|
||||
|
||||
u32 address=debuggerBreakpointList[num].cond_address;
|
||||
char size=debuggerBreakpointList[num].cond_size;
|
||||
u32 value=debuggerBreakpointList[num].cond_value;
|
||||
u32 value1=0;
|
||||
u32 value2=0;
|
||||
|
||||
|
||||
if(address<17)
|
||||
value1=reg[address].I;
|
||||
else {
|
||||
|
@ -2499,7 +2499,7 @@ static bool debuggerCondEvaluate(int num)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//value2
|
||||
if(debuggerBreakpointList[num].ia2) { //is address or register
|
||||
if(value<17)
|
||||
|
@ -2618,11 +2618,11 @@ char* strqtok (char* string, const char* ctrl)
|
|||
char buffer[1024];
|
||||
char *commands[10];
|
||||
int commandCount = 0;
|
||||
|
||||
|
||||
if(emulator.emuUpdateCPSR)
|
||||
emulator.emuUpdateCPSR();
|
||||
debuggerRegisters(0, NULL);
|
||||
|
||||
|
||||
while(debugger) {
|
||||
systemSoundPause();
|
||||
debuggerDisableBreakpoints();
|
||||
|
@ -2649,7 +2649,7 @@ char* strqtok (char* string, const char* ctrl)
|
|||
debuggerCommands[j].function(commandCount, commands);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,303 +1,303 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "System.h"
|
||||
|
||||
void Simple2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
u8 *nextLine, *finish;
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *dP = (u32 *) dstPtr;
|
||||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
|
||||
finish = (u8 *) bP + ((width+2) << 1);
|
||||
currentPixel = *bP++;
|
||||
|
||||
do {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
u32 color = currentPixel >> 16;
|
||||
#else
|
||||
u32 color = currentPixel & 0xffff;
|
||||
#endif
|
||||
|
||||
color = color | (color << 16);
|
||||
|
||||
*(dP) = color;
|
||||
*(nL) = color;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
color = currentPixel & 0xffff;
|
||||
#else
|
||||
color = currentPixel >> 16;
|
||||
#endif
|
||||
color = color| (color << 16);
|
||||
*(dP + 1) = color;
|
||||
*(nL + 1) = color;
|
||||
|
||||
currentPixel = *bP++;
|
||||
|
||||
dP += 2;
|
||||
nL += 2;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
}
|
||||
while (--height);
|
||||
}
|
||||
|
||||
void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
u8 *nextLine, *finish;
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *dP = (u32 *) dstPtr;
|
||||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
|
||||
finish = (u8 *) bP + ((width+1) << 2);
|
||||
currentPixel = *bP++;
|
||||
|
||||
do {
|
||||
u32 color = currentPixel;
|
||||
|
||||
*(dP) = color;
|
||||
*(dP+1) = color;
|
||||
*(nL) = color;
|
||||
*(nL + 1) = color;
|
||||
|
||||
currentPixel = *bP++;
|
||||
|
||||
dP += 2;
|
||||
nL += 2;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
}
|
||||
while (--height);
|
||||
}
|
||||
|
||||
|
||||
void Simple3x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
#define magnification 3
|
||||
#define colorBytes 2 // 16 bit colors = 2 byte colors
|
||||
|
||||
// Generic Simple magnification filter
|
||||
int x, y; // Source Position Counter
|
||||
unsigned int dx, dy; // Destination pixel's pixels
|
||||
unsigned short col; // Source color
|
||||
|
||||
srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
|
||||
dstPitch = dstPitch / colorBytes;
|
||||
|
||||
unsigned short *src, *dst, *dst2;
|
||||
src = (unsigned short *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
|
||||
dst = (unsigned short *)dstPtr;
|
||||
|
||||
for (y = 0; y < height; y++) // Line
|
||||
{
|
||||
for (x = 0; x < width; x++) // Pixel in Line
|
||||
{
|
||||
col = *src;
|
||||
|
||||
dst2 = dst;
|
||||
*dst2 = col;
|
||||
for (dy = 0; dy < magnification; dy++)
|
||||
{
|
||||
for (dx = 0; dx < magnification; dx++)
|
||||
{
|
||||
*dst2 = col;
|
||||
dst2++;
|
||||
}
|
||||
dst2+=dstPitch;
|
||||
dst2-=magnification;
|
||||
}
|
||||
|
||||
src++;
|
||||
dst+=magnification;
|
||||
}
|
||||
src+=srcPitch;
|
||||
dst+=dstPitch * magnification;
|
||||
dst-=width * magnification;
|
||||
}
|
||||
#undef magnification
|
||||
#undef colorBytes
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Simple3x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
#define magnification 3
|
||||
#define colorBytes 4 // 32 bit colors = 4 byte colors
|
||||
|
||||
// Generic Simple magnification filter
|
||||
int x, y; // Source Position Counter
|
||||
unsigned int dx, dy; // Destination pixel's pixels
|
||||
unsigned int col; // Source color
|
||||
|
||||
srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
|
||||
dstPitch = dstPitch / colorBytes;
|
||||
|
||||
unsigned int *src, *dst, *dst2;
|
||||
src = (unsigned int *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
|
||||
dst = (unsigned int *)dstPtr;
|
||||
|
||||
for (y = 0; y < height; y++) // Line
|
||||
{
|
||||
for (x = 0; x < width; x++) // Pixel in Line
|
||||
{
|
||||
col = *src;
|
||||
|
||||
dst2 = dst;
|
||||
*dst2 = col;
|
||||
for (dy = 0; dy < magnification; dy++)
|
||||
{
|
||||
for (dx = 0; dx < magnification; dx++)
|
||||
{
|
||||
*dst2 = col;
|
||||
dst2++;
|
||||
}
|
||||
dst2+=dstPitch;
|
||||
dst2-=magnification;
|
||||
}
|
||||
|
||||
src++;
|
||||
dst+=magnification;
|
||||
}
|
||||
src+=srcPitch;
|
||||
dst+=dstPitch * magnification;
|
||||
dst-=width * magnification;
|
||||
}
|
||||
#undef magnification
|
||||
#undef colorBytes
|
||||
}
|
||||
|
||||
void Simple4x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
#define magnification 4
|
||||
#define colorBytes 2 // 16 bit colors = 2 byte colors
|
||||
|
||||
// Generic Simple magnification filter
|
||||
int x, y; // Source Position Counter
|
||||
unsigned int dx, dy; // Destination pixel's pixels
|
||||
unsigned short col; // Source color
|
||||
|
||||
srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
|
||||
dstPitch = dstPitch / colorBytes;
|
||||
|
||||
unsigned short *src, *dst, *dst2;
|
||||
src = (unsigned short *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
|
||||
dst = (unsigned short *)dstPtr;
|
||||
|
||||
for (y = 0; y < height; y++) // Line
|
||||
{
|
||||
for (x = 0; x < width; x++) // Pixel in Line
|
||||
{
|
||||
col = *src;
|
||||
|
||||
dst2 = dst;
|
||||
*dst2 = col;
|
||||
for (dy = 0; dy < magnification; dy++)
|
||||
{
|
||||
for (dx = 0; dx < magnification; dx++)
|
||||
{
|
||||
*dst2 = col;
|
||||
dst2++;
|
||||
}
|
||||
dst2+=dstPitch;
|
||||
dst2-=magnification;
|
||||
}
|
||||
|
||||
src++;
|
||||
dst+=magnification;
|
||||
}
|
||||
src+=srcPitch;
|
||||
dst+=dstPitch * magnification;
|
||||
dst-=width * magnification;
|
||||
}
|
||||
#undef magnification
|
||||
#undef colorBytes
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Simple4x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
#define magnification 4
|
||||
#define colorBytes 4 // 32 bit colors = 4 byte colors
|
||||
|
||||
// Generic Simple magnification filter
|
||||
int x, y; // Source Position Counter
|
||||
unsigned int dx, dy; // Destination pixel's pixels
|
||||
unsigned int col; // Source color
|
||||
|
||||
srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
|
||||
dstPitch = dstPitch / colorBytes;
|
||||
|
||||
unsigned int *src, *dst, *dst2;
|
||||
src = (unsigned int *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
|
||||
dst = (unsigned int *)dstPtr;
|
||||
|
||||
for (y = 0; y < height; y++) // Line
|
||||
{
|
||||
for (x = 0; x < width; x++) // Pixel in Line
|
||||
{
|
||||
col = *src;
|
||||
|
||||
dst2 = dst;
|
||||
*dst2 = col;
|
||||
for (dy = 0; dy < magnification; dy++)
|
||||
{
|
||||
for (dx = 0; dx < magnification; dx++)
|
||||
{
|
||||
*dst2 = col;
|
||||
dst2++;
|
||||
}
|
||||
dst2+=dstPitch;
|
||||
dst2-=magnification;
|
||||
}
|
||||
|
||||
src++;
|
||||
dst+=magnification;
|
||||
}
|
||||
src+=srcPitch;
|
||||
dst+=dstPitch * magnification;
|
||||
dst-=width * magnification;
|
||||
}
|
||||
#undef magnification
|
||||
#undef colorBytes
|
||||
}
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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 2, 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, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "System.h"
|
||||
|
||||
void Simple2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
u8 *nextLine, *finish;
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *dP = (u32 *) dstPtr;
|
||||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
|
||||
finish = (u8 *) bP + ((width+2) << 1);
|
||||
currentPixel = *bP++;
|
||||
|
||||
do {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
u32 color = currentPixel >> 16;
|
||||
#else
|
||||
u32 color = currentPixel & 0xffff;
|
||||
#endif
|
||||
|
||||
color = color | (color << 16);
|
||||
|
||||
*(dP) = color;
|
||||
*(nL) = color;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
color = currentPixel & 0xffff;
|
||||
#else
|
||||
color = currentPixel >> 16;
|
||||
#endif
|
||||
color = color| (color << 16);
|
||||
*(dP + 1) = color;
|
||||
*(nL + 1) = color;
|
||||
|
||||
currentPixel = *bP++;
|
||||
|
||||
dP += 2;
|
||||
nL += 2;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
}
|
||||
while (--height);
|
||||
}
|
||||
|
||||
void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
u8 *nextLine, *finish;
|
||||
|
||||
nextLine = dstPtr + dstPitch;
|
||||
|
||||
do {
|
||||
u32 *bP = (u32 *) srcPtr;
|
||||
u32 *dP = (u32 *) dstPtr;
|
||||
u32 *nL = (u32 *) nextLine;
|
||||
u32 currentPixel;
|
||||
|
||||
finish = (u8 *) bP + ((width+1) << 2);
|
||||
currentPixel = *bP++;
|
||||
|
||||
do {
|
||||
u32 color = currentPixel;
|
||||
|
||||
*(dP) = color;
|
||||
*(dP+1) = color;
|
||||
*(nL) = color;
|
||||
*(nL + 1) = color;
|
||||
|
||||
currentPixel = *bP++;
|
||||
|
||||
dP += 2;
|
||||
nL += 2;
|
||||
} while ((u8 *) bP < finish);
|
||||
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch << 1;
|
||||
nextLine += dstPitch << 1;
|
||||
}
|
||||
while (--height);
|
||||
}
|
||||
|
||||
|
||||
void Simple3x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
#define magnification 3
|
||||
#define colorBytes 2 // 16 bit colors = 2 byte colors
|
||||
|
||||
// Generic Simple magnification filter
|
||||
int x, y; // Source Position Counter
|
||||
unsigned int dx, dy; // Destination pixel's pixels
|
||||
unsigned short col; // Source color
|
||||
|
||||
srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
|
||||
dstPitch = dstPitch / colorBytes;
|
||||
|
||||
unsigned short *src, *dst, *dst2;
|
||||
src = (unsigned short *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
|
||||
dst = (unsigned short *)dstPtr;
|
||||
|
||||
for (y = 0; y < height; y++) // Line
|
||||
{
|
||||
for (x = 0; x < width; x++) // Pixel in Line
|
||||
{
|
||||
col = *src;
|
||||
|
||||
dst2 = dst;
|
||||
*dst2 = col;
|
||||
for (dy = 0; dy < magnification; dy++)
|
||||
{
|
||||
for (dx = 0; dx < magnification; dx++)
|
||||
{
|
||||
*dst2 = col;
|
||||
dst2++;
|
||||
}
|
||||
dst2+=dstPitch;
|
||||
dst2-=magnification;
|
||||
}
|
||||
|
||||
src++;
|
||||
dst+=magnification;
|
||||
}
|
||||
src+=srcPitch;
|
||||
dst+=dstPitch * magnification;
|
||||
dst-=width * magnification;
|
||||
}
|
||||
#undef magnification
|
||||
#undef colorBytes
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Simple3x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
#define magnification 3
|
||||
#define colorBytes 4 // 32 bit colors = 4 byte colors
|
||||
|
||||
// Generic Simple magnification filter
|
||||
int x, y; // Source Position Counter
|
||||
unsigned int dx, dy; // Destination pixel's pixels
|
||||
unsigned int col; // Source color
|
||||
|
||||
srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
|
||||
dstPitch = dstPitch / colorBytes;
|
||||
|
||||
unsigned int *src, *dst, *dst2;
|
||||
src = (unsigned int *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
|
||||
dst = (unsigned int *)dstPtr;
|
||||
|
||||
for (y = 0; y < height; y++) // Line
|
||||
{
|
||||
for (x = 0; x < width; x++) // Pixel in Line
|
||||
{
|
||||
col = *src;
|
||||
|
||||
dst2 = dst;
|
||||
*dst2 = col;
|
||||
for (dy = 0; dy < magnification; dy++)
|
||||
{
|
||||
for (dx = 0; dx < magnification; dx++)
|
||||
{
|
||||
*dst2 = col;
|
||||
dst2++;
|
||||
}
|
||||
dst2+=dstPitch;
|
||||
dst2-=magnification;
|
||||
}
|
||||
|
||||
src++;
|
||||
dst+=magnification;
|
||||
}
|
||||
src+=srcPitch;
|
||||
dst+=dstPitch * magnification;
|
||||
dst-=width * magnification;
|
||||
}
|
||||
#undef magnification
|
||||
#undef colorBytes
|
||||
}
|
||||
|
||||
void Simple4x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
#define magnification 4
|
||||
#define colorBytes 2 // 16 bit colors = 2 byte colors
|
||||
|
||||
// Generic Simple magnification filter
|
||||
int x, y; // Source Position Counter
|
||||
unsigned int dx, dy; // Destination pixel's pixels
|
||||
unsigned short col; // Source color
|
||||
|
||||
srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
|
||||
dstPitch = dstPitch / colorBytes;
|
||||
|
||||
unsigned short *src, *dst, *dst2;
|
||||
src = (unsigned short *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
|
||||
dst = (unsigned short *)dstPtr;
|
||||
|
||||
for (y = 0; y < height; y++) // Line
|
||||
{
|
||||
for (x = 0; x < width; x++) // Pixel in Line
|
||||
{
|
||||
col = *src;
|
||||
|
||||
dst2 = dst;
|
||||
*dst2 = col;
|
||||
for (dy = 0; dy < magnification; dy++)
|
||||
{
|
||||
for (dx = 0; dx < magnification; dx++)
|
||||
{
|
||||
*dst2 = col;
|
||||
dst2++;
|
||||
}
|
||||
dst2+=dstPitch;
|
||||
dst2-=magnification;
|
||||
}
|
||||
|
||||
src++;
|
||||
dst+=magnification;
|
||||
}
|
||||
src+=srcPitch;
|
||||
dst+=dstPitch * magnification;
|
||||
dst-=width * magnification;
|
||||
}
|
||||
#undef magnification
|
||||
#undef colorBytes
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Simple4x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
|
||||
u8 *dstPtr, u32 dstPitch, int width, int height)
|
||||
{
|
||||
#define magnification 4
|
||||
#define colorBytes 4 // 32 bit colors = 4 byte colors
|
||||
|
||||
// Generic Simple magnification filter
|
||||
int x, y; // Source Position Counter
|
||||
unsigned int dx, dy; // Destination pixel's pixels
|
||||
unsigned int col; // Source color
|
||||
|
||||
srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
|
||||
dstPitch = dstPitch / colorBytes;
|
||||
|
||||
unsigned int *src, *dst, *dst2;
|
||||
src = (unsigned int *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
|
||||
dst = (unsigned int *)dstPtr;
|
||||
|
||||
for (y = 0; y < height; y++) // Line
|
||||
{
|
||||
for (x = 0; x < width; x++) // Pixel in Line
|
||||
{
|
||||
col = *src;
|
||||
|
||||
dst2 = dst;
|
||||
*dst2 = col;
|
||||
for (dy = 0; dy < magnification; dy++)
|
||||
{
|
||||
for (dx = 0; dx < magnification; dx++)
|
||||
{
|
||||
*dst2 = col;
|
||||
dst2++;
|
||||
}
|
||||
dst2+=dstPitch;
|
||||
dst2-=magnification;
|
||||
}
|
||||
|
||||
src++;
|
||||
dst+=magnification;
|
||||
}
|
||||
src+=srcPitch;
|
||||
dst+=dstPitch * magnification;
|
||||
dst-=width * magnification;
|
||||
}
|
||||
#undef magnification
|
||||
#undef colorBytes
|
||||
}
|
||||
|
|
|
@ -1,481 +1,481 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "libresample-0.1.3/include/libresample.h"
|
||||
#include "snd_interp.h"
|
||||
|
||||
// this was once borrowed from libmodplug, and was also used to generate the FIR coefficient
|
||||
// tables that ZSNES uses for its "FIR" interpolation mode
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------------------------
|
||||
fir interpolation doc,
|
||||
(derived from "an engineer's guide to fir digital filters", n.j. loy)
|
||||
|
||||
calculate coefficients for ideal lowpass filter (with cutoff = fc in 0..1 (mapped to 0..nyquist))
|
||||
c[-N..N] = (i==0) ? fc : sin(fc*pi*i)/(pi*i)
|
||||
|
||||
then apply selected window to coefficients
|
||||
c[-N..N] *= w(0..N)
|
||||
with n in 2*N and w(n) being a window function (see loy)
|
||||
|
||||
then calculate gain and scale filter coefs to have unity gain.
|
||||
------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
// quantizer scale of window coefs
|
||||
#define WFIR_QUANTBITS 14
|
||||
#define WFIR_QUANTSCALE (1L<<WFIR_QUANTBITS)
|
||||
#define WFIR_8SHIFT (WFIR_QUANTBITS-8)
|
||||
#define WFIR_16BITSHIFT (WFIR_QUANTBITS)
|
||||
// log2(number)-1 of precalculated taps range is [4..12]
|
||||
#define WFIR_FRACBITS 12
|
||||
#define WFIR_LUTLEN ((1L<<(WFIR_FRACBITS+1))+1)
|
||||
// number of samples in window
|
||||
#define WFIR_LOG2WIDTH 3
|
||||
#define WFIR_WIDTH (1L<<WFIR_LOG2WIDTH)
|
||||
#define WFIR_SMPSPERWING ((WFIR_WIDTH-1)>>1)
|
||||
// cutoff (1.0 == pi/2)
|
||||
#define WFIR_CUTOFF 0.95f
|
||||
// wfir type
|
||||
#define WFIR_HANN 0
|
||||
#define WFIR_HAMMING 1
|
||||
#define WFIR_BLACKMANEXACT 2
|
||||
#define WFIR_BLACKMAN3T61 3
|
||||
#define WFIR_BLACKMAN3T67 4
|
||||
#define WFIR_BLACKMAN4T92 5
|
||||
#define WFIR_BLACKMAN4T74 6
|
||||
#define WFIR_KAISER4T 7
|
||||
#define WFIR_LANCZOS 8
|
||||
#define WFIR_TYPE WFIR_LANCZOS
|
||||
// wfir help
|
||||
#ifndef M_zPI
|
||||
#define M_zPI 3.1415926535897932384626433832795
|
||||
#endif
|
||||
#define M_zEPS 1e-8
|
||||
#define M_zBESSELEPS 1e-21
|
||||
|
||||
class CzWINDOWEDFIR
|
||||
{ public:
|
||||
CzWINDOWEDFIR( );
|
||||
~CzWINDOWEDFIR( );
|
||||
float coef( int _PCnr, float _POfs, float _PCut, int _PWidth, int _PType ) //float _PPos, float _PFc, int _PLen )
|
||||
{ double _LWidthM1 = _PWidth-1;
|
||||
double _LWidthM1Half = 0.5*_LWidthM1;
|
||||
double _LPosU = ((double)_PCnr - _POfs);
|
||||
double _LPos = _LPosU-_LWidthM1Half;
|
||||
double _LPIdl = 2.0*M_zPI/_LWidthM1;
|
||||
double _LWc,_LSi;
|
||||
if( fabs(_LPos)<M_zEPS )
|
||||
{ _LWc = 1.0;
|
||||
_LSi = _PCut;
|
||||
}
|
||||
else
|
||||
{ switch( _PType )
|
||||
{ case WFIR_HANN:
|
||||
_LWc = 0.50 - 0.50 * cos(_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_HAMMING:
|
||||
_LWc = 0.54 - 0.46 * cos(_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_BLACKMANEXACT:
|
||||
_LWc = 0.42 - 0.50 * cos(_LPIdl*_LPosU) + 0.08 * cos(2.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_BLACKMAN3T61:
|
||||
_LWc = 0.44959 - 0.49364 * cos(_LPIdl*_LPosU) + 0.05677 * cos(2.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_BLACKMAN3T67:
|
||||
_LWc = 0.42323 - 0.49755 * cos(_LPIdl*_LPosU) + 0.07922 * cos(2.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_BLACKMAN4T92:
|
||||
_LWc = 0.35875 - 0.48829 * cos(_LPIdl*_LPosU) + 0.14128 * cos(2.0*_LPIdl*_LPosU) - 0.01168 * cos(3.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_BLACKMAN4T74:
|
||||
_LWc = 0.40217 - 0.49703 * cos(_LPIdl*_LPosU) + 0.09392 * cos(2.0*_LPIdl*_LPosU) - 0.00183 * cos(3.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_KAISER4T:
|
||||
_LWc = 0.40243 - 0.49804 * cos(_LPIdl*_LPosU) + 0.09831 * cos(2.0*_LPIdl*_LPosU) - 0.00122 * cos(3.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_LANCZOS:
|
||||
_LWc = 1 - (sin(_LPIdl*_LPosU) / (_LPIdl*_LPosU));
|
||||
break;
|
||||
default:
|
||||
_LWc = 1.0;
|
||||
break;
|
||||
}
|
||||
_LPos *= M_zPI;
|
||||
_LSi = sin(_PCut*_LPos)/_LPos;
|
||||
}
|
||||
return (float)(_LWc*_LSi);
|
||||
}
|
||||
static signed short lut[WFIR_LUTLEN*WFIR_WIDTH];
|
||||
};
|
||||
|
||||
signed short CzWINDOWEDFIR::lut[WFIR_LUTLEN*WFIR_WIDTH];
|
||||
|
||||
CzWINDOWEDFIR::CzWINDOWEDFIR()
|
||||
{ int _LPcl;
|
||||
float _LPcllen = (float)(1L<<WFIR_FRACBITS); // number of precalculated lines for 0..1 (-1..0)
|
||||
float _LNorm = 1.0f / (float)(2.0f * _LPcllen);
|
||||
float _LCut = WFIR_CUTOFF;
|
||||
float _LScale = (float)WFIR_QUANTSCALE;
|
||||
float _LGain,_LCoefs[WFIR_WIDTH];
|
||||
for( _LPcl=0;_LPcl<WFIR_LUTLEN;_LPcl++ )
|
||||
{
|
||||
float _LOfs = ((float)_LPcl-_LPcllen)*_LNorm;
|
||||
int _LCc,_LIdx = _LPcl<<WFIR_LOG2WIDTH;
|
||||
for( _LCc=0,_LGain=0.0f;_LCc<WFIR_WIDTH;_LCc++ )
|
||||
{ _LGain += (_LCoefs[_LCc] = coef( _LCc, _LOfs, _LCut, WFIR_WIDTH, WFIR_TYPE ));
|
||||
}
|
||||
_LGain = 1.0f/_LGain;
|
||||
for( _LCc=0;_LCc<WFIR_WIDTH;_LCc++ )
|
||||
{ float _LCoef = (float)floor( 0.5 + _LScale*_LCoefs[_LCc]*_LGain );
|
||||
lut[_LIdx+_LCc] = (signed short)( (_LCoef<-_LScale)?-_LScale:((_LCoef>_LScale)?_LScale:_LCoef) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CzWINDOWEDFIR::~CzWINDOWEDFIR()
|
||||
{ // nothing todo
|
||||
}
|
||||
|
||||
CzWINDOWEDFIR sfir;
|
||||
|
||||
template <class T, int buffer_size>
|
||||
class sample_buffer
|
||||
{
|
||||
int ptr, filled;
|
||||
T * buffer;
|
||||
|
||||
public:
|
||||
sample_buffer() : ptr(0), filled(0)
|
||||
{
|
||||
buffer = new T[buffer_size];
|
||||
}
|
||||
~sample_buffer()
|
||||
{
|
||||
if (buffer) delete [] buffer;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
ptr = filled = 0;
|
||||
}
|
||||
|
||||
inline int size() const
|
||||
{
|
||||
return filled;
|
||||
}
|
||||
|
||||
inline void push_back(T sample)
|
||||
{
|
||||
buffer[ptr] = sample;
|
||||
if (++ptr >= buffer_size) ptr = 0;
|
||||
if (filled < buffer_size) filled++;
|
||||
}
|
||||
|
||||
inline void erase(int count)
|
||||
{
|
||||
if (count > filled) filled = 0;
|
||||
else filled -= count;
|
||||
}
|
||||
|
||||
inline T operator[] (int index) const
|
||||
{
|
||||
index += ptr - filled;
|
||||
if (index < 0) index += buffer_size;
|
||||
else if (index > buffer_size) index -= buffer_size;
|
||||
return buffer[index];
|
||||
}
|
||||
};
|
||||
|
||||
class foo_null : public foo_interpolate
|
||||
{
|
||||
int sample;
|
||||
|
||||
public:
|
||||
foo_null() : sample(0) {}
|
||||
~foo_null() {}
|
||||
|
||||
void reset() {}
|
||||
|
||||
void push(int psample)
|
||||
{
|
||||
sample = psample;
|
||||
}
|
||||
|
||||
int pop()
|
||||
{
|
||||
return sample;
|
||||
}
|
||||
};
|
||||
|
||||
class foo_linear : public foo_interpolate
|
||||
{
|
||||
sample_buffer<int,4> samples;
|
||||
|
||||
int position;
|
||||
|
||||
inline int smp(int index)
|
||||
{
|
||||
return samples[index];
|
||||
}
|
||||
|
||||
public:
|
||||
foo_linear()
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
|
||||
~foo_linear() {}
|
||||
|
||||
void reset()
|
||||
{
|
||||
position = 0;
|
||||
samples.clear();
|
||||
}
|
||||
|
||||
|
||||
void push(int sample)
|
||||
{
|
||||
samples.push_back(sample);
|
||||
}
|
||||
|
||||
int pop()
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (position > 0x7fff)
|
||||
{
|
||||
int howmany = position >> 15;
|
||||
position &= 0x7fff;
|
||||
samples.erase(howmany);
|
||||
}
|
||||
|
||||
if (samples.size() < 2) return 0;
|
||||
|
||||
ret = smp(0) * (0x8000 - position);
|
||||
ret += smp(1) * position;
|
||||
ret >>= 15;
|
||||
|
||||
position+=lrate;
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
// and this integer cubic interpolation implementation was kind of borrowed from either TiMidity
|
||||
// or the P.E.Op.S. SPU project, or is in use in both, or something...
|
||||
|
||||
class foo_cubic : public foo_interpolate
|
||||
{
|
||||
sample_buffer<int,12> samples;
|
||||
|
||||
int position;
|
||||
|
||||
inline int smp(int index)
|
||||
{
|
||||
return samples[index];
|
||||
}
|
||||
|
||||
public:
|
||||
foo_cubic()
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
|
||||
~foo_cubic() {}
|
||||
|
||||
void reset()
|
||||
{
|
||||
position = 0;
|
||||
samples.clear();
|
||||
}
|
||||
|
||||
void push(int sample)
|
||||
{
|
||||
samples.push_back(sample);
|
||||
}
|
||||
|
||||
int pop()
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (position > 0x7fff)
|
||||
{
|
||||
int howmany = position >> 15;
|
||||
position &= 0x7fff;
|
||||
samples.erase(howmany);
|
||||
}
|
||||
|
||||
if (samples.size() < 4) return 0;
|
||||
|
||||
ret = smp(3) - 3 * smp(2) + 3 * smp(1) - smp(0);
|
||||
ret *= (position - (2 << 15)) / 6;
|
||||
ret >>= 15;
|
||||
ret += smp(2) - 2 * smp(1) + smp(0);
|
||||
ret *= (position - (1 << 15)) >> 1;
|
||||
ret >>= 15;
|
||||
ret += smp(1) - smp(0);
|
||||
ret *= position;
|
||||
ret >>= 15;
|
||||
ret += smp(0);
|
||||
|
||||
if (ret > 32767) ret = 32767;
|
||||
else if (ret < -32768) ret = -32768;
|
||||
|
||||
position+=lrate;
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
class foo_fir : public foo_interpolate
|
||||
{
|
||||
sample_buffer<int,24> samples;
|
||||
|
||||
int position;
|
||||
|
||||
inline int smp(int index)
|
||||
{
|
||||
return samples[index];
|
||||
}
|
||||
|
||||
public:
|
||||
foo_fir()
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
|
||||
~foo_fir()
|
||||
{
|
||||
position=666;
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
position = 0;
|
||||
samples.clear();
|
||||
}
|
||||
|
||||
void push(int sample)
|
||||
{
|
||||
samples.push_back(sample);
|
||||
}
|
||||
|
||||
int pop()
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (position > 0x7fff)
|
||||
{
|
||||
int howmany = position >> 15;
|
||||
position &= 0x7fff;
|
||||
samples.erase(howmany);
|
||||
}
|
||||
|
||||
if (samples.size() < 8) return 0;
|
||||
|
||||
ret = smp(0) * CzWINDOWEDFIR::lut[(position & ~7) ];
|
||||
ret += smp(1) * CzWINDOWEDFIR::lut[(position & ~7) + 1];
|
||||
ret += smp(2) * CzWINDOWEDFIR::lut[(position & ~7) + 2];
|
||||
ret += smp(3) * CzWINDOWEDFIR::lut[(position & ~7) + 3];
|
||||
ret += smp(4) * CzWINDOWEDFIR::lut[(position & ~7) + 4];
|
||||
ret += smp(5) * CzWINDOWEDFIR::lut[(position & ~7) + 5];
|
||||
ret += smp(6) * CzWINDOWEDFIR::lut[(position & ~7) + 6];
|
||||
ret += smp(7) * CzWINDOWEDFIR::lut[(position & ~7) + 7];
|
||||
ret >>= WFIR_QUANTBITS;
|
||||
|
||||
if (ret > 32767) ret = 32767;
|
||||
else if (ret < -32768) ret = -32768;
|
||||
|
||||
position+=lrate;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
class foo_libresample : public foo_interpolate
|
||||
{
|
||||
sample_buffer<float,32> samples;
|
||||
|
||||
void * resampler;
|
||||
|
||||
public:
|
||||
foo_libresample()
|
||||
{
|
||||
resampler = 0;
|
||||
}
|
||||
|
||||
~foo_libresample()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
samples.clear();
|
||||
if (resampler)
|
||||
{
|
||||
resample_close(resampler);
|
||||
resampler = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void push(int sample)
|
||||
{
|
||||
samples.push_back(float(sample));
|
||||
}
|
||||
|
||||
int pop()
|
||||
{
|
||||
int ret;
|
||||
if (!resampler)
|
||||
{
|
||||
resampler = resample_open(0, .25, 44100. / 4000.);
|
||||
}
|
||||
|
||||
{
|
||||
int count = samples.size();
|
||||
float * in = new float[count];
|
||||
float out;
|
||||
int used, returned;
|
||||
|
||||
for (used = 0; used < count; used++)
|
||||
{
|
||||
in[used] = samples[used];
|
||||
}
|
||||
|
||||
returned = resample_process(resampler, 32767. / lrate, in, count, 0, &used, &out, 1);
|
||||
if (used)
|
||||
{
|
||||
samples.erase(used);
|
||||
}
|
||||
|
||||
delete [] in;
|
||||
|
||||
if (returned < 1) return 0;
|
||||
|
||||
ret = (int)out;
|
||||
}
|
||||
|
||||
if (ret > 32767) ret = 32767;
|
||||
else if (ret < -32768) ret = -32768;
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
foo_interpolate * get_filter(int which)
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
default:
|
||||
return new foo_null;
|
||||
case 1:
|
||||
return new foo_linear;
|
||||
case 2:
|
||||
return new foo_cubic;
|
||||
case 3:
|
||||
return new foo_fir;
|
||||
case 4:
|
||||
return new foo_libresample;
|
||||
}
|
||||
}
|
||||
#include <math.h>
|
||||
|
||||
#include "libresample-0.1.3/include/libresample.h"
|
||||
#include "snd_interp.h"
|
||||
|
||||
// this was once borrowed from libmodplug, and was also used to generate the FIR coefficient
|
||||
// tables that ZSNES uses for its "FIR" interpolation mode
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------------------------
|
||||
fir interpolation doc,
|
||||
(derived from "an engineer's guide to fir digital filters", n.j. loy)
|
||||
|
||||
calculate coefficients for ideal lowpass filter (with cutoff = fc in 0..1 (mapped to 0..nyquist))
|
||||
c[-N..N] = (i==0) ? fc : sin(fc*pi*i)/(pi*i)
|
||||
|
||||
then apply selected window to coefficients
|
||||
c[-N..N] *= w(0..N)
|
||||
with n in 2*N and w(n) being a window function (see loy)
|
||||
|
||||
then calculate gain and scale filter coefs to have unity gain.
|
||||
------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
// quantizer scale of window coefs
|
||||
#define WFIR_QUANTBITS 14
|
||||
#define WFIR_QUANTSCALE (1L<<WFIR_QUANTBITS)
|
||||
#define WFIR_8SHIFT (WFIR_QUANTBITS-8)
|
||||
#define WFIR_16BITSHIFT (WFIR_QUANTBITS)
|
||||
// log2(number)-1 of precalculated taps range is [4..12]
|
||||
#define WFIR_FRACBITS 12
|
||||
#define WFIR_LUTLEN ((1L<<(WFIR_FRACBITS+1))+1)
|
||||
// number of samples in window
|
||||
#define WFIR_LOG2WIDTH 3
|
||||
#define WFIR_WIDTH (1L<<WFIR_LOG2WIDTH)
|
||||
#define WFIR_SMPSPERWING ((WFIR_WIDTH-1)>>1)
|
||||
// cutoff (1.0 == pi/2)
|
||||
#define WFIR_CUTOFF 0.95f
|
||||
// wfir type
|
||||
#define WFIR_HANN 0
|
||||
#define WFIR_HAMMING 1
|
||||
#define WFIR_BLACKMANEXACT 2
|
||||
#define WFIR_BLACKMAN3T61 3
|
||||
#define WFIR_BLACKMAN3T67 4
|
||||
#define WFIR_BLACKMAN4T92 5
|
||||
#define WFIR_BLACKMAN4T74 6
|
||||
#define WFIR_KAISER4T 7
|
||||
#define WFIR_LANCZOS 8
|
||||
#define WFIR_TYPE WFIR_LANCZOS
|
||||
// wfir help
|
||||
#ifndef M_zPI
|
||||
#define M_zPI 3.1415926535897932384626433832795
|
||||
#endif
|
||||
#define M_zEPS 1e-8
|
||||
#define M_zBESSELEPS 1e-21
|
||||
|
||||
class CzWINDOWEDFIR
|
||||
{ public:
|
||||
CzWINDOWEDFIR( );
|
||||
~CzWINDOWEDFIR( );
|
||||
float coef( int _PCnr, float _POfs, float _PCut, int _PWidth, int _PType ) //float _PPos, float _PFc, int _PLen )
|
||||
{ double _LWidthM1 = _PWidth-1;
|
||||
double _LWidthM1Half = 0.5*_LWidthM1;
|
||||
double _LPosU = ((double)_PCnr - _POfs);
|
||||
double _LPos = _LPosU-_LWidthM1Half;
|
||||
double _LPIdl = 2.0*M_zPI/_LWidthM1;
|
||||
double _LWc,_LSi;
|
||||
if( fabs(_LPos)<M_zEPS )
|
||||
{ _LWc = 1.0;
|
||||
_LSi = _PCut;
|
||||
}
|
||||
else
|
||||
{ switch( _PType )
|
||||
{ case WFIR_HANN:
|
||||
_LWc = 0.50 - 0.50 * cos(_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_HAMMING:
|
||||
_LWc = 0.54 - 0.46 * cos(_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_BLACKMANEXACT:
|
||||
_LWc = 0.42 - 0.50 * cos(_LPIdl*_LPosU) + 0.08 * cos(2.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_BLACKMAN3T61:
|
||||
_LWc = 0.44959 - 0.49364 * cos(_LPIdl*_LPosU) + 0.05677 * cos(2.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_BLACKMAN3T67:
|
||||
_LWc = 0.42323 - 0.49755 * cos(_LPIdl*_LPosU) + 0.07922 * cos(2.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_BLACKMAN4T92:
|
||||
_LWc = 0.35875 - 0.48829 * cos(_LPIdl*_LPosU) + 0.14128 * cos(2.0*_LPIdl*_LPosU) - 0.01168 * cos(3.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_BLACKMAN4T74:
|
||||
_LWc = 0.40217 - 0.49703 * cos(_LPIdl*_LPosU) + 0.09392 * cos(2.0*_LPIdl*_LPosU) - 0.00183 * cos(3.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_KAISER4T:
|
||||
_LWc = 0.40243 - 0.49804 * cos(_LPIdl*_LPosU) + 0.09831 * cos(2.0*_LPIdl*_LPosU) - 0.00122 * cos(3.0*_LPIdl*_LPosU);
|
||||
break;
|
||||
case WFIR_LANCZOS:
|
||||
_LWc = 1 - (sin(_LPIdl*_LPosU) / (_LPIdl*_LPosU));
|
||||
break;
|
||||
default:
|
||||
_LWc = 1.0;
|
||||
break;
|
||||
}
|
||||
_LPos *= M_zPI;
|
||||
_LSi = sin(_PCut*_LPos)/_LPos;
|
||||
}
|
||||
return (float)(_LWc*_LSi);
|
||||
}
|
||||
static signed short lut[WFIR_LUTLEN*WFIR_WIDTH];
|
||||
};
|
||||
|
||||
signed short CzWINDOWEDFIR::lut[WFIR_LUTLEN*WFIR_WIDTH];
|
||||
|
||||
CzWINDOWEDFIR::CzWINDOWEDFIR()
|
||||
{ int _LPcl;
|
||||
float _LPcllen = (float)(1L<<WFIR_FRACBITS); // number of precalculated lines for 0..1 (-1..0)
|
||||
float _LNorm = 1.0f / (float)(2.0f * _LPcllen);
|
||||
float _LCut = WFIR_CUTOFF;
|
||||
float _LScale = (float)WFIR_QUANTSCALE;
|
||||
float _LGain,_LCoefs[WFIR_WIDTH];
|
||||
for( _LPcl=0;_LPcl<WFIR_LUTLEN;_LPcl++ )
|
||||
{
|
||||
float _LOfs = ((float)_LPcl-_LPcllen)*_LNorm;
|
||||
int _LCc,_LIdx = _LPcl<<WFIR_LOG2WIDTH;
|
||||
for( _LCc=0,_LGain=0.0f;_LCc<WFIR_WIDTH;_LCc++ )
|
||||
{ _LGain += (_LCoefs[_LCc] = coef( _LCc, _LOfs, _LCut, WFIR_WIDTH, WFIR_TYPE ));
|
||||
}
|
||||
_LGain = 1.0f/_LGain;
|
||||
for( _LCc=0;_LCc<WFIR_WIDTH;_LCc++ )
|
||||
{ float _LCoef = (float)floor( 0.5 + _LScale*_LCoefs[_LCc]*_LGain );
|
||||
lut[_LIdx+_LCc] = (signed short)( (_LCoef<-_LScale)?-_LScale:((_LCoef>_LScale)?_LScale:_LCoef) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CzWINDOWEDFIR::~CzWINDOWEDFIR()
|
||||
{ // nothing todo
|
||||
}
|
||||
|
||||
CzWINDOWEDFIR sfir;
|
||||
|
||||
template <class T, int buffer_size>
|
||||
class sample_buffer
|
||||
{
|
||||
int ptr, filled;
|
||||
T * buffer;
|
||||
|
||||
public:
|
||||
sample_buffer() : ptr(0), filled(0)
|
||||
{
|
||||
buffer = new T[buffer_size];
|
||||
}
|
||||
~sample_buffer()
|
||||
{
|
||||
if (buffer) delete [] buffer;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
ptr = filled = 0;
|
||||
}
|
||||
|
||||
inline int size() const
|
||||
{
|
||||
return filled;
|
||||
}
|
||||
|
||||
inline void push_back(T sample)
|
||||
{
|
||||
buffer[ptr] = sample;
|
||||
if (++ptr >= buffer_size) ptr = 0;
|
||||
if (filled < buffer_size) filled++;
|
||||
}
|
||||
|
||||
inline void erase(int count)
|
||||
{
|
||||
if (count > filled) filled = 0;
|
||||
else filled -= count;
|
||||
}
|
||||
|
||||
inline T operator[] (int index) const
|
||||
{
|
||||
index += ptr - filled;
|
||||
if (index < 0) index += buffer_size;
|
||||
else if (index > buffer_size) index -= buffer_size;
|
||||
return buffer[index];
|
||||
}
|
||||
};
|
||||
|
||||
class foo_null : public foo_interpolate
|
||||
{
|
||||
int sample;
|
||||
|
||||
public:
|
||||
foo_null() : sample(0) {}
|
||||
~foo_null() {}
|
||||
|
||||
void reset() {}
|
||||
|
||||
void push(int psample)
|
||||
{
|
||||
sample = psample;
|
||||
}
|
||||
|
||||
int pop()
|
||||
{
|
||||
return sample;
|
||||
}
|
||||
};
|
||||
|
||||
class foo_linear : public foo_interpolate
|
||||
{
|
||||
sample_buffer<int,4> samples;
|
||||
|
||||
int position;
|
||||
|
||||
inline int smp(int index)
|
||||
{
|
||||
return samples[index];
|
||||
}
|
||||
|
||||
public:
|
||||
foo_linear()
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
|
||||
~foo_linear() {}
|
||||
|
||||
void reset()
|
||||
{
|
||||
position = 0;
|
||||
samples.clear();
|
||||
}
|
||||
|
||||
|
||||
void push(int sample)
|
||||
{
|
||||
samples.push_back(sample);
|
||||
}
|
||||
|
||||
int pop()
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (position > 0x7fff)
|
||||
{
|
||||
int howmany = position >> 15;
|
||||
position &= 0x7fff;
|
||||
samples.erase(howmany);
|
||||
}
|
||||
|
||||
if (samples.size() < 2) return 0;
|
||||
|
||||
ret = smp(0) * (0x8000 - position);
|
||||
ret += smp(1) * position;
|
||||
ret >>= 15;
|
||||
|
||||
position+=lrate;
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
// and this integer cubic interpolation implementation was kind of borrowed from either TiMidity
|
||||
// or the P.E.Op.S. SPU project, or is in use in both, or something...
|
||||
|
||||
class foo_cubic : public foo_interpolate
|
||||
{
|
||||
sample_buffer<int,12> samples;
|
||||
|
||||
int position;
|
||||
|
||||
inline int smp(int index)
|
||||
{
|
||||
return samples[index];
|
||||
}
|
||||
|
||||
public:
|
||||
foo_cubic()
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
|
||||
~foo_cubic() {}
|
||||
|
||||
void reset()
|
||||
{
|
||||
position = 0;
|
||||
samples.clear();
|
||||
}
|
||||
|
||||
void push(int sample)
|
||||
{
|
||||
samples.push_back(sample);
|
||||
}
|
||||
|
||||
int pop()
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (position > 0x7fff)
|
||||
{
|
||||
int howmany = position >> 15;
|
||||
position &= 0x7fff;
|
||||
samples.erase(howmany);
|
||||
}
|
||||
|
||||
if (samples.size() < 4) return 0;
|
||||
|
||||
ret = smp(3) - 3 * smp(2) + 3 * smp(1) - smp(0);
|
||||
ret *= (position - (2 << 15)) / 6;
|
||||
ret >>= 15;
|
||||
ret += smp(2) - 2 * smp(1) + smp(0);
|
||||
ret *= (position - (1 << 15)) >> 1;
|
||||
ret >>= 15;
|
||||
ret += smp(1) - smp(0);
|
||||
ret *= position;
|
||||
ret >>= 15;
|
||||
ret += smp(0);
|
||||
|
||||
if (ret > 32767) ret = 32767;
|
||||
else if (ret < -32768) ret = -32768;
|
||||
|
||||
position+=lrate;
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
class foo_fir : public foo_interpolate
|
||||
{
|
||||
sample_buffer<int,24> samples;
|
||||
|
||||
int position;
|
||||
|
||||
inline int smp(int index)
|
||||
{
|
||||
return samples[index];
|
||||
}
|
||||
|
||||
public:
|
||||
foo_fir()
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
|
||||
~foo_fir()
|
||||
{
|
||||
position=666;
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
position = 0;
|
||||
samples.clear();
|
||||
}
|
||||
|
||||
void push(int sample)
|
||||
{
|
||||
samples.push_back(sample);
|
||||
}
|
||||
|
||||
int pop()
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (position > 0x7fff)
|
||||
{
|
||||
int howmany = position >> 15;
|
||||
position &= 0x7fff;
|
||||
samples.erase(howmany);
|
||||
}
|
||||
|
||||
if (samples.size() < 8) return 0;
|
||||
|
||||
ret = smp(0) * CzWINDOWEDFIR::lut[(position & ~7) ];
|
||||
ret += smp(1) * CzWINDOWEDFIR::lut[(position & ~7) + 1];
|
||||
ret += smp(2) * CzWINDOWEDFIR::lut[(position & ~7) + 2];
|
||||
ret += smp(3) * CzWINDOWEDFIR::lut[(position & ~7) + 3];
|
||||
ret += smp(4) * CzWINDOWEDFIR::lut[(position & ~7) + 4];
|
||||
ret += smp(5) * CzWINDOWEDFIR::lut[(position & ~7) + 5];
|
||||
ret += smp(6) * CzWINDOWEDFIR::lut[(position & ~7) + 6];
|
||||
ret += smp(7) * CzWINDOWEDFIR::lut[(position & ~7) + 7];
|
||||
ret >>= WFIR_QUANTBITS;
|
||||
|
||||
if (ret > 32767) ret = 32767;
|
||||
else if (ret < -32768) ret = -32768;
|
||||
|
||||
position+=lrate;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
class foo_libresample : public foo_interpolate
|
||||
{
|
||||
sample_buffer<float,32> samples;
|
||||
|
||||
void * resampler;
|
||||
|
||||
public:
|
||||
foo_libresample()
|
||||
{
|
||||
resampler = 0;
|
||||
}
|
||||
|
||||
~foo_libresample()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
samples.clear();
|
||||
if (resampler)
|
||||
{
|
||||
resample_close(resampler);
|
||||
resampler = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void push(int sample)
|
||||
{
|
||||
samples.push_back(float(sample));
|
||||
}
|
||||
|
||||
int pop()
|
||||
{
|
||||
int ret;
|
||||
if (!resampler)
|
||||
{
|
||||
resampler = resample_open(0, .25, 44100. / 4000.);
|
||||
}
|
||||
|
||||
{
|
||||
int count = samples.size();
|
||||
float * in = new float[count];
|
||||
float out;
|
||||
int used, returned;
|
||||
|
||||
for (used = 0; used < count; used++)
|
||||
{
|
||||
in[used] = samples[used];
|
||||
}
|
||||
|
||||
returned = resample_process(resampler, 32767. / lrate, in, count, 0, &used, &out, 1);
|
||||
if (used)
|
||||
{
|
||||
samples.erase(used);
|
||||
}
|
||||
|
||||
delete [] in;
|
||||
|
||||
if (returned < 1) return 0;
|
||||
|
||||
ret = (int)out;
|
||||
}
|
||||
|
||||
if (ret > 32767) ret = 32767;
|
||||
else if (ret < -32768) ret = -32768;
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
foo_interpolate * get_filter(int which)
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
default:
|
||||
return new foo_null;
|
||||
case 1:
|
||||
return new foo_linear;
|
||||
case 2:
|
||||
return new foo_cubic;
|
||||
case 3:
|
||||
return new foo_fir;
|
||||
case 4:
|
||||
return new foo_libresample;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
#ifndef __SND_INTERP_H__
|
||||
#define __SND_INTERP_H__
|
||||
|
||||
class foo_interpolate
|
||||
{
|
||||
public:
|
||||
foo_interpolate() {}
|
||||
virtual ~foo_interpolate() {};
|
||||
|
||||
virtual void reset() = 0;
|
||||
|
||||
long lrate;
|
||||
|
||||
virtual void rate(double rate)
|
||||
{
|
||||
lrate = (int)(32768. * rate);
|
||||
};
|
||||
|
||||
virtual void push(int sample) = 0;
|
||||
virtual int pop() = 0;
|
||||
};
|
||||
|
||||
extern foo_interpolate * get_filter(int which);
|
||||
|
||||
/*
|
||||
|
||||
// complicated, synced interface, specific to this implementation
|
||||
|
||||
double calc_rate(int timer);
|
||||
void interp_switch(int which);
|
||||
void interp_reset(int ch);
|
||||
inline void interp_push(int ch, int sample);
|
||||
inline int interp_pop(int ch, double rate); */
|
||||
|
||||
#endif
|
||||
#ifndef __SND_INTERP_H__
|
||||
#define __SND_INTERP_H__
|
||||
|
||||
class foo_interpolate
|
||||
{
|
||||
public:
|
||||
foo_interpolate() {}
|
||||
virtual ~foo_interpolate() {};
|
||||
|
||||
virtual void reset() = 0;
|
||||
|
||||
long lrate;
|
||||
|
||||
virtual void rate(double rate)
|
||||
{
|
||||
lrate = (int)(32768. * rate);
|
||||
};
|
||||
|
||||
virtual void push(int sample) = 0;
|
||||
virtual int pop() = 0;
|
||||
};
|
||||
|
||||
extern foo_interpolate * get_filter(int which);
|
||||
|
||||
/*
|
||||
|
||||
// complicated, synced interface, specific to this implementation
|
||||
|
||||
double calc_rate(int timer);
|
||||
void interp_switch(int which);
|
||||
void interp_reset(int ch);
|
||||
inline void interp_push(int ch, int sample);
|
||||
inline int interp_pop(int ch, double rate); */
|
||||
|
||||
#endif
|
||||
|
|
126
src/thumb.h
126
src/thumb.h
|
@ -25,7 +25,7 @@
|
|||
for (xxx=0; xxx<18; xxx++){ \
|
||||
oldreg[xxx]=reg[xxx].I; \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef C_CORE
|
||||
|
@ -813,7 +813,7 @@ switch(opcode >> 8) {
|
|||
int source = (opcode >> 3) & 0x07;
|
||||
int shift = (opcode >> 6) & 0x1f;
|
||||
u32 value;
|
||||
|
||||
|
||||
if(shift) {
|
||||
LSL_RD_RM_I5;
|
||||
} else {
|
||||
|
@ -839,7 +839,7 @@ switch(opcode >> 8) {
|
|||
int source = (opcode >> 3) & 0x07;
|
||||
int shift = (opcode >> 6) & 0x1f;
|
||||
u32 value;
|
||||
|
||||
|
||||
if(shift) {
|
||||
LSR_RD_RM_I5;
|
||||
} else {
|
||||
|
@ -860,13 +860,13 @@ switch(opcode >> 8) {
|
|||
case 0x15:
|
||||
case 0x16:
|
||||
case 0x17:
|
||||
{
|
||||
{
|
||||
// ASR Rd, Rm, #Imm 5
|
||||
int dest = opcode & 0x07;
|
||||
int source = (opcode >> 3) & 0x07;
|
||||
int shift = (opcode >> 6) & 0x1f;
|
||||
u32 value;
|
||||
|
||||
|
||||
if(shift) {
|
||||
ASR_RD_RM_I5;
|
||||
} else {
|
||||
|
@ -975,31 +975,31 @@ case 0x28:
|
|||
case 0x30:
|
||||
// ADD R0,#Offset8
|
||||
ADD_RN_O8(0);
|
||||
break;
|
||||
break;
|
||||
case 0x31:
|
||||
// ADD R1,#Offset8
|
||||
ADD_RN_O8(1);
|
||||
break;
|
||||
break;
|
||||
case 0x32:
|
||||
// ADD R2,#Offset8
|
||||
ADD_RN_O8(2);
|
||||
break;
|
||||
break;
|
||||
case 0x33:
|
||||
// ADD R3,#Offset8
|
||||
ADD_RN_O8(3);
|
||||
break;
|
||||
break;
|
||||
case 0x34:
|
||||
// ADD R4,#Offset8
|
||||
ADD_RN_O8(4);
|
||||
break;
|
||||
break;
|
||||
case 0x35:
|
||||
// ADD R5,#Offset8
|
||||
ADD_RN_O8(5);
|
||||
break;
|
||||
break;
|
||||
case 0x36:
|
||||
// ADD R6,#Offset8
|
||||
ADD_RN_O8(6);
|
||||
break;
|
||||
break;
|
||||
case 0x37:
|
||||
// ADD R7,#Offset8
|
||||
ADD_RN_O8(7);
|
||||
|
@ -1046,7 +1046,7 @@ case 0x28:
|
|||
reg[dest].I &= reg[(opcode >> 3)&7].I;
|
||||
N_FLAG = reg[dest].I & 0x80000000 ? true : false;
|
||||
Z_FLAG = reg[dest].I ? false : true;
|
||||
#ifdef BKPT_SUPPORT
|
||||
#ifdef BKPT_SUPPORT
|
||||
#define THUMB_CONSOLE_OUTPUT(a,b) \
|
||||
if((opcode == 0x4000) && (reg[0].I == 0xC0DED00D)) {\
|
||||
extern void (*dbgOutput)(char *, u32);\
|
||||
|
@ -1082,7 +1082,7 @@ case 0x28:
|
|||
value = 0;
|
||||
C_FLAG = false;
|
||||
}
|
||||
reg[dest].I = value;
|
||||
reg[dest].I = value;
|
||||
}
|
||||
N_FLAG = reg[dest].I & 0x80000000 ? true : false;
|
||||
Z_FLAG = reg[dest].I ? false : true;
|
||||
|
@ -1104,7 +1104,7 @@ case 0x28:
|
|||
value = 0;
|
||||
C_FLAG = false;
|
||||
}
|
||||
reg[dest].I = value;
|
||||
reg[dest].I = value;
|
||||
}
|
||||
N_FLAG = reg[dest].I & 0x80000000 ? true : false;
|
||||
Z_FLAG = reg[dest].I ? false : true;
|
||||
|
@ -1124,7 +1124,7 @@ case 0x28:
|
|||
if(value) {
|
||||
if(value < 32) {
|
||||
ASR_RD_RS;
|
||||
reg[dest].I = value;
|
||||
reg[dest].I = value;
|
||||
} else {
|
||||
if(reg[dest].I & 0x80000000){
|
||||
reg[dest].I = 0xFFFFFFFF;
|
||||
|
@ -1154,7 +1154,7 @@ case 0x28:
|
|||
// SBC Rd, Rs
|
||||
int dest = opcode & 0x07;
|
||||
u32 value = reg[(opcode >> 3)&7].I;
|
||||
|
||||
|
||||
// SBC
|
||||
SBC_RD_RS;
|
||||
}
|
||||
|
@ -1164,7 +1164,7 @@ case 0x28:
|
|||
{
|
||||
int dest = opcode & 7;
|
||||
u32 value = reg[(opcode >> 3)&7].B.B0;
|
||||
|
||||
|
||||
if(value) {
|
||||
value = value & 0x1f;
|
||||
if(value == 0) {
|
||||
|
@ -1222,7 +1222,7 @@ case 0x28:
|
|||
switch((opcode >> 6) & 3) {
|
||||
case 0x00:
|
||||
{
|
||||
// ORR Rd, Rs
|
||||
// ORR Rd, Rs
|
||||
int dest = opcode & 7;
|
||||
reg[dest].I |= reg[(opcode >> 3) & 7].I;
|
||||
Z_FLAG = reg[dest].I ? false : true;
|
||||
|
@ -1293,7 +1293,7 @@ case 0x28:
|
|||
THUMB_PREFETCH;
|
||||
clockTicks = codeTicksAccessSeq16(armNextPC)+1;
|
||||
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// ADD Hd, Hs
|
||||
|
@ -1304,7 +1304,7 @@ case 0x28:
|
|||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
clockTicks = codeTicksAccessSeq16(armNextPC)+1;
|
||||
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
|
||||
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1368,7 +1368,7 @@ case 0x28:
|
|||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
clockTicks = codeTicksAccessSeq16(armNextPC)+1;
|
||||
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
|
||||
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
|
@ -1385,8 +1385,8 @@ case 0x28:
|
|||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
clockTicks = codeTicksAccessSeq16(armNextPC)+1;
|
||||
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
|
||||
}
|
||||
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1436,7 +1436,7 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC) + 3;
|
||||
} else {
|
||||
armState = true;
|
||||
reg[15].I &= 0xFFFFFFFC;
|
||||
reg[15].I &= 0xFFFFFFFC;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 4;
|
||||
ARM_PREFETCH;
|
||||
|
@ -1654,7 +1654,7 @@ case 0x28:
|
|||
reg[opcode&7].W.W0);
|
||||
clockTicks = dataTicksAccess16(address) + codeTicksAccess16(armNextPC) + 2;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0x88:
|
||||
case 0x89:
|
||||
case 0x8a:
|
||||
|
@ -1690,7 +1690,7 @@ case 0x28:
|
|||
CPUWriteMemory(address, reg[regist].I);
|
||||
clockTicks = dataTicksAccess32(address) + codeTicksAccess16(armNextPC) + 2;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0x98:
|
||||
case 0x99:
|
||||
case 0x9a:
|
||||
|
@ -1704,7 +1704,7 @@ case 0x28:
|
|||
u8 regist = (opcode >> 8) & 7;
|
||||
if (!busPrefetchCount)
|
||||
busPrefetch = busPrefetchEnable;
|
||||
u32 address = reg[13].I + ((opcode&255)<<2);
|
||||
u32 address = reg[13].I + ((opcode&255)<<2);
|
||||
reg[regist].I = CPUReadMemoryQuick(address);
|
||||
clockTicks = 3 + dataTicksAccess32(address) +
|
||||
codeTicksAccess16(armNextPC);
|
||||
|
@ -1723,7 +1723,7 @@ case 0x28:
|
|||
u8 regist = (opcode >> 8) & 7;
|
||||
reg[regist].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xa8:
|
||||
case 0xa9:
|
||||
case 0xaa:
|
||||
|
@ -1737,7 +1737,7 @@ case 0x28:
|
|||
u8 regist = (opcode >> 8) & 7;
|
||||
reg[regist].I = reg[13].I + ((opcode&255)<<2);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xb0:
|
||||
{
|
||||
// ADD SP, Imm
|
||||
|
@ -1828,7 +1828,7 @@ case 0x28:
|
|||
reg[13].I = temp;
|
||||
clockTicks += codeTicksAccess16(armNextPC)+2;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xbd:
|
||||
// POP {Rlist, PC}
|
||||
{
|
||||
|
@ -1858,7 +1858,7 @@ case 0x28:
|
|||
busPrefetchCount=0;
|
||||
clockTicks += codeTicksAccess16(armNextPC) + codeTicksAccess16(armNextPC) + 3;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
#define THUMB_STM_REG(val,r,b) \
|
||||
if(opcode & (val)) {\
|
||||
CPUWriteMemory(address, reg[(r)].I);\
|
||||
|
@ -1897,7 +1897,7 @@ case 0x28:
|
|||
THUMB_STM_REG(128, 7, regist);
|
||||
clockTicks = codeTicksAccess16(armNextPC)+1;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
#define THUMB_LDM_REG(val,r) \
|
||||
if(opcode & (val)) {\
|
||||
reg[(r)].I = CPUReadMemory(address);\
|
||||
|
@ -1953,14 +1953,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xd1:
|
||||
// BNE offset
|
||||
if(!Z_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -1968,14 +1968,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xd2:
|
||||
// BCS offset
|
||||
if(C_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -1983,14 +1983,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xd3:
|
||||
// BCC offset
|
||||
if(!C_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -1998,14 +1998,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xd4:
|
||||
// BMI offset
|
||||
if(N_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -2013,14 +2013,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xd5:
|
||||
// BPL offset
|
||||
if(!N_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -2028,14 +2028,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xd6:
|
||||
// BVS offset
|
||||
if(V_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -2043,14 +2043,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xd7:
|
||||
// BVC offset
|
||||
if(!V_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -2058,14 +2058,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xd8:
|
||||
// BHI offset
|
||||
if(C_FLAG && !Z_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -2073,14 +2073,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xd9:
|
||||
// BLS offset
|
||||
if(!C_FLAG || Z_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -2088,14 +2088,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xda:
|
||||
// BGE offset
|
||||
if(N_FLAG == V_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -2103,14 +2103,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xdb:
|
||||
// BLT offset
|
||||
if(N_FLAG != V_FLAG) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -2118,14 +2118,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xdc:
|
||||
// BGT offset
|
||||
if(!Z_FLAG && (N_FLAG == V_FLAG)) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -2133,14 +2133,14 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xdd:
|
||||
// BLE offset
|
||||
if(Z_FLAG || (N_FLAG != V_FLAG)) {
|
||||
#ifdef BKPT_SUPPORT
|
||||
UPDATE_OLD_REG
|
||||
#endif
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
reg[15].I += ((s8)(opcode & 0xFF)) << 1;
|
||||
armNextPC = reg[15].I;
|
||||
reg[15].I += 2;
|
||||
THUMB_PREFETCH;
|
||||
|
@ -2148,7 +2148,7 @@ case 0x28:
|
|||
codeTicksAccess16(armNextPC)+3;
|
||||
busPrefetchCount=0;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xdf:
|
||||
{
|
||||
// SWI #comment
|
||||
|
@ -2191,7 +2191,7 @@ case 0x28:
|
|||
reg[14].I = reg[15].I + (offset << 12);
|
||||
clockTicks = codeTicksAccessSeq16(armNextPC) + 1;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xf4:
|
||||
case 0xf5:
|
||||
case 0xf6:
|
||||
|
@ -2202,7 +2202,7 @@ case 0x28:
|
|||
reg[14].I = reg[15].I + ((offset << 12) | 0xFF800000);
|
||||
clockTicks = codeTicksAccessSeq16(armNextPC) + 1;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 0xf8:
|
||||
case 0xf9:
|
||||
case 0xfa:
|
||||
|
@ -2230,7 +2230,7 @@ case 0x28:
|
|||
// BKPT #comment
|
||||
extern void (*dbgSignal)(int,int);
|
||||
reg[15].I -= 2;
|
||||
armNextPC -= 2;
|
||||
armNextPC -= 2;
|
||||
dbgSignal(5, opcode & 255);
|
||||
return;
|
||||
#endif
|
||||
|
|
122
src/unzip.cpp
122
src/unzip.cpp
|
@ -16,7 +16,7 @@
|
|||
// along with this program; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
/* unzip.c -- IO on .zip files using zlib
|
||||
/* unzip.c -- IO on .zip files using zlib
|
||||
Version 0.15 beta, Mar 19th, 1998,
|
||||
|
||||
Read unzip.h for more info
|
||||
|
@ -162,7 +162,7 @@ local int unzlocal_getByte(FILE *fin,int *pi)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (ferror(fin))
|
||||
if (ferror(fin))
|
||||
return UNZ_ERRNO;
|
||||
else
|
||||
return UNZ_EOF;
|
||||
|
@ -171,7 +171,7 @@ local int unzlocal_getByte(FILE *fin,int *pi)
|
|||
|
||||
|
||||
/* ===========================================================================
|
||||
Reads a long in LSB order from the given gz_stream. Sets
|
||||
Reads a long in LSB order from the given gz_stream. Sets
|
||||
*/
|
||||
local int unzlocal_getShort (FILE *fin,uLong *pX)
|
||||
{
|
||||
|
@ -181,11 +181,11 @@ local int unzlocal_getShort (FILE *fin,uLong *pX)
|
|||
|
||||
err = unzlocal_getByte(fin,&i);
|
||||
x = (uLong)i;
|
||||
|
||||
|
||||
if (err==UNZ_OK)
|
||||
err = unzlocal_getByte(fin,&i);
|
||||
x += ((uLong)i)<<8;
|
||||
|
||||
|
||||
if (err==UNZ_OK)
|
||||
*pX = x;
|
||||
else
|
||||
|
@ -201,7 +201,7 @@ local int unzlocal_getLong (FILE *fin,uLong *pX)
|
|||
|
||||
err = unzlocal_getByte(fin,&i);
|
||||
x = (uLong)i;
|
||||
|
||||
|
||||
if (err==UNZ_OK)
|
||||
err = unzlocal_getByte(fin,&i);
|
||||
x += ((uLong)i)<<8;
|
||||
|
@ -213,7 +213,7 @@ local int unzlocal_getLong (FILE *fin,uLong *pX)
|
|||
if (err==UNZ_OK)
|
||||
err = unzlocal_getByte(fin,&i);
|
||||
x += ((uLong)i)<<24;
|
||||
|
||||
|
||||
if (err==UNZ_OK)
|
||||
*pX = x;
|
||||
else
|
||||
|
@ -256,7 +256,7 @@ local int strcmpcasenosensitive_internal (const char *fileName1,
|
|||
#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
|
||||
#endif
|
||||
|
||||
/*
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
|
@ -276,7 +276,7 @@ extern int ZEXPORT unzStringFileNameCompare (const char *fileName1,
|
|||
return strcmp(fileName1,fileName2);
|
||||
|
||||
return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
|
||||
}
|
||||
}
|
||||
|
||||
#define BUFREADCOMMENT (0x400)
|
||||
|
||||
|
@ -291,13 +291,13 @@ local uLong unzlocal_SearchCentralDir(FILE *fin)
|
|||
uLong uBackRead;
|
||||
uLong uMaxBack=0xffff; /* maximum size of global comment */
|
||||
uLong uPosFound=0;
|
||||
|
||||
|
||||
if (fseek(fin,0,SEEK_END) != 0)
|
||||
return 0;
|
||||
|
||||
|
||||
uSizeFile = ftell( fin );
|
||||
|
||||
|
||||
if (uMaxBack>uSizeFile)
|
||||
uMaxBack = uSizeFile;
|
||||
|
||||
|
@ -310,13 +310,13 @@ local uLong unzlocal_SearchCentralDir(FILE *fin)
|
|||
{
|
||||
uLong uReadSize,uReadPos ;
|
||||
int i;
|
||||
if (uBackRead+BUFREADCOMMENT>uMaxBack)
|
||||
if (uBackRead+BUFREADCOMMENT>uMaxBack)
|
||||
uBackRead = uMaxBack;
|
||||
else
|
||||
uBackRead+=BUFREADCOMMENT;
|
||||
uReadPos = uSizeFile-uBackRead ;
|
||||
|
||||
uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
|
||||
|
||||
uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
|
||||
(BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
|
||||
if (fseek(fin,uReadPos,SEEK_SET)!=0)
|
||||
break;
|
||||
|
@ -325,7 +325,7 @@ local uLong unzlocal_SearchCentralDir(FILE *fin)
|
|||
break;
|
||||
|
||||
for (i=(int)uReadSize-3; (i--)>0;)
|
||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
||||
{
|
||||
uPosFound = uReadPos+i;
|
||||
|
@ -355,12 +355,12 @@ extern unzFile ZEXPORT unzOpen (const char *path)
|
|||
uLong central_pos,uL;
|
||||
FILE * fin ;
|
||||
|
||||
uLong number_disk; /* number of the current dist, used for
|
||||
uLong number_disk; /* number of the current dist, used for
|
||||
spaning ZIP, unsupported, always 0*/
|
||||
uLong number_disk_with_CD; /* number the the disk with central dir, used
|
||||
for spaning ZIP, unsupported, always 0*/
|
||||
uLong number_entry_CD; /* total number of entries in
|
||||
the central dir
|
||||
the central dir
|
||||
(same than number_entry on nospan) */
|
||||
|
||||
int err=UNZ_OK;
|
||||
|
@ -408,7 +408,7 @@ extern unzFile ZEXPORT unzOpen (const char *path)
|
|||
if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)
|
||||
err=UNZ_ERRNO;
|
||||
|
||||
/* offset of start of central directory with respect to the
|
||||
/* offset of start of central directory with respect to the
|
||||
starting disk number */
|
||||
if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)
|
||||
err=UNZ_ERRNO;
|
||||
|
@ -417,7 +417,7 @@ extern unzFile ZEXPORT unzOpen (const char *path)
|
|||
if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)
|
||||
err=UNZ_ERRNO;
|
||||
|
||||
if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
|
||||
if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
|
||||
(err==UNZ_OK))
|
||||
err=UNZ_BADZIPFILE;
|
||||
|
||||
|
@ -432,12 +432,12 @@ extern unzFile ZEXPORT unzOpen (const char *path)
|
|||
(us.offset_central_dir+us.size_central_dir);
|
||||
us.central_pos = central_pos;
|
||||
us.pfile_in_zip_read = NULL;
|
||||
|
||||
|
||||
|
||||
s=(unz_s*)ALLOC(sizeof(unz_s));
|
||||
*s=us;
|
||||
unzGoToFirstFile((unzFile)s);
|
||||
return (unzFile)s;
|
||||
unzGoToFirstFile((unzFile)s);
|
||||
return (unzFile)s;
|
||||
}
|
||||
|
||||
|
||||
|
@ -499,7 +499,7 @@ local void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz *ptm)
|
|||
*/
|
||||
local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
unz_file_info_internal
|
||||
unz_file_info_internal
|
||||
*pfile_info_internal,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
|
@ -604,7 +604,7 @@ local int unzlocal_GetCurrentFileInfoInternal (unzFile file,
|
|||
lSeek -= uSizeRead;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((err==UNZ_OK) && (extraField!=NULL))
|
||||
{
|
||||
uLong uSizeRead ;
|
||||
|
@ -624,9 +624,9 @@ local int unzlocal_GetCurrentFileInfoInternal (unzFile file,
|
|||
lSeek += file_info.size_file_extra - uSizeRead;
|
||||
}
|
||||
else
|
||||
lSeek+=file_info.size_file_extra;
|
||||
lSeek+=file_info.size_file_extra;
|
||||
|
||||
|
||||
|
||||
if ((err==UNZ_OK) && (szComment!=NULL))
|
||||
{
|
||||
uLong uSizeRead ;
|
||||
|
@ -710,7 +710,7 @@ extern int ZEXPORT unzGoToFirstFile (unzFile file)
|
|||
*/
|
||||
extern int ZEXPORT unzGoToNextFile (unzFile file)
|
||||
{
|
||||
unz_s* s;
|
||||
unz_s* s;
|
||||
int err;
|
||||
|
||||
if (file==NULL)
|
||||
|
@ -744,10 +744,10 @@ extern int ZEXPORT unzLocateFile (unzFile file,
|
|||
const char *szFileName,
|
||||
int iCaseSensitivity)
|
||||
{
|
||||
unz_s* s;
|
||||
unz_s* s;
|
||||
int err;
|
||||
|
||||
|
||||
|
||||
uLong num_fileSaved;
|
||||
uLong pos_in_central_dirSaved;
|
||||
|
||||
|
@ -852,7 +852,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s,
|
|||
|
||||
if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */
|
||||
err=UNZ_ERRNO;
|
||||
else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
|
||||
else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
|
||||
((uFlags & 8)==0))
|
||||
err=UNZ_BADZIPFILE;
|
||||
|
||||
|
@ -874,7 +874,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s,
|
|||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error and the file is opened, the return value is UNZ_OK.
|
||||
|
@ -919,7 +919,7 @@ extern int ZEXPORT unzOpenCurrentFile (unzFile file)
|
|||
}
|
||||
|
||||
pfile_in_zip_read_info->stream_initialised=0;
|
||||
|
||||
|
||||
if ((s->cur_file_info.compression_method!=0) &&
|
||||
(s->cur_file_info.compression_method!=Z_DEFLATED))
|
||||
err=UNZ_BADZIPFILE;
|
||||
|
@ -938,29 +938,29 @@ extern int ZEXPORT unzOpenCurrentFile (unzFile file)
|
|||
{
|
||||
pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
|
||||
pfile_in_zip_read_info->stream.zfree = (free_func)0;
|
||||
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
|
||||
|
||||
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
|
||||
|
||||
err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
|
||||
if (err == Z_OK)
|
||||
pfile_in_zip_read_info->stream_initialised=1;
|
||||
/* windowBits is passed < 0 to tell that there is no zlib header.
|
||||
* Note that in this case inflate *requires* an extra "dummy" byte
|
||||
* after the compressed stream in order to complete decompression and
|
||||
* return Z_STREAM_END.
|
||||
* In unzip, i don't wait absolutely Z_STREAM_END because I known the
|
||||
* return Z_STREAM_END.
|
||||
* In unzip, i don't wait absolutely Z_STREAM_END because I known the
|
||||
* size of both compressed and uncompressed data
|
||||
*/
|
||||
}
|
||||
pfile_in_zip_read_info->rest_read_compressed =
|
||||
pfile_in_zip_read_info->rest_read_compressed =
|
||||
s->cur_file_info.compressed_size ;
|
||||
pfile_in_zip_read_info->rest_read_uncompressed =
|
||||
pfile_in_zip_read_info->rest_read_uncompressed =
|
||||
s->cur_file_info.uncompressed_size ;
|
||||
|
||||
|
||||
pfile_in_zip_read_info->pos_in_zipfile =
|
||||
s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
|
||||
|
||||
pfile_in_zip_read_info->pos_in_zipfile =
|
||||
s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
|
||||
iSizeVar;
|
||||
|
||||
|
||||
pfile_in_zip_read_info->stream.avail_in = (uInt)0;
|
||||
|
||||
|
||||
|
@ -1002,9 +1002,9 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
|||
pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
|
||||
|
||||
pfile_in_zip_read_info->stream.avail_out = (uInt)len;
|
||||
|
||||
|
||||
if (len>pfile_in_zip_read_info->rest_read_uncompressed)
|
||||
pfile_in_zip_read_info->stream.avail_out =
|
||||
pfile_in_zip_read_info->stream.avail_out =
|
||||
(uInt)pfile_in_zip_read_info->rest_read_uncompressed;
|
||||
|
||||
while (pfile_in_zip_read_info->stream.avail_out>0)
|
||||
|
@ -1018,7 +1018,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
|||
if (uReadThis == 0)
|
||||
return UNZ_EOF;
|
||||
if (fseek(pfile_in_zip_read_info->file,
|
||||
pfile_in_zip_read_info->pos_in_zipfile +
|
||||
pfile_in_zip_read_info->pos_in_zipfile +
|
||||
pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)
|
||||
return UNZ_ERRNO;
|
||||
if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,
|
||||
|
@ -1027,8 +1027,8 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
|||
pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
|
||||
|
||||
pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
|
||||
|
||||
pfile_in_zip_read_info->stream.next_in =
|
||||
|
||||
pfile_in_zip_read_info->stream.next_in =
|
||||
(Bytef*)pfile_in_zip_read_info->read_buffer;
|
||||
pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
|
||||
}
|
||||
|
@ -1036,16 +1036,16 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
|||
if (pfile_in_zip_read_info->compression_method==0)
|
||||
{
|
||||
uInt uDoCopy,i ;
|
||||
if (pfile_in_zip_read_info->stream.avail_out <
|
||||
if (pfile_in_zip_read_info->stream.avail_out <
|
||||
pfile_in_zip_read_info->stream.avail_in)
|
||||
uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
|
||||
else
|
||||
uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
|
||||
|
||||
|
||||
for (i=0;i<uDoCopy;i++)
|
||||
*(pfile_in_zip_read_info->stream.next_out+i) =
|
||||
*(pfile_in_zip_read_info->stream.next_in+i);
|
||||
|
||||
|
||||
pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
|
||||
pfile_in_zip_read_info->stream.next_out,
|
||||
uDoCopy);
|
||||
|
@ -1077,8 +1077,8 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
|||
|
||||
uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
|
||||
uOutThis = uTotalOutAfter-uTotalOutBefore;
|
||||
|
||||
pfile_in_zip_read_info->crc32 =
|
||||
|
||||
pfile_in_zip_read_info->crc32 =
|
||||
crc32(pfile_in_zip_read_info->crc32,bufBefore,
|
||||
(uInt)(uOutThis));
|
||||
|
||||
|
@ -1086,10 +1086,10 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
|||
uOutThis;
|
||||
|
||||
iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
|
||||
|
||||
|
||||
if (err==Z_STREAM_END)
|
||||
return (iRead==0) ? UNZ_EOF : iRead;
|
||||
if (err!=Z_OK)
|
||||
if (err!=Z_OK)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1120,7 +1120,7 @@ extern z_off_t ZEXPORT unztell (unzFile file)
|
|||
|
||||
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
extern int ZEXPORT unzeof (unzFile file)
|
||||
{
|
||||
|
@ -1133,7 +1133,7 @@ extern int ZEXPORT unzeof (unzFile file)
|
|||
|
||||
if (pfile_in_zip_read_info==NULL)
|
||||
return UNZ_PARAMERROR;
|
||||
|
||||
|
||||
if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
|
||||
return 1;
|
||||
else
|
||||
|
@ -1151,7 +1151,7 @@ extern int ZEXPORT unzeof (unzFile file)
|
|||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
extern int ZEXPORT unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len)
|
||||
|
@ -1169,12 +1169,12 @@ extern int ZEXPORT unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len)
|
|||
if (pfile_in_zip_read_info==NULL)
|
||||
return UNZ_PARAMERROR;
|
||||
|
||||
size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
|
||||
size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
|
||||
pfile_in_zip_read_info->pos_local_extrafield);
|
||||
|
||||
if (buf==NULL)
|
||||
return (int)size_to_read;
|
||||
|
||||
|
||||
if (len>size_to_read)
|
||||
read_now = (uInt)size_to_read;
|
||||
else
|
||||
|
@ -1182,9 +1182,9 @@ extern int ZEXPORT unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len)
|
|||
|
||||
if (read_now==0)
|
||||
return 0;
|
||||
|
||||
|
||||
if (fseek(pfile_in_zip_read_info->file,
|
||||
pfile_in_zip_read_info->offset_local_extrafield +
|
||||
pfile_in_zip_read_info->offset_local_extrafield +
|
||||
pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)
|
||||
return UNZ_ERRNO;
|
||||
|
||||
|
|
22
src/unzip.h
22
src/unzip.h
|
@ -17,7 +17,7 @@
|
|||
// along with this program; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 0.15 beta, Mar 19th, 1998,
|
||||
|
||||
Copyright (C) 1998 Gilles Vollant
|
||||
|
@ -52,7 +52,7 @@
|
|||
|
||||
|
||||
*/
|
||||
/* for more info about .ZIP format, see
|
||||
/* for more info about .ZIP format, see
|
||||
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip */
|
||||
|
@ -71,7 +71,7 @@ extern "C" {
|
|||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
|
@ -88,7 +88,7 @@ typedef voidp unzFile;
|
|||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
|
@ -117,8 +117,8 @@ typedef struct unz_file_info_s
|
|||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
@ -195,7 +195,7 @@ extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
|||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
|
@ -246,8 +246,8 @@ extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
|||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
|
@ -268,7 +268,7 @@ extern z_off_t ZEXPORT unztell OF((unzFile file));
|
|||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
|
@ -283,7 +283,7 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
|||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ AVIWrite::AVIWrite()
|
|||
m_streamCompressed = NULL;
|
||||
m_streamSound = NULL;
|
||||
m_samplesSound = 0;
|
||||
|
||||
|
||||
AVIFileInit();
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ AVIWrite::~AVIWrite()
|
|||
|
||||
if(m_streamCompressed)
|
||||
AVIStreamClose(m_streamCompressed);
|
||||
|
||||
|
||||
if(m_stream)
|
||||
AVIStreamClose(m_stream);
|
||||
|
||||
|
@ -65,13 +65,13 @@ void AVIWrite::SetSoundFormat(WAVEFORMATEX *format)
|
|||
m_soundHeader.dwInitialFrames = 1;
|
||||
m_soundHeader.dwRate = format->nAvgBytesPerSec;
|
||||
m_soundHeader.dwSampleSize = format->nBlockAlign;
|
||||
|
||||
|
||||
// create the sound stream
|
||||
if(FAILED(AVIFileCreateStream(m_file, &m_streamSound, &m_soundHeader))) {
|
||||
m_failed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// setup the sound stream format
|
||||
if(FAILED(AVIStreamSetFormat(m_streamSound, 0 , (void *)&m_soundFormat,
|
||||
sizeof(WAVEFORMATEX)))) {
|
||||
|
@ -104,7 +104,7 @@ bool AVIWrite::Open(const char *filename)
|
|||
m_failed = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
ZeroMemory(&m_options, sizeof(AVICOMPRESSOPTIONS));
|
||||
m_arrayOptions[0] = &m_options;
|
||||
|
||||
|
@ -113,13 +113,13 @@ bool AVIWrite::Open(const char *filename)
|
|||
m_failed = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// create the compressed stream
|
||||
if(FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL))) {
|
||||
m_failed = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// setup the video stream format
|
||||
if(FAILED( AVIStreamSetFormat(m_streamCompressed, 0,
|
||||
&m_bitmap,
|
||||
|
@ -160,7 +160,7 @@ bool AVIWrite::AddFrame(const int frame, const char *bmp)
|
|||
{
|
||||
if (m_failed)
|
||||
return false;
|
||||
|
||||
|
||||
// write the frame to the video stream
|
||||
if(FAILED(AVIStreamWrite(m_streamCompressed,
|
||||
frame,
|
||||
|
|
|
@ -60,10 +60,10 @@ BEGIN_MESSAGE_MAP(AboutDialog, CDialog)
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// AboutDialog message handlers
|
||||
|
||||
BOOL AboutDialog::OnInitDialog()
|
||||
BOOL AboutDialog::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
|
||||
CWnd *p = GetDlgItem(IDC_TRANSLATOR_URL);
|
||||
if(p) {
|
||||
m_translator.SubclassDlgItem(IDC_TRANSLATOR_URL, this);
|
||||
|
|
|
@ -70,10 +70,10 @@ BEGIN_MESSAGE_MAP(AccelEditor, CDialog)
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// AccelEditor message handlers
|
||||
|
||||
BOOL AccelEditor::OnInitDialog()
|
||||
BOOL AccelEditor::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
|
||||
DIALOG_SIZER_START( sz )
|
||||
DIALOG_SIZER_ENTRY( IDC_STATIC1, DS_MoveX)
|
||||
DIALOG_SIZER_ENTRY( IDC_STATIC2, DS_MoveY)
|
||||
|
@ -97,7 +97,7 @@ BOOL AccelEditor::OnInitDialog()
|
|||
NULL);
|
||||
|
||||
InitCommands();
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ void AccelEditor::InitCommands()
|
|||
m_alreadyAffected.SetWindowText("");
|
||||
|
||||
POSITION pos = mgr.m_mapAccelString.GetStartPosition();
|
||||
|
||||
|
||||
while(pos != NULL) {
|
||||
CString command;
|
||||
WORD wID;
|
||||
|
@ -123,17 +123,17 @@ void AccelEditor::InitCommands()
|
|||
OnSelchangeCommands();
|
||||
}
|
||||
|
||||
void AccelEditor::OnCancel()
|
||||
void AccelEditor::OnCancel()
|
||||
{
|
||||
EndDialog(FALSE);
|
||||
}
|
||||
|
||||
void AccelEditor::OnOk()
|
||||
void AccelEditor::OnOk()
|
||||
{
|
||||
EndDialog(TRUE);
|
||||
}
|
||||
|
||||
void AccelEditor::OnSelchangeCommands()
|
||||
void AccelEditor::OnSelchangeCommands()
|
||||
{
|
||||
// Check if some commands exist.
|
||||
int index = m_commands.GetCurSel();
|
||||
|
@ -144,7 +144,7 @@ void AccelEditor::OnSelchangeCommands()
|
|||
m_currents.ResetContent();
|
||||
|
||||
CCmdAccelOb* pCmdAccel;
|
||||
|
||||
|
||||
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel)) {
|
||||
CAccelsOb* pAccel;
|
||||
CString szBuffer;
|
||||
|
@ -164,20 +164,20 @@ void AccelEditor::OnSelchangeCommands()
|
|||
|
||||
}
|
||||
|
||||
void AccelEditor::OnReset()
|
||||
void AccelEditor::OnReset()
|
||||
{
|
||||
mgr.Default();
|
||||
InitCommands(); // update the listboxes.
|
||||
}
|
||||
|
||||
void AccelEditor::OnAssign()
|
||||
void AccelEditor::OnAssign()
|
||||
{
|
||||
// Control if it's not already affected
|
||||
CCmdAccelOb* pCmdAccel;
|
||||
CAccelsOb* pAccel;
|
||||
WORD wIDCommand;
|
||||
POSITION pos;
|
||||
|
||||
|
||||
WORD wKey;
|
||||
bool bCtrl, bAlt, bShift;
|
||||
|
||||
|
@ -241,13 +241,13 @@ void AccelEditor::OnAssign()
|
|||
m_key.ResetKey();
|
||||
}
|
||||
|
||||
void AccelEditor::OnRemove()
|
||||
void AccelEditor::OnRemove()
|
||||
{
|
||||
// Some controls
|
||||
int indexCurrent = m_currents.GetCurSel();
|
||||
if (indexCurrent == LB_ERR)
|
||||
return;
|
||||
|
||||
|
||||
// 2nd part.
|
||||
int indexCmd = m_commands.GetCurSel();
|
||||
if (indexCmd == LB_ERR)
|
||||
|
|
|
@ -246,7 +246,7 @@ bool CAcceleratorManager::UpdateWndTable()
|
|||
arrayACCEL.Add(pACCEL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INT_PTR nAccel = arrayACCEL.GetSize();
|
||||
LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, nAccel * sizeof(ACCEL));
|
||||
if (!lpAccel) {
|
||||
|
@ -258,7 +258,7 @@ bool CAcceleratorManager::UpdateWndTable()
|
|||
}
|
||||
|
||||
for (iLoop = 0; iLoop < nAccel; iLoop++) {
|
||||
|
||||
|
||||
pACCEL = arrayACCEL.GetAt(iLoop);
|
||||
lpAccel[iLoop].fVirt = pACCEL->fVirt;
|
||||
lpAccel[iLoop].key = pACCEL->key;
|
||||
|
@ -419,7 +419,7 @@ bool CAcceleratorManager::CreateEntry(WORD wIDCommand, LPCTSTR szCommand)
|
|||
bool CAcceleratorManager::GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel)
|
||||
{
|
||||
ASSERT(pACCEL != NULL);
|
||||
|
||||
|
||||
CAccelsOb accel(pACCEL);
|
||||
accel.GetString(szAccel);
|
||||
|
||||
|
@ -493,7 +493,7 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
|||
OSVERSIONINFO info;
|
||||
info.dwOSVersionInfoSize = sizeof(info);
|
||||
GetVersionEx(&info);
|
||||
|
||||
|
||||
if(info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
|
||||
MENUITEMINFO info;
|
||||
char ss[128];
|
||||
|
@ -502,7 +502,7 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
|||
info.fMask = MIIM_ID | MIIM_SUBMENU;
|
||||
for(int i = 0; i < count; i++) {
|
||||
GetMenuItemInfo(menu, i, TRUE, &info);
|
||||
|
||||
|
||||
if(info.hSubMenu != NULL) {
|
||||
UpdateMenu(info.hSubMenu);
|
||||
} else {
|
||||
|
@ -518,15 +518,15 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
|||
int index = str.Find('\t');
|
||||
if(index != -1)
|
||||
str = str.Left(index);
|
||||
|
||||
|
||||
WORD command = info.wID;
|
||||
|
||||
|
||||
CCmdAccelOb *o;
|
||||
if(m_mapAccelTable.Lookup(command, o)) {
|
||||
if(o->m_Accels.GetCount()) {
|
||||
POSITION pos = o->m_Accels.GetHeadPosition();
|
||||
CAccelsOb *accel = o->m_Accels.GetNext(pos);
|
||||
|
||||
|
||||
CString s;
|
||||
accel->GetString(s);
|
||||
str += "\t";
|
||||
|
@ -542,13 +542,13 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
|||
MENUITEMINFO info;
|
||||
wchar_t ss[128];
|
||||
wchar_t str[512];
|
||||
|
||||
|
||||
ZeroMemory(&info, sizeof(info));
|
||||
info.cbSize = sizeof(info);
|
||||
info.fMask = MIIM_ID | MIIM_SUBMENU;
|
||||
for(int i = 0; i < count; i++) {
|
||||
GetMenuItemInfo(menu, i, TRUE, &info);
|
||||
|
||||
|
||||
if(info.hSubMenu != NULL) {
|
||||
UpdateMenu(info.hSubMenu);
|
||||
} else {
|
||||
|
@ -562,19 +562,19 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
|
|||
GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info2);
|
||||
|
||||
wcscpy(str, ss);
|
||||
|
||||
|
||||
wchar_t *p = wcschr(str, '\t');
|
||||
if(p)
|
||||
*p = 0;
|
||||
|
||||
|
||||
CCmdAccelOb *o;
|
||||
WORD command = info.wID;
|
||||
if(m_mapAccelTable.Lookup(command, o)) {
|
||||
if(o->m_Accels.GetCount()) {
|
||||
POSITION pos = o->m_Accels.GetHeadPosition();
|
||||
|
||||
|
||||
CAccelsOb *accel = o->m_Accels.GetNext(pos);
|
||||
|
||||
|
||||
CString s;
|
||||
accel->GetString(s);
|
||||
|
||||
|
@ -618,7 +618,7 @@ bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey)
|
|||
CCmdAccelOb* pCmdAccel;
|
||||
CAccelsOb* pAccel;
|
||||
DWORD dwIDAccelData, dwAccelData;
|
||||
BOOL bExistID;
|
||||
BOOL bExistID;
|
||||
int iIndex = 0;
|
||||
if(count) {
|
||||
WORD wKey;
|
||||
|
@ -628,10 +628,10 @@ bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey)
|
|||
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
|
||||
pCmdAccel->DeleteUserAccels();
|
||||
}
|
||||
|
||||
|
||||
while(iIndex < count) {
|
||||
dwIDAccelData = data[iIndex++];
|
||||
|
||||
|
||||
WORD wIDCommand = LOWORD(dwIDAccelData);
|
||||
bExistID = m_mapAccelTable.Lookup(wIDCommand, pCmdAccel);
|
||||
|
||||
|
@ -679,12 +679,12 @@ bool CAcceleratorManager::Write()
|
|||
{
|
||||
CDWordArray AccelsDatasArray;
|
||||
CDWordArray CmdDatasArray;
|
||||
|
||||
|
||||
int iCount = 0;
|
||||
CCmdAccelOb* pCmdAccel;
|
||||
CAccelsOb* pAccel;
|
||||
DWORD dwAccelData;
|
||||
|
||||
|
||||
WORD wKey;
|
||||
POSITION pos = m_mapAccelTable.GetStartPosition();
|
||||
while (pos != NULL) {
|
||||
|
@ -702,13 +702,13 @@ bool CAcceleratorManager::Write()
|
|||
|
||||
if (CmdDatasArray.GetSize() > 0) {
|
||||
CmdDatasArray.InsertAt(0, MAKELONG(pCmdAccel->m_wIDCommand, CmdDatasArray.GetSize()));
|
||||
|
||||
|
||||
AccelsDatasArray.Append(CmdDatasArray);
|
||||
iCount++;
|
||||
}
|
||||
}
|
||||
// AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount));
|
||||
|
||||
|
||||
INT_PTR count = AccelsDatasArray.GetSize();
|
||||
DWORD *data = (DWORD *)malloc(count * sizeof(DWORD));
|
||||
ASSERT(data != NULL);
|
||||
|
@ -736,7 +736,7 @@ bool CAcceleratorManager::CreateDefaultTable()
|
|||
{
|
||||
if (m_bDefaultTable)
|
||||
return false;
|
||||
|
||||
|
||||
CCmdAccelOb* pCmdAccel;
|
||||
CCmdAccelOb* pNewCmdAccel;
|
||||
|
||||
|
@ -749,14 +749,14 @@ bool CAcceleratorManager::CreateDefaultTable()
|
|||
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
|
||||
pNewCmdAccel = new CCmdAccelOb;
|
||||
ASSERT(pNewCmdAccel != NULL);
|
||||
|
||||
|
||||
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
|
||||
while (pos != NULL) {
|
||||
pAccel = pCmdAccel->m_Accels.GetNext(pos);
|
||||
if (!pAccel->m_bLocked) {
|
||||
pNewAccel = new CAccelsOb;
|
||||
ASSERT(pNewAccel != NULL);
|
||||
|
||||
|
||||
*pNewAccel = *pAccel;
|
||||
pNewCmdAccel->m_Accels.AddTail(pNewAccel);
|
||||
}
|
||||
|
@ -764,9 +764,9 @@ bool CAcceleratorManager::CreateDefaultTable()
|
|||
if (pNewCmdAccel->m_Accels.GetCount() != 0) {
|
||||
pNewCmdAccel->m_wIDCommand = pCmdAccel->m_wIDCommand;
|
||||
pNewCmdAccel->m_szCommand = pCmdAccel->m_szCommand;
|
||||
|
||||
|
||||
m_mapAccelTableSaved.SetAt(wKey, pNewCmdAccel);
|
||||
} else
|
||||
} else
|
||||
delete pNewCmdAccel;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class CAcceleratorManager : public CObject {
|
|||
bool Load();
|
||||
bool Write();
|
||||
// Get the initials accels, not the user's
|
||||
bool Default();
|
||||
bool Default();
|
||||
// Save a copy in the 2 maps called xxxSaved, which are used in case
|
||||
// of Default(), to reload the defaults accels.
|
||||
bool CreateDefaultTable();
|
||||
|
|
|
@ -74,22 +74,22 @@ BEGIN_MESSAGE_MAP(Associate, CDialog)
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Associate message handlers
|
||||
|
||||
BOOL Associate::OnInitDialog()
|
||||
BOOL Associate::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
|
||||
CenterWindow();
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void Associate::OnCancel()
|
||||
void Associate::OnCancel()
|
||||
{
|
||||
EndDialog(FALSE);
|
||||
}
|
||||
|
||||
void Associate::OnOk()
|
||||
void Associate::OnOk()
|
||||
{
|
||||
UpdateData();
|
||||
|
||||
|
@ -117,7 +117,7 @@ void Associate::OnOk()
|
|||
regAssociateType("VisualBoyAdvance.Binary",
|
||||
"Binary",
|
||||
commandPath);
|
||||
|
||||
|
||||
for(int i = 0; i < 7; i++) {
|
||||
if(mask & (1<<i)) {
|
||||
regCreateFileType(types[i],"VisualBoyAdvance.Binary");
|
||||
|
|
|
@ -95,12 +95,12 @@ void BitmapControl::OnDraw(CDC* dc)
|
|||
if(stretch) {
|
||||
bmpInfo->bmiHeader.biWidth = w;
|
||||
bmpInfo->bmiHeader.biHeight = -h;
|
||||
|
||||
|
||||
StretchDIBits(memDC.GetSafeHdc(),
|
||||
0,
|
||||
0,
|
||||
w1,
|
||||
h1,
|
||||
h1,
|
||||
0,
|
||||
0,
|
||||
w,
|
||||
|
@ -111,7 +111,7 @@ void BitmapControl::OnDraw(CDC* dc)
|
|||
SRCCOPY);
|
||||
} else {
|
||||
FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE)));
|
||||
|
||||
|
||||
bmpInfo->bmiHeader.biWidth = w;
|
||||
bmpInfo->bmiHeader.biHeight = -h;
|
||||
SetDIBitsToDevice(memDC.GetSafeHdc(),
|
||||
|
@ -133,7 +133,7 @@ void BitmapControl::OnDraw(CDC* dc)
|
|||
memDC.SelectObject(pOldBitmap);
|
||||
|
||||
bitmap.DeleteObject();
|
||||
memDC.DeleteDC();
|
||||
memDC.DeleteDC();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -154,18 +154,18 @@ void BitmapControl::Dump(CDumpContext& dc) const
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// BitmapControl message handlers
|
||||
|
||||
BOOL BitmapControl::OnEraseBkgnd(CDC* pDC)
|
||||
BOOL BitmapControl::OnEraseBkgnd(CDC* pDC)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void BitmapControl::OnSize(UINT nType, int cx, int cy)
|
||||
void BitmapControl::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
if(!stretch)
|
||||
CScrollView::OnSize(nType, cx, cy);
|
||||
}
|
||||
|
||||
void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
|
||||
void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
|
||||
{
|
||||
if(!data)
|
||||
return;
|
||||
|
@ -173,14 +173,14 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
|
|||
int y = pt.y;
|
||||
|
||||
WPARAM point;
|
||||
|
||||
|
||||
if(stretch) {
|
||||
RECT rect;
|
||||
GetClientRect(&rect);
|
||||
|
||||
|
||||
int height = rect.bottom - rect.top;
|
||||
int width = rect.right - rect.left;
|
||||
|
||||
|
||||
int xx = (x * w) / width;
|
||||
int yy = (y * h) / height;
|
||||
|
||||
|
@ -207,7 +207,7 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
|
|||
return;
|
||||
|
||||
point = p.x | (p.y<<16);
|
||||
|
||||
|
||||
int xxx = p.x / 8;
|
||||
int yyy = p.y / 8;
|
||||
|
||||
|
@ -217,7 +217,7 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
|
|||
i * w * 3], 8 * 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GetParent()->SendMessage(WM_MAPINFO,
|
||||
point,
|
||||
(LPARAM)colors);
|
||||
|
@ -282,6 +282,6 @@ bool BitmapControl::getStretch()
|
|||
return stretch;
|
||||
}
|
||||
|
||||
void BitmapControl::PostNcDestroy()
|
||||
void BitmapControl::PostNcDestroy()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ BEGIN_MESSAGE_MAP(BugReport, CDialog)
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// BugReport message handlers
|
||||
|
||||
void BugReport::OnCopy()
|
||||
void BugReport::OnCopy()
|
||||
{
|
||||
OpenClipboard();
|
||||
|
||||
|
@ -79,38 +79,38 @@ void BugReport::OnCopy()
|
|||
CString report;
|
||||
m_report.GetWindowText(report);
|
||||
|
||||
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
|
||||
(report.GetLength() + 1) * sizeof(CHAR));
|
||||
if (hglbCopy == NULL) {
|
||||
CloseClipboard();
|
||||
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
|
||||
(report.GetLength() + 1) * sizeof(CHAR));
|
||||
if (hglbCopy == NULL) {
|
||||
CloseClipboard();
|
||||
return;
|
||||
}
|
||||
|
||||
// Lock the handle and copy the text to the buffer.
|
||||
|
||||
LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy);
|
||||
memcpy(lptstrCopy, (const char *)report,
|
||||
report.GetLength() * sizeof(CHAR));
|
||||
lptstrCopy[report.GetLength()] = (TCHAR) 0; // null character
|
||||
GlobalUnlock(hglbCopy);
|
||||
|
||||
// Place the handle on the clipboard.
|
||||
|
||||
SetClipboardData(CF_TEXT, hglbCopy);
|
||||
}
|
||||
|
||||
// Lock the handle and copy the text to the buffer.
|
||||
|
||||
LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy);
|
||||
memcpy(lptstrCopy, (const char *)report,
|
||||
report.GetLength() * sizeof(CHAR));
|
||||
lptstrCopy[report.GetLength()] = (TCHAR) 0; // null character
|
||||
GlobalUnlock(hglbCopy);
|
||||
|
||||
// Place the handle on the clipboard.
|
||||
|
||||
SetClipboardData(CF_TEXT, hglbCopy);
|
||||
CloseClipboard();
|
||||
|
||||
systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard");
|
||||
}
|
||||
|
||||
void BugReport::OnOk()
|
||||
void BugReport::OnOk()
|
||||
{
|
||||
EndDialog(TRUE);
|
||||
}
|
||||
|
||||
BOOL BugReport::OnInitDialog()
|
||||
BOOL BugReport::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
|
||||
CenterWindow();
|
||||
|
||||
CString report = createReport();
|
||||
|
@ -118,7 +118,7 @@ BOOL BugReport::OnInitDialog()
|
|||
m_report.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)));
|
||||
|
||||
m_report.SetWindowText(report);
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ CString BugReport::createReport()
|
|||
strncpy(buffer, (const char *)&rom[0xa0], 12);
|
||||
buffer[12] = 0;
|
||||
AppendFormat(report, "Internal name: %s\r\n", buffer);
|
||||
|
||||
|
||||
strncpy(buffer, (const char *)&rom[0xac], 4);
|
||||
buffer[4] = 0;
|
||||
AppendFormat(report, "Game code : %s\r\n", buffer);
|
||||
|
@ -177,7 +177,7 @@ CString BugReport::createReport()
|
|||
u32 *end = (u32 *)((char *)rom+theApp.romSize);
|
||||
while(p < end) {
|
||||
u32 d = READ32LE(p);
|
||||
|
||||
|
||||
if(d == 0x52504545) {
|
||||
if(memcmp(p, "EEPROM_", 7) == 0) {
|
||||
res += (const char *)p;
|
||||
|
@ -212,7 +212,7 @@ CString BugReport::createReport()
|
|||
AppendFormat(report, "Game title : %s\r\n", buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AppendFormat(report, "Using BIOS : %d\r\n", theApp.useBiosFile);
|
||||
AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile);
|
||||
AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx);
|
||||
|
@ -227,9 +227,9 @@ CString BugReport::createReport()
|
|||
AppendFormat(report, "Blue shift : %08x\r\n", systemBlueShift);
|
||||
AppendFormat(report, "Layer setting: %04X\r\n", layerSettings);
|
||||
AppendFormat(report, "Mirroring : %d\r\n", mirroringEnable);
|
||||
AppendFormat(report, "Save type : %d (%d)\r\n",
|
||||
AppendFormat(report, "Save type : %d (%d)\r\n",
|
||||
theApp.winSaveType, cpuSaveType);
|
||||
AppendFormat(report, "Flash size : %08X (%08x)\r\n",
|
||||
AppendFormat(report, "Flash size : %08X (%08x)\r\n",
|
||||
theApp.winFlashSize, flashSize);
|
||||
AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable,
|
||||
rtcIsEnabled());
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// Version : 1.0 * Author : T.Maurel
|
||||
// Date : 17.08.98
|
||||
//
|
||||
// Remarks :
|
||||
// Remarks :
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -207,7 +207,7 @@ CAccelsOb::CAccelsOb()
|
|||
CAccelsOb::CAccelsOb(CAccelsOb* pFrom)
|
||||
{
|
||||
ASSERT(pFrom != NULL);
|
||||
|
||||
|
||||
m_cVirt = pFrom->m_cVirt;
|
||||
m_wKey = pFrom->m_wKey;
|
||||
m_bLocked = pFrom->m_bLocked;
|
||||
|
@ -231,7 +231,7 @@ CAccelsOb::CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked)
|
|||
CAccelsOb::CAccelsOb(LPACCEL pACCEL)
|
||||
{
|
||||
ASSERT(pACCEL != NULL);
|
||||
|
||||
|
||||
m_cVirt = pACCEL->fVirt;
|
||||
m_wKey = pACCEL->key;
|
||||
m_bLocked = false;
|
||||
|
@ -246,7 +246,7 @@ CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from)
|
|||
m_cVirt = from.m_cVirt;
|
||||
m_wKey = from.m_wKey;
|
||||
m_bLocked = from.m_bLocked;
|
||||
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -290,18 +290,18 @@ bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift)
|
|||
// CString szTemp;
|
||||
// GetString(szTemp);
|
||||
|
||||
|
||||
|
||||
bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false;
|
||||
bool bRet = (bCtrl == m_bCtrl);
|
||||
|
||||
|
||||
bool m_bAlt = (m_cVirt & FALT) ? true : false;
|
||||
bRet &= (bAlt == m_bAlt);
|
||||
|
||||
|
||||
bool m_bShift = (m_cVirt & FSHIFT) ? true : false;
|
||||
bRet &= (bShift == m_bShift);
|
||||
|
||||
|
||||
bRet &= static_cast<bool>(m_wKey == wKey);
|
||||
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ DWORD CAccelsOb::GetData()
|
|||
cLocalCodes = DEFAULT_ACCEL;
|
||||
else
|
||||
cLocalCodes = USER_ACCEL;
|
||||
|
||||
|
||||
WORD bCodes = MAKEWORD(m_cVirt, cLocalCodes);
|
||||
return MAKELONG(m_wKey, bCodes);
|
||||
}
|
||||
|
@ -328,10 +328,10 @@ DWORD CAccelsOb::GetData()
|
|||
bool CAccelsOb::SetData(DWORD dwDatas)
|
||||
{
|
||||
m_wKey = LOWORD(dwDatas);
|
||||
|
||||
|
||||
WORD bCodes = HIWORD(dwDatas);
|
||||
m_cVirt = LOBYTE(bCodes);
|
||||
|
||||
|
||||
BYTE cLocalCodes = HIBYTE(bCodes);
|
||||
m_bLocked = static_cast<bool>(cLocalCodes == DEFAULT_ACCEL);
|
||||
return true;
|
||||
|
@ -388,10 +388,10 @@ CCmdAccelOb::CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand)
|
|||
CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
|
||||
{
|
||||
ASSERT(szCommand != NULL);
|
||||
|
||||
|
||||
m_wIDCommand = wIDCommand;
|
||||
m_szCommand = szCommand;
|
||||
|
||||
|
||||
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
|
||||
ASSERT(pAccel != NULL);
|
||||
m_Accels.AddTail(pAccel);
|
||||
|
@ -439,10 +439,10 @@ void CCmdAccelOb::Add(CAccelsOb* pAccel)
|
|||
CCmdAccelOb& CCmdAccelOb::operator=(const CCmdAccelOb& from)
|
||||
{
|
||||
Reset();
|
||||
|
||||
|
||||
m_wIDCommand = from.m_wIDCommand;
|
||||
m_szCommand = from.m_szCommand;
|
||||
|
||||
|
||||
CAccelsOb* pAccel;
|
||||
POSITION pos = from.m_Accels.GetHeadPosition();
|
||||
while (pos != NULL) {
|
||||
|
@ -480,7 +480,7 @@ void CCmdAccelOb::Reset()
|
|||
{
|
||||
m_wIDCommand = 0;
|
||||
m_szCommand = "Empty command";
|
||||
|
||||
|
||||
CAccelsOb* pAccel;
|
||||
POSITION pos = m_Accels.GetHeadPosition();
|
||||
while (pos != NULL) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// Version : 1.0 * Author : T.Maurel
|
||||
// Date : 17.08.98
|
||||
//
|
||||
// Remarks :
|
||||
// Remarks :
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __CMDACCEL_OB_INCLUDE
|
||||
|
|
|
@ -63,7 +63,7 @@ void ColorButton::PreSubclassWindow()
|
|||
void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
||||
{
|
||||
ASSERT(lpDrawItemStruct);
|
||||
|
||||
|
||||
int r = (color & 0x1f) << 3;
|
||||
int g = (color & 0x3e0) >> 2;
|
||||
int b = (color & 0x7c00) >> 7;
|
||||
|
@ -82,8 +82,8 @@ void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
|||
DrawEdge(dc, &rect, EDGE_RAISED, BF_RECT);
|
||||
|
||||
InflateRect(&rect, -margins.cx, -margins.cy);
|
||||
|
||||
HBRUSH br = CreateSolidBrush((state & ODS_DISABLED) ?
|
||||
|
||||
HBRUSH br = CreateSolidBrush((state & ODS_DISABLED) ?
|
||||
::GetSysColor(COLOR_3DFACE) : RGB(r,g,b));
|
||||
|
||||
FillRect(dc, &rect, br);
|
||||
|
@ -92,7 +92,7 @@ void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
|||
InflateRect(&rect, -1, -1);
|
||||
DrawFocusRect(dc, &rect);
|
||||
}
|
||||
|
||||
|
||||
DeleteObject(br);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,12 +56,12 @@ BEGIN_MESSAGE_MAP(ColorControl, CWnd)
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ColorControl message handlers
|
||||
|
||||
void ColorControl::OnPaint()
|
||||
void ColorControl::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
}
|
||||
|
||||
BOOL ColorControl::OnEraseBkgnd(CDC* pDC)
|
||||
BOOL ColorControl::OnEraseBkgnd(CDC* pDC)
|
||||
{
|
||||
int r = (color & 0x1f) << 3;
|
||||
int g = (color & 0x3e0) >> 2;
|
||||
|
|
|
@ -167,7 +167,7 @@ struct {
|
|||
{ "OptionsSoundVolume1x", ID_OPTIONS_SOUND_VOLUME_1X },
|
||||
{ "OptionsSoundVolume2x", ID_OPTIONS_SOUND_VOLUME_2X },
|
||||
{ "OptionsSoundVolume3x", ID_OPTIONS_SOUND_VOLUME_3X },
|
||||
{ "OptionsSoundVolume4x", ID_OPTIONS_SOUND_VOLUME_4X },
|
||||
{ "OptionsSoundVolume4x", ID_OPTIONS_SOUND_VOLUME_4X },
|
||||
{ "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER },
|
||||
{ "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC },
|
||||
{ "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS },
|
||||
|
@ -236,13 +236,13 @@ bool winAccelGetID(const char *command, WORD& id)
|
|||
{
|
||||
if(!initialized) {
|
||||
int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
|
||||
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
winAccelStrings.SetAt(winAccelCommands[i].command, winAccelCommands[i].id);
|
||||
winAccelStrings.SetAt(winAccelCommands[i].command, winAccelCommands[i].id);
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
||||
return winAccelStrings.Lookup(command, id) ? true : false;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue