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:
Nach 2007-11-14 12:28:27 +00:00
parent 5be56cdac5
commit 3c06fa079f
181 changed files with 41361 additions and 41361 deletions

View File

@ -1,20 +1,20 @@
Developer Information File: Developer Information File:
- Don't use the global optimization switch (/Og) because it causes a black screen in Metroid Prime. - Don't use the global optimization switch (/Og) because it causes a black screen in Metroid Prime.
- Project Configurations: - Project Configurations:
- Debug: Debug ON | Optimizations OFF | UPX OFF - Debug: Debug ON | Optimizations OFF | UPX OFF
- Release: Debug OFF | Optimizations OFF | UPX OFF - Release: Debug OFF | Optimizations OFF | UPX OFF
- Optimized: Debug OFF | Optimizations ON | UPX ON - Optimized: Debug OFF | Optimizations ON | UPX ON
Software Used: Software Used:
OPTIONAL UPX 1.25 +/- OPTIONAL UPX 1.25 +/-
NEEDED nasm 0.98.39 +/- NEEDED nasm 0.98.39 +/-
INCLUDED zlib 1.2.3 +/- INCLUDED zlib 1.2.3 +/-
INCLUDED libpng 1.2.8 +/- INCLUDED libpng 1.2.8 +/-
NEEDED Microsoft Platform SDK 2003 SP1 +/- NEEDED Microsoft Platform SDK 2003 SP1 +/-
NEEDED Microsoft DirectX 9.0c SDK (June 2005) + NEEDED Microsoft DirectX 9.0c SDK (June 2005) +
NEEDED Microsoft Visual Studio .NET Professional 2003 German + NEEDED Microsoft Visual Studio .NET Professional 2003 German +
+ newer is ok + newer is ok
+/- newer and older is ok +/- newer and older is ok

View File

@ -1,81 +1,81 @@
VisualBoyAdvance S1.7.6 VisualBoyAdvance S1.7.6
Nintendo Game Boy / Game Boy Advance Emulator Nintendo Game Boy / Game Boy Advance Emulator
This program is distributed under the GNU General Public License This program is distributed under the GNU General Public License
http://www.gnu.org/licenses/gpl.html http://www.gnu.org/licenses/gpl.html
VBA Official Version 1.7.2 with changes by Spacy VBA Official Version 1.7.2 with changes by Spacy
Spacy51@gmx.de (Write in english or in german) Spacy51@gmx.de (Write in english or in german)
Special Build Aturhors Homepage: www.spacyhacks.de.vu Special Build Aturhors Homepage: www.spacyhacks.de.vu
Original Project Homepage: vba.ngemu.com Original Project Homepage: vba.ngemu.com
My aim: My aim:
I want to make this emulator fit my needs and hopefully the needs of others, 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 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). 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. If you need one of the removed features, just use the original VBA emulator.
Thanks go to: Thanks go to:
suanyuan For help in compilation and other fixes suanyuan For help in compilation and other fixes
Tauwasser For help in assembler Tauwasser For help in assembler
WingX For fixing a linker error WingX For fixing a linker error
The following changes have been made: The following changes have been made:
S1.7.6: S1.7.6:
Emu: Emu:
- Readded MMX macro - Readded MMX macro
- Updated zlib to 1.2.3 - Updated zlib to 1.2.3
- Changed some first start options - Changed some first start options
- Other small changes - Other small changes
- Put zlib & libpng in seperate Projects - Put zlib & libpng in seperate Projects
- Added some changes from the latest CVS source - Added some changes from the latest CVS source
- Small changes to ROM Header Info (just4fun) - Small changes to ROM Header Info (just4fun)
- Fixed the linker error (new&delete defined twice) - Fixed the linker error (new&delete defined twice)
Filters: Filters:
- Speeded up HQ3X code - Speeded up HQ3X code
- Fixed LQ2X using HQ2X functions - Fixed LQ2X using HQ2X functions
Display: Display:
- Added extended display mode selection - Added extended display mode selection
(Display Adapter, Resolution, Bit Depth, Frequency) (Display Adapter, Resolution, Bit Depth, Frequency)
- No more unnecessary black borders in full screen - No more unnecessary black borders in full screen
- Direct3D doesn't take the whole screen (only if you want) - Direct3D doesn't take the whole screen (only if you want)
- Direct3D shows menu and windows correct - Direct3D shows menu and windows correct
- Direct3D doesn't show a black screen if left fullscreen to Windows - Direct3D doesn't show a black screen if left fullscreen to Windows
- Changes on max scale are applied immediately - Changes on max scale are applied immediately
Sound: Sound:
- Updated sound to DirectSound8 - Updated sound to DirectSound8
S1.7.5: S1.7.5:
- Removed screen flickering when switching to GDI mode. - Removed screen flickering when switching to GDI mode.
- Changed some first start options. - Changed some first start options.
- Rearranged Menu - Rearranged Menu
- Added HQ3X in 32 bit mode - Added HQ3X in 32 bit mode
- Changed App Icon - Changed App Icon
- Added FINAL_VERSION definition again. - Added FINAL_VERSION definition again.
- Added 3x/4x filter support to OpenGL mode - Added 3x/4x filter support to OpenGL mode
- Some minor fixes - Some minor fixes
S1.7.4: S1.7.4:
- optimized build: (many thanks to suanyuan) - optimized build: (many thanks to suanyuan)
- libpng, zlib, MFC linked static - libpng, zlib, MFC linked static
- Target OS: Windows 2000 - Target OS: Windows 2000
- Keep in mind that HQ3X/HQ4X is NOT added - Keep in mind that HQ3X/HQ4X is NOT added
at the moment, but everything is ready for it at the moment, but everything is ready for it
S1.7.3: S1.7.3:
- Optimized build and project file - Optimized build and project file
- Removed Skin support - Removed Skin support
- Removed SDL support - Removed SDL support
- Removed Linux support - Removed Linux support
- Removed Motion Blur Experimental Filter (the none-IFB version) - Removed Motion Blur Experimental Filter (the none-IFB version)
- Reworked GDI - Reworked GDI
- 3x / 4x filter support - 3x / 4x filter support
- Fullscreen modes available - Fullscreen modes available

View File

@ -1,340 +1,340 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc. Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
Preamble Preamble
The licenses for most software are designed to take away your The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free 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 software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to the GNU Library General Public License instead.) You can apply it to
your programs, too. your programs, too.
When we speak of free software, we are referring to freedom, not When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for 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 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 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. in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid 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. anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it. distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether 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 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 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 source code. And you must show them these terms so they know their
rights. rights.
We protect your rights with two steps: (1) copyright the software, and We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy, (2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software. distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we 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 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 that any problems introduced by others will not reflect on the original
authors' reputations. authors' reputations.
Finally, any free program is threatened constantly by software Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any 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. patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and The precise terms and conditions for copying, distribution and
modification follow. modification follow.
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains 0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below, 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" 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: 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, that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you". the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program). Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does. Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's 1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty; 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 and give any other recipients of the Program a copy of this License
along with the Program. along with the Program.
You may charge a fee for the physical act of transferring a copy, and 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. 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 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 of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1 distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions: above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change. 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 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 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 part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License. parties under the terms of this License.
c) If the modified program normally reads commands interactively c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on does not normally print such an announcement, your work based on
the Program is not required to print an announcement.) the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program, identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you 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 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 on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it. 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 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 your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or exercise the right to control the distribution of derivative or
collective works based on the Program. collective works based on the Program.
In addition, mere aggregation of another work not 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 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 a storage or distribution medium does not bring the other work under
the scope of this License. the scope of this License.
3. You may copy and distribute the Program (or a work based on it, 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 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: Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or, 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 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 years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or, customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such received the program in object code or executable form with such
an offer, in accord with Subsection b above.) an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component operating system on which the executable runs, unless that component
itself accompanies the executable. itself accompanies the executable.
If distribution of executable or object code is made by offering If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not distribution of the source code, even though third parties are not
compelled to copy the source along with the object code. compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program 4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License. void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such this License will not have their licenses terminated so long as such
parties remain in full compliance. parties remain in full compliance.
5. You are not required to accept this License, since you have not 5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying all its terms and conditions for copying, distributing or modifying
the Program or works based on it. the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the 6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein. restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to You are not responsible for enforcing compliance by third parties to
this License. this License.
7. If, as a consequence of a court judgment or allegation of patent 7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then 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 the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program. refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other apply and the section as a whole is intended to apply in other
circumstances. circumstances.
It is not the purpose of this section to induce you to infringe any 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 patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is integrity of the free software distribution system, which is
implemented by public license practices. Many people have made implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that 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 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 to distribute software through any other system and a licensee cannot
impose that choice. impose that choice.
This section is intended to make thoroughly clear what is believed to This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License. be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in 8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License. the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions 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 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 be similar in spirit to the present version, but may differ in detail to
address new problems or concerns. address new problems or concerns.
Each version is given a distinguishing version number. If the Program Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any 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 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 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 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 this License, you may choose any version ever published by the Free Software
Foundation. Foundation.
10. If you wish to incorporate parts of the Program into other free 10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals 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 preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally. of promoting the sharing and reuse of software generally.
NO WARRANTY NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS 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 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION. REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 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 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, REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 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 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 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 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest 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 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. 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 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 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 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. 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.> <one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author> Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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 You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 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. 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 If the program is interactive, make it output a short notice like this
when it starts in an interactive mode: when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details. under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate 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 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 be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program. mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your 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 school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names: necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker. `Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989 <signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice Ty Coon, President of Vice
This General Public License does not permit incorporating your program into This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the 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 library. If this is what you want to do, use the GNU Library General
Public License instead of this License. Public License instead of this License.

File diff suppressed because it is too large Load Diff

View File

@ -23,10 +23,10 @@ extern "C"
void BilinearMMXGrid1 (u16 * A, u16 * B, u16 * C, u16 * D, void BilinearMMXGrid1 (u16 * A, u16 * B, u16 * C, u16 * D,
u16 * dx, u16 * dy, u8 *dP); u16 * dx, u16 * dy, u8 *dP);
void EndMMX (); void EndMMX ();
bool cpu_mmx = 1; bool cpu_mmx = 1;
#endif #endif
} }
static u32 colorMask = 0xF7DEF7DE; static u32 colorMask = 0xF7DEF7DE;
static u32 lowPixelMask = 0x08210821; static u32 lowPixelMask = 0x08210821;
static u32 qcolorMask = 0xE79CE79C; static u32 qcolorMask = 0xE79CE79C;
@ -50,7 +50,7 @@ int Init_2xSaI(u32 BitFormat)
greenMask = 0x7E0; greenMask = 0x7E0;
qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xF7DEF7DE; qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xF7DEF7DE;
hq2x_init(16); hq2x_init(16);
RGB_LOW_BITS_MASK = 0x0821; RGB_LOW_BITS_MASK = 0x0821;
} else if (BitFormat == 555) { } else if (BitFormat == 555) {
colorMask = 0x7BDE7BDE; colorMask = 0x7BDE7BDE;
lowPixelMask = 0x04210421; lowPixelMask = 0x04210421;
@ -60,7 +60,7 @@ int Init_2xSaI(u32 BitFormat)
greenMask = 0x3E0; greenMask = 0x3E0;
qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0x7BDE7BDE; qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0x7BDE7BDE;
hq2x_init(15); hq2x_init(15);
RGB_LOW_BITS_MASK = 0x0421; RGB_LOW_BITS_MASK = 0x0421;
} else { } else {
return 0; return 0;
} }
@ -71,14 +71,14 @@ int Init_2xSaI(u32 BitFormat)
qlowpixelMask = 0x030303; qlowpixelMask = 0x030303;
qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xfefefe; qRGB_COLOR_MASK[0] = qRGB_COLOR_MASK[1] = 0xfefefe;
hq2x_init(32); hq2x_init(32);
RGB_LOW_BITS_MASK = 0x010101; RGB_LOW_BITS_MASK = 0x010101;
} else } else
return 0; return 0;
#ifdef MMX #ifdef MMX
Init_2xSaIMMX (BitFormat); Init_2xSaIMMX (BitFormat);
#endif #endif
return 1; return 1;
} }
@ -110,7 +110,7 @@ static inline int GetResult2 (u32 A, u32 B, u32 C, u32 D,
int x = 0; int x = 0;
int y = 0; int y = 0;
int r = 0; int r = 0;
if (A == C) if (A == C)
x += 1; x += 1;
else if (B == C) else if (B == C)
@ -131,7 +131,7 @@ static inline int GetResult (u32 A, u32 B, u32 C, u32 D)
int x = 0; int x = 0;
int y = 0; int y = 0;
int r = 0; int r = 0;
if (A == C) if (A == C)
x += 1; x += 1;
else if (B == C) 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); ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2);
register u32 y = (A & qlowpixelMask) + register u32 y = (A & qlowpixelMask) +
(B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask); (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask);
y = (y >> 2) & qlowpixelMask; y = (y >> 2) & qlowpixelMask;
return x + y; return x + y;
} }
@ -196,7 +196,7 @@ static inline int GetResult2_32 (u32 A, u32 B, u32 C, u32 D,
int x = 0; int x = 0;
int y = 0; int y = 0;
int r = 0; int r = 0;
if (A == C) if (A == C)
x += 1; x += 1;
else if (B == C) else if (B == C)
@ -241,43 +241,43 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
#endif #endif
{ {
inc_bP = 1; inc_bP = 1;
for (; height; height--) { for (; height; height--) {
bP = (u16 *) srcPtr; bP = (u16 *) srcPtr;
dP = (u8 *) dstPtr; dP = (u8 *) dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) { for (u32 finish = width; finish; finish -= inc_bP) {
u32 color4, color5, color6; u32 color4, color5, color6;
u32 color1, color2, color3; u32 color1, color2, color3;
u32 colorA0, colorA1, colorA2, colorA3, u32 colorA0, colorA1, colorA2, colorA3,
colorB0, colorB1, colorB2, colorB3, colorS1, colorS2; colorB0, colorB1, colorB2, colorB3, colorS1, colorS2;
u32 product1a, product1b, product2a, product2b; u32 product1a, product1b, product2a, product2b;
//--------------------------------------- B1 B2 //--------------------------------------- B1 B2
// 4 5 6 S2 // 4 5 6 S2
// 1 2 3 S1 // 1 2 3 S1
// A1 A2 // A1 A2
colorB0 = *(bP - Nextline - 1); colorB0 = *(bP - Nextline - 1);
colorB1 = *(bP - Nextline); colorB1 = *(bP - Nextline);
colorB2 = *(bP - Nextline + 1); colorB2 = *(bP - Nextline + 1);
colorB3 = *(bP - Nextline + 2); colorB3 = *(bP - Nextline + 2);
color4 = *(bP - 1); color4 = *(bP - 1);
color5 = *(bP); color5 = *(bP);
color6 = *(bP + 1); color6 = *(bP + 1);
colorS2 = *(bP + 2); colorS2 = *(bP + 2);
color1 = *(bP + Nextline - 1); color1 = *(bP + Nextline - 1);
color2 = *(bP + Nextline); color2 = *(bP + Nextline);
color3 = *(bP + Nextline + 1); color3 = *(bP + Nextline + 1);
colorS1 = *(bP + Nextline + 2); colorS1 = *(bP + Nextline + 2);
colorA0 = *(bP + Nextline + Nextline - 1); colorA0 = *(bP + Nextline + Nextline - 1);
colorA1 = *(bP + Nextline + Nextline); colorA1 = *(bP + Nextline + Nextline);
colorA2 = *(bP + Nextline + Nextline + 1); colorA2 = *(bP + Nextline + Nextline + 1);
colorA3 = *(bP + Nextline + Nextline + 2); colorA3 = *(bP + Nextline + Nextline + 2);
//-------------------------------------- //--------------------------------------
if (color2 == color6 && color5 != color3) { if (color2 == color6 && color5 != color3) {
product2b = product1b = color2; product2b = product1b = color2;
@ -285,12 +285,12 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
product2b = product1b = color5; product2b = product1b = color5;
} else if (color5 == color3 && color2 == color6) { } else if (color5 == color3 && color2 == color6) {
register int r = 0; register int r = 0;
r += GetResult (color6, color5, color1, colorA1); r += GetResult (color6, color5, color1, colorA1);
r += GetResult (color6, color5, color4, colorB1); r += GetResult (color6, color5, color4, colorB1);
r += GetResult (color6, color5, colorA2, colorS1); r += GetResult (color6, color5, colorA2, colorS1);
r += GetResult (color6, color5, colorB2, colorS2); r += GetResult (color6, color5, colorB2, colorS2);
if (r > 0) if (r > 0)
product2b = product1b = color6; product2b = product1b = color6;
else if (r < 0) else if (r < 0)
@ -309,7 +309,7 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
Q_INTERPOLATE (color2, color2, color2, color3); Q_INTERPOLATE (color2, color2, color2, color3);
else else
product2b = INTERPOLATE (color2, color3); product2b = INTERPOLATE (color2, color3);
if (color6 == color3 && color6 == colorB1 if (color6 == color3 && color6 == colorB1
&& color5 != colorB2 && color6 != colorB0) && color5 != colorB2 && color6 != colorB0)
product1b = product1b =
@ -321,7 +321,7 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
else else
product1b = INTERPOLATE (color5, color6); product1b = INTERPOLATE (color5, color6);
} }
if (color5 == color3 && color2 != color6 && color4 == color5 if (color5 == color3 && color2 != color6 && color4 == color5
&& color5 != colorA2) && color5 != colorA2)
product2a = INTERPOLATE (color2, color5); product2a = INTERPOLATE (color2, color5);
@ -331,7 +331,7 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
product2a = INTERPOLATE (color2, color5); product2a = INTERPOLATE (color2, color5);
else else
product2a = color2; product2a = color2;
if (color2 == color6 && color5 != color3 && color1 == color2 if (color2 == color6 && color5 != color3 && color1 == color2
&& color2 != colorB2) && color2 != colorB2)
product1a = INTERPOLATE (color2, color5); product1a = INTERPOLATE (color2, color5);
@ -341,7 +341,7 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
product1a = INTERPOLATE (color2, color5); product1a = INTERPOLATE (color2, color5);
else else
product1a = color5; product1a = color5;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
product1a = (product1a << 16) | product1b; product1a = (product1a << 16) | product1b;
product2a = (product2a << 16) | product2b; product2a = (product2a << 16) | product2b;
@ -349,14 +349,14 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
product1a = product1a | (product1b << 16); product1a = product1a | (product1b << 16);
product2a = product2a | (product2b << 16); product2a = product2a | (product2b << 16);
#endif #endif
*((u32 *) dP) = product1a; *((u32 *) dP) = product1a;
*((u32 *) (dP + dstPitch)) = product2a; *((u32 *) (dP + dstPitch)) = product2a;
bP += inc_bP; bP += inc_bP;
dP += sizeof (u32); dP += sizeof (u32);
} // end of for ( finish= width etc..) } // end of for ( finish= width etc..)
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
deltaPtr += srcPitch; deltaPtr += srcPitch;
@ -373,43 +373,43 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
u32 inc_bP; u32 inc_bP;
u32 Nextline = srcPitch >> 2; u32 Nextline = srcPitch >> 2;
inc_bP = 1; inc_bP = 1;
for (; height; height--) { for (; height; height--) {
bP = (u32 *) srcPtr; bP = (u32 *) srcPtr;
dP = (u32 *) dstPtr; dP = (u32 *) dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) { for (u32 finish = width; finish; finish -= inc_bP) {
u32 color4, color5, color6; u32 color4, color5, color6;
u32 color1, color2, color3; u32 color1, color2, color3;
u32 colorA0, colorA1, colorA2, colorA3, u32 colorA0, colorA1, colorA2, colorA3,
colorB0, colorB1, colorB2, colorB3, colorS1, colorS2; colorB0, colorB1, colorB2, colorB3, colorS1, colorS2;
u32 product1a, product1b, product2a, product2b; u32 product1a, product1b, product2a, product2b;
//--------------------------------------- B1 B2 //--------------------------------------- B1 B2
// 4 5 6 S2 // 4 5 6 S2
// 1 2 3 S1 // 1 2 3 S1
// A1 A2 // A1 A2
colorB0 = *(bP - Nextline - 1); colorB0 = *(bP - Nextline - 1);
colorB1 = *(bP - Nextline); colorB1 = *(bP - Nextline);
colorB2 = *(bP - Nextline + 1); colorB2 = *(bP - Nextline + 1);
colorB3 = *(bP - Nextline + 2); colorB3 = *(bP - Nextline + 2);
color4 = *(bP - 1); color4 = *(bP - 1);
color5 = *(bP); color5 = *(bP);
color6 = *(bP + 1); color6 = *(bP + 1);
colorS2 = *(bP + 2); colorS2 = *(bP + 2);
color1 = *(bP + Nextline - 1); color1 = *(bP + Nextline - 1);
color2 = *(bP + Nextline); color2 = *(bP + Nextline);
color3 = *(bP + Nextline + 1); color3 = *(bP + Nextline + 1);
colorS1 = *(bP + Nextline + 2); colorS1 = *(bP + Nextline + 2);
colorA0 = *(bP + Nextline + Nextline - 1); colorA0 = *(bP + Nextline + Nextline - 1);
colorA1 = *(bP + Nextline + Nextline); colorA1 = *(bP + Nextline + Nextline);
colorA2 = *(bP + Nextline + Nextline + 1); colorA2 = *(bP + Nextline + Nextline + 1);
colorA3 = *(bP + Nextline + Nextline + 2); colorA3 = *(bP + Nextline + Nextline + 2);
//-------------------------------------- //--------------------------------------
if (color2 == color6 && color5 != color3) { if (color2 == color6 && color5 != color3) {
product2b = product1b = color2; product2b = product1b = color2;
@ -417,12 +417,12 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
product2b = product1b = color5; product2b = product1b = color5;
} else if (color5 == color3 && color2 == color6) { } else if (color5 == color3 && color2 == color6) {
register int r = 0; register int r = 0;
r += GetResult (color6, color5, color1, colorA1); r += GetResult (color6, color5, color1, colorA1);
r += GetResult (color6, color5, color4, colorB1); r += GetResult (color6, color5, color4, colorB1);
r += GetResult (color6, color5, colorA2, colorS1); r += GetResult (color6, color5, colorA2, colorS1);
r += GetResult (color6, color5, colorB2, colorS2); r += GetResult (color6, color5, colorB2, colorS2);
if (r > 0) if (r > 0)
product2b = product1b = color6; product2b = product1b = color6;
else if (r < 0) else if (r < 0)
@ -441,7 +441,7 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
Q_INTERPOLATE (color2, color2, color2, color3); Q_INTERPOLATE (color2, color2, color2, color3);
else else
product2b = INTERPOLATE (color2, color3); product2b = INTERPOLATE (color2, color3);
if (color6 == color3 && color6 == colorB1 if (color6 == color3 && color6 == colorB1
&& color5 != colorB2 && color6 != colorB0) && color5 != colorB2 && color6 != colorB0)
product1b = product1b =
@ -453,7 +453,7 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
else else
product1b = INTERPOLATE (color5, color6); product1b = INTERPOLATE (color5, color6);
} }
if (color5 == color3 && color2 != color6 && color4 == color5 if (color5 == color3 && color2 != color6 && color4 == color5
&& color5 != colorA2) && color5 != colorA2)
product2a = INTERPOLATE (color2, color5); product2a = INTERPOLATE (color2, color5);
@ -463,7 +463,7 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
product2a = INTERPOLATE (color2, color5); product2a = INTERPOLATE (color2, color5);
else else
product2a = color2; product2a = color2;
if (color2 == color6 && color5 != color3 && color1 == color2 if (color2 == color6 && color5 != color3 && color1 == color2
&& color2 != colorB2) && color2 != colorB2)
product1a = INTERPOLATE (color2, color5); product1a = INTERPOLATE (color2, color5);
@ -477,18 +477,18 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
*(dP+1) = product1b; *(dP+1) = product1b;
*(dP + (dstPitch >> 2)) = product2a; *(dP + (dstPitch >> 2)) = product2a;
*(dP + (dstPitch >> 2) + 1) = product2b; *(dP + (dstPitch >> 2) + 1) = product2b;
bP += inc_bP; bP += inc_bP;
dP += 2; dP += 2;
} // end of for ( finish= width etc..) } // end of for ( finish= width etc..)
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
// deltaPtr += srcPitch; // deltaPtr += srcPitch;
} // endof: for (; height; height--) } // 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 *dstPtr, u32 dstPitch, int width, int height)
{ {
u8 *dP; u8 *dP;
@ -506,12 +506,12 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
deltaPtr += srcPitch; deltaPtr += srcPitch;
} }
} else } else
#endif #endif
{ {
inc_bP = 1; inc_bP = 1;
u32 Nextline = srcPitch >> 1; u32 Nextline = srcPitch >> 1;
for (; height; height--) { for (; height; height--) {
bP = (u16 *) srcPtr; bP = (u16 *) srcPtr;
xP = (u16 *) deltaPtr; xP = (u16 *) deltaPtr;
@ -521,23 +521,23 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u32 color1, color2, color3; u32 color1, color2, color3;
u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2; u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
u32 product1a, product1b, product2a, product2b; u32 product1a, product1b, product2a, product2b;
colorB1 = *(bP - Nextline); colorB1 = *(bP - Nextline);
colorB2 = *(bP - Nextline + 1); colorB2 = *(bP - Nextline + 1);
color4 = *(bP - 1); color4 = *(bP - 1);
color5 = *(bP); color5 = *(bP);
color6 = *(bP + 1); color6 = *(bP + 1);
colorS2 = *(bP + 2); colorS2 = *(bP + 2);
color1 = *(bP + Nextline - 1); color1 = *(bP + Nextline - 1);
color2 = *(bP + Nextline); color2 = *(bP + Nextline);
color3 = *(bP + Nextline + 1); color3 = *(bP + Nextline + 1);
colorS1 = *(bP + Nextline + 2); colorS1 = *(bP + Nextline + 2);
colorA1 = *(bP + Nextline + Nextline); colorA1 = *(bP + Nextline + Nextline);
colorA2 = *(bP + Nextline + Nextline + 1); colorA2 = *(bP + Nextline + Nextline + 1);
// -------------------------------------- // --------------------------------------
if (color2 == color6 && color5 != color3) { if (color2 == color6 && color5 != color3) {
product1b = product2a = color2; product1b = product2a = color2;
@ -548,7 +548,7 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} else { } else {
product1a = INTERPOLATE (color5, color6); product1a = INTERPOLATE (color5, color6);
} }
if ((color6 == colorS2) || (color2 == colorA1)) { if ((color6 == colorS2) || (color2 == colorA1)) {
product2b = INTERPOLATE (color2, color3); product2b = INTERPOLATE (color2, color3);
product2b = INTERPOLATE (color2, product2b); product2b = INTERPOLATE (color2, product2b);
@ -558,7 +558,7 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} }
} else if (color5 == color3 && color2 != color6) { } else if (color5 == color3 && color2 != color6) {
product2b = product1a = color5; product2b = product1a = color5;
if ((colorB1 == color5) || (color3 == colorS1)) { if ((colorB1 == color5) || (color3 == colorS1)) {
product1b = INTERPOLATE (color5, color6); product1b = INTERPOLATE (color5, color6);
product1b = INTERPOLATE (color5, product1b); product1b = INTERPOLATE (color5, product1b);
@ -566,7 +566,7 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} else { } else {
product1b = INTERPOLATE (color5, color6); product1b = INTERPOLATE (color5, color6);
} }
if ((color3 == colorA2) || (color4 == color5)) { if ((color3 == colorA2) || (color4 == color5)) {
product2a = INTERPOLATE (color5, color2); product2a = INTERPOLATE (color5, color2);
product2a = INTERPOLATE (color5, product2a); product2a = INTERPOLATE (color5, product2a);
@ -574,15 +574,15 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} else { } else {
product2a = INTERPOLATE (color2, color3); product2a = INTERPOLATE (color2, color3);
} }
} else if (color5 == color3 && color2 == color6) { } else if (color5 == color3 && color2 == color6) {
register int r = 0; register int r = 0;
r += GetResult (color6, color5, color1, colorA1); r += GetResult (color6, color5, color1, colorA1);
r += GetResult (color6, color5, color4, colorB1); r += GetResult (color6, color5, color4, colorB1);
r += GetResult (color6, color5, colorA2, colorS1); r += GetResult (color6, color5, colorA2, colorS1);
r += GetResult (color6, color5, colorB2, colorS2); r += GetResult (color6, color5, colorB2, colorS2);
if (r > 0) { if (r > 0) {
product1b = product2a = color2; product1b = product2a = color2;
product1a = product2b = INTERPOLATE (color5, color6); product1a = product2b = INTERPOLATE (color5, color6);
@ -599,13 +599,13 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
Q_INTERPOLATE (color3, color3, color3, product2b); Q_INTERPOLATE (color3, color3, color3, product2b);
product1a = product1a =
Q_INTERPOLATE (color5, color5, color5, product1a); Q_INTERPOLATE (color5, color5, color5, product1a);
product2a = product1b = INTERPOLATE (color5, color3); product2a = product1b = INTERPOLATE (color5, color3);
product2a = product2a =
Q_INTERPOLATE (color2, color2, color2, product2a); Q_INTERPOLATE (color2, color2, color2, product2a);
product1b = product1b =
Q_INTERPOLATE (color6, color6, color6, product1b); Q_INTERPOLATE (color6, color6, color6, product1b);
// product1a = color5; // product1a = color5;
// product1b = color6; // product1b = color6;
// product2a = color2; // product2a = color2;
@ -618,16 +618,16 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
product1a = product1a | (product1b << 16); product1a = product1a | (product1b << 16);
product2a = product2a | (product2b << 16); product2a = product2a | (product2b << 16);
#endif #endif
*((u32 *) dP) = product1a; *((u32 *) dP) = product1a;
*((u32 *) (dP + dstPitch)) = product2a; *((u32 *) (dP + dstPitch)) = product2a;
*xP = color5; *xP = color5;
bP += inc_bP; bP += inc_bP;
xP += inc_bP; xP += inc_bP;
dP += sizeof (u32); dP += sizeof (u32);
} // end of for ( finish= width etc..) } // end of for ( finish= width etc..)
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
deltaPtr += srcPitch; 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) u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
u32 *dP; u32 *dP;
@ -644,9 +644,9 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u32 inc_bP; u32 inc_bP;
inc_bP = 1; inc_bP = 1;
u32 Nextline = srcPitch >> 2; u32 Nextline = srcPitch >> 2;
for (; height; height--) { for (; height; height--) {
bP = (u32 *) srcPtr; bP = (u32 *) srcPtr;
xP = (u32 *) deltaPtr; xP = (u32 *) deltaPtr;
@ -656,23 +656,23 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u32 color1, color2, color3; u32 color1, color2, color3;
u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2; u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
u32 product1a, product1b, product2a, product2b; u32 product1a, product1b, product2a, product2b;
colorB1 = *(bP - Nextline); colorB1 = *(bP - Nextline);
colorB2 = *(bP - Nextline + 1); colorB2 = *(bP - Nextline + 1);
color4 = *(bP - 1); color4 = *(bP - 1);
color5 = *(bP); color5 = *(bP);
color6 = *(bP + 1); color6 = *(bP + 1);
colorS2 = *(bP + 2); colorS2 = *(bP + 2);
color1 = *(bP + Nextline - 1); color1 = *(bP + Nextline - 1);
color2 = *(bP + Nextline); color2 = *(bP + Nextline);
color3 = *(bP + Nextline + 1); color3 = *(bP + Nextline + 1);
colorS1 = *(bP + Nextline + 2); colorS1 = *(bP + Nextline + 2);
colorA1 = *(bP + Nextline + Nextline); colorA1 = *(bP + Nextline + Nextline);
colorA2 = *(bP + Nextline + Nextline + 1); colorA2 = *(bP + Nextline + Nextline + 1);
// -------------------------------------- // --------------------------------------
if (color2 == color6 && color5 != color3) { if (color2 == color6 && color5 != color3) {
product1b = product2a = color2; product1b = product2a = color2;
@ -683,7 +683,7 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} else { } else {
product1a = INTERPOLATE (color5, color6); product1a = INTERPOLATE (color5, color6);
} }
if ((color6 == colorS2) || (color2 == colorA1)) { if ((color6 == colorS2) || (color2 == colorA1)) {
product2b = INTERPOLATE (color2, color3); product2b = INTERPOLATE (color2, color3);
product2b = INTERPOLATE (color2, product2b); product2b = INTERPOLATE (color2, product2b);
@ -693,7 +693,7 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} }
} else if (color5 == color3 && color2 != color6) { } else if (color5 == color3 && color2 != color6) {
product2b = product1a = color5; product2b = product1a = color5;
if ((colorB1 == color5) || (color3 == colorS1)) { if ((colorB1 == color5) || (color3 == colorS1)) {
product1b = INTERPOLATE (color5, color6); product1b = INTERPOLATE (color5, color6);
product1b = INTERPOLATE (color5, product1b); product1b = INTERPOLATE (color5, product1b);
@ -701,7 +701,7 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} else { } else {
product1b = INTERPOLATE (color5, color6); product1b = INTERPOLATE (color5, color6);
} }
if ((color3 == colorA2) || (color4 == color5)) { if ((color3 == colorA2) || (color4 == color5)) {
product2a = INTERPOLATE (color5, color2); product2a = INTERPOLATE (color5, color2);
product2a = INTERPOLATE (color5, product2a); product2a = INTERPOLATE (color5, product2a);
@ -709,15 +709,15 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} else { } else {
product2a = INTERPOLATE (color2, color3); product2a = INTERPOLATE (color2, color3);
} }
} else if (color5 == color3 && color2 == color6) { } else if (color5 == color3 && color2 == color6) {
register int r = 0; register int r = 0;
r += GetResult (color6, color5, color1, colorA1); r += GetResult (color6, color5, color1, colorA1);
r += GetResult (color6, color5, color4, colorB1); r += GetResult (color6, color5, color4, colorB1);
r += GetResult (color6, color5, colorA2, colorS1); r += GetResult (color6, color5, colorA2, colorS1);
r += GetResult (color6, color5, colorB2, colorS2); r += GetResult (color6, color5, colorB2, colorS2);
if (r > 0) { if (r > 0) {
product1b = product2a = color2; product1b = product2a = color2;
product1a = product2b = INTERPOLATE (color5, color6); product1a = product2b = INTERPOLATE (color5, color6);
@ -734,13 +734,13 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
Q_INTERPOLATE (color3, color3, color3, product2b); Q_INTERPOLATE (color3, color3, color3, product2b);
product1a = product1a =
Q_INTERPOLATE (color5, color5, color5, product1a); Q_INTERPOLATE (color5, color5, color5, product1a);
product2a = product1b = INTERPOLATE (color5, color3); product2a = product1b = INTERPOLATE (color5, color3);
product2a = product2a =
Q_INTERPOLATE (color2, color2, color2, product2a); Q_INTERPOLATE (color2, color2, color2, product2a);
product1b = product1b =
Q_INTERPOLATE (color6, color6, color6, product1b); Q_INTERPOLATE (color6, color6, color6, product1b);
// product1a = color5; // product1a = color5;
// product1b = color6; // product1b = color6;
// product2a = color2; // product2a = color2;
@ -751,12 +751,12 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
*(dP + (dstPitch >> 2)) = product2a; *(dP + (dstPitch >> 2)) = product2a;
*(dP + (dstPitch >> 2) +1) = product2b; *(dP + (dstPitch >> 2) +1) = product2b;
*xP = color5; *xP = color5;
bP += inc_bP; bP += inc_bP;
xP += inc_bP; xP += inc_bP;
dP += 2; dP += 2;
} // end of for ( finish= width etc..) } // end of for ( finish= width etc..)
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
deltaPtr += srcPitch; deltaPtr += srcPitch;
@ -769,7 +769,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *dP; u8 *dP;
u16 *bP; u16 *bP;
u32 inc_bP; u32 inc_bP;
#ifdef MMX #ifdef MMX
if (cpu_mmx) { if (cpu_mmx) {
for (; height; height -= 1) { for (; height; height -= 1) {
@ -782,23 +782,23 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
#endif #endif
{ {
inc_bP = 1; inc_bP = 1;
u32 Nextline = srcPitch >> 1; u32 Nextline = srcPitch >> 1;
for (; height; height--) { for (; height; height--) {
bP = (u16 *) srcPtr; bP = (u16 *) srcPtr;
dP = dstPtr; dP = dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) { for (u32 finish = width; finish; finish -= inc_bP) {
register u32 colorA, colorB; register u32 colorA, colorB;
u32 colorC, colorD, u32 colorC, colorD,
colorE, colorF, colorG, colorH, colorE, colorF, colorG, colorH,
colorI, colorJ, colorK, colorL, colorI, colorJ, colorK, colorL,
colorM, colorN, colorO, colorP; colorM, colorN, colorO, colorP;
u32 product, product1, product2; u32 product, product1, product2;
//--------------------------------------- //---------------------------------------
// Map of the pixels: I|E F|J // Map of the pixels: I|E F|J
// G|A B|K // G|A B|K
@ -808,22 +808,22 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
colorE = *(bP - Nextline); colorE = *(bP - Nextline);
colorF = *(bP - Nextline + 1); colorF = *(bP - Nextline + 1);
colorJ = *(bP - Nextline + 2); colorJ = *(bP - Nextline + 2);
colorG = *(bP - 1); colorG = *(bP - 1);
colorA = *(bP); colorA = *(bP);
colorB = *(bP + 1); colorB = *(bP + 1);
colorK = *(bP + 2); colorK = *(bP + 2);
colorH = *(bP + Nextline - 1); colorH = *(bP + Nextline - 1);
colorC = *(bP + Nextline); colorC = *(bP + Nextline);
colorD = *(bP + Nextline + 1); colorD = *(bP + Nextline + 1);
colorL = *(bP + Nextline + 2); colorL = *(bP + Nextline + 2);
colorM = *(bP + Nextline + Nextline - 1); colorM = *(bP + Nextline + Nextline - 1);
colorN = *(bP + Nextline + Nextline); colorN = *(bP + Nextline + Nextline);
colorO = *(bP + Nextline + Nextline + 1); colorO = *(bP + Nextline + Nextline + 1);
colorP = *(bP + Nextline + Nextline + 2); colorP = *(bP + Nextline + Nextline + 2);
if ((colorA == colorD) && (colorB != colorC)) { if ((colorA == colorD) && (colorB != colorC)) {
if (((colorA == colorE) && (colorB == colorL)) || if (((colorA == colorE) && (colorB == colorL)) ||
((colorA == colorC) && (colorA == colorF) ((colorA == colorC) && (colorA == colorF)
@ -832,7 +832,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} else { } else {
product = INTERPOLATE (colorA, colorB); product = INTERPOLATE (colorA, colorB);
} }
if (((colorA == colorG) && (colorC == colorO)) || if (((colorA == colorG) && (colorC == colorO)) ||
((colorA == colorB) && (colorA == colorH) ((colorA == colorB) && (colorA == colorH)
&& (colorG != colorC) && (colorC == colorM))) { && (colorG != colorC) && (colorC == colorM))) {
@ -849,7 +849,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} else { } else {
product = INTERPOLATE (colorA, colorB); product = INTERPOLATE (colorA, colorB);
} }
if (((colorC == colorH) && (colorA == colorF)) || if (((colorC == colorH) && (colorA == colorF)) ||
((colorC == colorG) && (colorC == colorD) ((colorC == colorG) && (colorC == colorD)
&& (colorA != colorH) && (colorA == colorI))) { && (colorA != colorH) && (colorA == colorI))) {
@ -865,10 +865,10 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
product2 = colorA; product2 = colorA;
} else { } else {
register int r = 0; register int r = 0;
product1 = INTERPOLATE (colorA, colorC); product1 = INTERPOLATE (colorA, colorC);
product = INTERPOLATE (colorA, colorB); product = INTERPOLATE (colorA, colorB);
r += r +=
GetResult1 (colorA, colorB, colorG, colorE, GetResult1 (colorA, colorB, colorG, colorE,
colorI); colorI);
@ -881,7 +881,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
r += r +=
GetResult1 (colorA, colorB, colorL, colorO, GetResult1 (colorA, colorB, colorL, colorO,
colorP); colorP);
if (r > 0) if (r > 0)
product2 = colorA; product2 = colorA;
else if (r < 0) else if (r < 0)
@ -894,7 +894,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} }
} else { } else {
product2 = Q_INTERPOLATE (colorA, colorB, colorC, colorD); product2 = Q_INTERPOLATE (colorA, colorB, colorC, colorD);
if ((colorA == colorC) && (colorA == colorF) if ((colorA == colorC) && (colorA == colorF)
&& (colorB != colorE) && (colorB == colorJ)) { && (colorB != colorE) && (colorB == colorJ)) {
product = colorA; product = colorA;
@ -904,7 +904,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} else { } else {
product = INTERPOLATE (colorA, colorB); product = INTERPOLATE (colorA, colorB);
} }
if ((colorA == colorB) && (colorA == colorH) if ((colorA == colorB) && (colorA == colorH)
&& (colorG != colorC) && (colorC == colorM)) { && (colorG != colorC) && (colorC == colorM)) {
product1 = colorA; product1 = colorA;
@ -915,7 +915,7 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
product1 = INTERPOLATE (colorA, colorC); product1 = INTERPOLATE (colorA, colorC);
} }
} }
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
product = (colorA << 16) | product ; product = (colorA << 16) | product ;
product1 = (product1 << 16) | product2 ; product1 = (product1 << 16) | product2 ;
@ -925,11 +925,11 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
#endif #endif
*((s32 *) dP) = product; *((s32 *) dP) = product;
*((u32 *) (dP + dstPitch)) = product1; *((u32 *) (dP + dstPitch)) = product1;
bP += inc_bP; bP += inc_bP;
dP += sizeof (u32); dP += sizeof (u32);
} // end of for ( finish= width etc..) } // end of for ( finish= width etc..)
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
deltaPtr += srcPitch; deltaPtr += srcPitch;
@ -943,22 +943,22 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u32 *dP; u32 *dP;
u32 *bP; u32 *bP;
u32 inc_bP = 1; u32 inc_bP = 1;
u32 Nextline = srcPitch >> 2; u32 Nextline = srcPitch >> 2;
for (; height; height--) { for (; height; height--) {
bP = (u32 *) srcPtr; bP = (u32 *) srcPtr;
dP = (u32 *) dstPtr; dP = (u32 *) dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) { for (u32 finish = width; finish; finish -= inc_bP) {
register u32 colorA, colorB; register u32 colorA, colorB;
u32 colorC, colorD, u32 colorC, colorD,
colorE, colorF, colorG, colorH, colorE, colorF, colorG, colorH,
colorI, colorJ, colorK, colorL, colorI, colorJ, colorK, colorL,
colorM, colorN, colorO, colorP; colorM, colorN, colorO, colorP;
u32 product, product1, product2; u32 product, product1, product2;
//--------------------------------------- //---------------------------------------
// Map of the pixels: I|E F|J // Map of the pixels: I|E F|J
// G|A B|K // G|A B|K
@ -968,22 +968,22 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
colorE = *(bP - Nextline); colorE = *(bP - Nextline);
colorF = *(bP - Nextline + 1); colorF = *(bP - Nextline + 1);
colorJ = *(bP - Nextline + 2); colorJ = *(bP - Nextline + 2);
colorG = *(bP - 1); colorG = *(bP - 1);
colorA = *(bP); colorA = *(bP);
colorB = *(bP + 1); colorB = *(bP + 1);
colorK = *(bP + 2); colorK = *(bP + 2);
colorH = *(bP + Nextline - 1); colorH = *(bP + Nextline - 1);
colorC = *(bP + Nextline); colorC = *(bP + Nextline);
colorD = *(bP + Nextline + 1); colorD = *(bP + Nextline + 1);
colorL = *(bP + Nextline + 2); colorL = *(bP + Nextline + 2);
colorM = *(bP + Nextline + Nextline - 1); colorM = *(bP + Nextline + Nextline - 1);
colorN = *(bP + Nextline + Nextline); colorN = *(bP + Nextline + Nextline);
colorO = *(bP + Nextline + Nextline + 1); colorO = *(bP + Nextline + Nextline + 1);
colorP = *(bP + Nextline + Nextline + 2); colorP = *(bP + Nextline + Nextline + 2);
if ((colorA == colorD) && (colorB != colorC)) { if ((colorA == colorD) && (colorB != colorC)) {
if (((colorA == colorE) && (colorB == colorL)) || if (((colorA == colorE) && (colorB == colorL)) ||
((colorA == colorC) && (colorA == colorF) ((colorA == colorC) && (colorA == colorF)
@ -992,7 +992,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
} else { } else {
product = INTERPOLATE (colorA, colorB); product = INTERPOLATE (colorA, colorB);
} }
if (((colorA == colorG) && (colorC == colorO)) || if (((colorA == colorG) && (colorC == colorO)) ||
((colorA == colorB) && (colorA == colorH) ((colorA == colorB) && (colorA == colorH)
&& (colorG != colorC) && (colorC == colorM))) { && (colorG != colorC) && (colorC == colorM))) {
@ -1009,7 +1009,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
} else { } else {
product = INTERPOLATE (colorA, colorB); product = INTERPOLATE (colorA, colorB);
} }
if (((colorC == colorH) && (colorA == colorF)) || if (((colorC == colorH) && (colorA == colorF)) ||
((colorC == colorG) && (colorC == colorD) ((colorC == colorG) && (colorC == colorD)
&& (colorA != colorH) && (colorA == colorI))) { && (colorA != colorH) && (colorA == colorI))) {
@ -1025,10 +1025,10 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
product2 = colorA; product2 = colorA;
} else { } else {
register int r = 0; register int r = 0;
product1 = INTERPOLATE (colorA, colorC); product1 = INTERPOLATE (colorA, colorC);
product = INTERPOLATE (colorA, colorB); product = INTERPOLATE (colorA, colorB);
r += r +=
GetResult1 (colorA, colorB, colorG, colorE, GetResult1 (colorA, colorB, colorG, colorE,
colorI); colorI);
@ -1041,7 +1041,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
r += r +=
GetResult1 (colorA, colorB, colorL, colorO, GetResult1 (colorA, colorB, colorL, colorO,
colorP); colorP);
if (r > 0) if (r > 0)
product2 = colorA; product2 = colorA;
else if (r < 0) else if (r < 0)
@ -1054,7 +1054,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
} }
} else { } else {
product2 = Q_INTERPOLATE (colorA, colorB, colorC, colorD); product2 = Q_INTERPOLATE (colorA, colorB, colorC, colorD);
if ((colorA == colorC) && (colorA == colorF) if ((colorA == colorC) && (colorA == colorF)
&& (colorB != colorE) && (colorB == colorJ)) { && (colorB != colorE) && (colorB == colorJ)) {
product = colorA; product = colorA;
@ -1064,7 +1064,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
} else { } else {
product = INTERPOLATE (colorA, colorB); product = INTERPOLATE (colorA, colorB);
} }
if ((colorA == colorB) && (colorA == colorH) if ((colorA == colorB) && (colorA == colorH)
&& (colorG != colorC) && (colorC == colorM)) { && (colorG != colorC) && (colorC == colorM)) {
product1 = colorA; product1 = colorA;
@ -1079,11 +1079,11 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
*(dP + 1) = product; *(dP + 1) = product;
*(dP + (dstPitch >> 2)) = product1; *(dP + (dstPitch >> 2)) = product1;
*(dP + (dstPitch >> 2) + 1) = product2; *(dP + (dstPitch >> 2) + 1) = product2;
bP += inc_bP; bP += inc_bP;
dP += 2; dP += 2;
} // end of for ( finish= width etc..) } // end of for ( finish= width etc..)
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
// deltaPtr += srcPitch; // deltaPtr += srcPitch;
@ -1094,18 +1094,18 @@ static u32 Bilinear (u32 A, u32 B, u32 x)
{ {
unsigned long areaA, areaB; unsigned long areaA, areaB;
unsigned long result; unsigned long result;
if (A == B) if (A == B)
return A; return A;
areaB = (x >> 11) & 0x1f; // reduce 16 bit fraction to 5 bits areaB = (x >> 11) & 0x1f; // reduce 16 bit fraction to 5 bits
areaA = 0x20 - areaB; areaA = 0x20 - areaB;
A = (A & redblueMask) | ((A & greenMask) << 16); A = (A & redblueMask) | ((A & greenMask) << 16);
B = (B & redblueMask) | ((B & greenMask) << 16); B = (B & redblueMask) | ((B & greenMask) << 16);
result = ((areaA * A) + (areaB * B)) >> 5; result = ((areaA * A) + (areaB * B)) >> 5;
return (result & redblueMask) | ((result >> 16) & greenMask); 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 areaA, areaB, areaC, areaD;
unsigned long result, xy; unsigned long result, xy;
x = (x >> 11) & 0x1f; x = (x >> 11) & 0x1f;
y = (y >> 11) & 0x1f; y = (y >> 11) & 0x1f;
xy = (x * y) >> 5; xy = (x * y) >> 5;
A = (A & redblueMask) | ((A & greenMask) << 16); A = (A & redblueMask) | ((A & greenMask) << 16);
B = (B & redblueMask) | ((B & greenMask) << 16); B = (B & redblueMask) | ((B & greenMask) << 16);
C = (C & redblueMask) | ((C & greenMask) << 16); C = (C & redblueMask) | ((C & greenMask) << 16);
D = (D & redblueMask) | ((D & greenMask) << 16); D = (D & redblueMask) | ((D & greenMask) << 16);
areaA = 0x20 + xy - x - y; areaA = 0x20 + xy - x - y;
areaB = x - xy; areaB = x - xy;
areaC = y - xy; areaC = y - xy;
areaD = xy; areaD = xy;
result = ((areaA * A) + (areaB * B) + (areaC * C) + (areaD * D)) >> 5; result = ((areaA * A) + (areaB * B) + (areaC * C) + (areaD * D)) >> 5;
return (result & redblueMask) | ((result >> 16) & greenMask); return (result & redblueMask) | ((result >> 16) & greenMask);
} }
void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, 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) u32 dstWidth, u32 dstHeight, int width, int height)
{ {
u8 *dP; u8 *dP;
@ -1147,31 +1147,31 @@ void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u32 dh; u32 dh;
u32 hfinish; u32 hfinish;
u32 wfinish; u32 wfinish;
u32 Nextline = srcPitch >> 1; u32 Nextline = srcPitch >> 1;
wfinish = (width - 1) << 16; // convert to fixed point wfinish = (width - 1) << 16; // convert to fixed point
dw = wfinish / (dstWidth - 1); dw = wfinish / (dstWidth - 1);
hfinish = (height - 1) << 16; // convert to fixed point hfinish = (height - 1) << 16; // convert to fixed point
dh = hfinish / (dstHeight - 1); dh = hfinish / (dstHeight - 1);
for (h = 0; h < hfinish; h += dh) { for (h = 0; h < hfinish; h += dh) {
u32 y1, y2; u32 y1, y2;
y1 = h & 0xffff; // fraction part of fixed point y1 = h & 0xffff; // fraction part of fixed point
bP = (u16 *) (srcPtr + ((h >> 16) * srcPitch)); bP = (u16 *) (srcPtr + ((h >> 16) * srcPitch));
dP = dstPtr; dP = dstPtr;
y2 = 0x10000 - y1; y2 = 0x10000 - y1;
w = 0; w = 0;
for (; w < wfinish;) { for (; w < wfinish;) {
u32 A, B, C, D; u32 A, B, C, D;
u32 E, F, G, H; u32 E, F, G, H;
u32 I, J, K, L; u32 I, J, K, L;
u32 x1, x2, a1, f1, f2; u32 x1, x2, a1, f1, f2;
u32 position, product1; u32 position, product1;
position = w >> 16; position = w >> 16;
A = bP[position]; // current pixel A = bP[position]; // current pixel
B = bP[position + 1]; // next 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]; J = bP[position + Nextline + 2];
K = bP[position + Nextline + Nextline]; K = bP[position + Nextline + Nextline];
L = bP[position + Nextline + Nextline + 1]; L = bP[position + Nextline + Nextline + 1];
x1 = w & 0xffff; // fraction part of fixed point x1 = w & 0xffff; // fraction part of fixed point
x2 = 0x10000 - x1; x2 = 0x10000 - x1;
/*0*/ /*0*/
if (A == B && C == D && A == C) if (A == B && C == D && A == C)
product1 = A; product1 = A;
else /*1*/ if (A == D && B != C) { else /*1*/ if (A == D && B != C) {
@ -1226,7 +1226,7 @@ void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
} }
} }
else else
/*2*/ /*2*/
if (B == C && A != D) if (B == C && A != D)
{ {
f1 = (x1 >> 1) + (0x10000 >> 2); 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); product1 = Bilinear4 (A, B, C, D, x1, y1);
} }
//end First Pixel //end First Pixel
*(u32 *) dP = product1; *(u32 *) dP = product1;
dP += 2; dP += 2;

View File

@ -102,7 +102,7 @@ _2xSaISuper2xSaILine:
mov ebx, [ebp+srcPitch] ;ebx contains the source pitch mov ebx, [ebp+srcPitch] ;ebx contains the source pitch
mov ecx, [ebp+width] ;ecx contains the number of pixels to process mov ecx, [ebp+width] ;ecx contains the number of pixels to process
; eax now points to colorB1 ; 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 ; Main Loop
.Loop: push ecx .Loop: push ecx
@ -153,7 +153,7 @@ _2xSaISuper2xSaILine:
packsswb mm7, mm7 packsswb mm7, mm7
movd ecx, mm7 movd ecx, mm7
test ecx, ecx test ecx, ecx
jz near .SKIP_PROCESS ;no, so we can skip jz near .SKIP_PROCESS ;no, so we can skip
;End Delta ;End Delta
@ -432,7 +432,7 @@ _2xSaISuper2xSaILine:
pcmpgtw mm0, mm1 pcmpgtw mm0, mm1
por mm7, [Mask35] por mm7, [Mask35]
por mm0, [Mask26] por mm0, [Mask26]
movq [Mask35], mm7 movq [Mask35], mm7
movq [Mask26], mm0 movq [Mask26], mm0
@ -440,7 +440,7 @@ _2xSaISuper2xSaILine:
;Start the ASSEMBLY !!! eh... compose all the results together to form the final image... ;Start the ASSEMBLY !!! eh... compose all the results together to form the final image...
movq mm0, [eax+ebx+color5] movq mm0, [eax+ebx+color5]
movq mm1, [eax+ebx+ebx+color2] movq mm1, [eax+ebx+ebx+color2]
movq mm2, mm0 movq mm2, mm0
@ -516,7 +516,7 @@ _2xSaISuper2xSaILine:
pand mm6, mm2 pand mm6, mm2
por mm7, mm6 por mm7, mm6
movq mm6, mm7 movq mm6, mm7
pcmpeqw mm6, mm5 pcmpeqw mm6, mm5
pand mm7, mm0 pand mm7, mm0
@ -527,8 +527,8 @@ _2xSaISuper2xSaILine:
movq [final1a], mm7 ;finished 1a movq [final1a], mm7 ;finished 1a
;-------------------------------- ;--------------------------------
movq mm7, [Mask35] movq mm7, [Mask35]
push eax push eax
@ -568,7 +568,7 @@ _2xSaISuper2xSaILine:
pand mm6, mm2 pand mm6, mm2
por mm7, mm6 por mm7, mm6
movq mm6, mm7 movq mm6, mm7
pcmpeqw mm6, mm5 pcmpeqw mm6, mm5
pand mm7, mm0 pand mm7, mm0
@ -580,7 +580,7 @@ _2xSaISuper2xSaILine:
;-------------------------------------------- ;--------------------------------------------
%ifdef dfhsdfhsdahdsfhdsfh %ifdef dfhsdfhsdahdsfhdsfh
if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0) if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0)
@ -647,7 +647,7 @@ _2xSaISuper2xSaILine:
movq mm4, [Mask35] movq mm4, [Mask35]
movq mm3, [Mask26] movq mm3, [Mask26]
movq mm6, mm4 movq mm6, mm4
pand mm6, mm7 pand mm6, mm7
pxor mm4, mm6 pxor mm4, mm6
@ -679,7 +679,7 @@ _2xSaISuper2xSaILine:
movq [final2b], mm0 movq [final2b], mm0
;----------------------------------- ;-----------------------------------
pxor mm7, mm7 pxor mm7, mm7
movq mm0, [eax+colorB0] movq mm0, [eax+colorB0]
@ -721,7 +721,7 @@ _2xSaISuper2xSaILine:
movq mm4, [Mask35] movq mm4, [Mask35]
movq mm3, [Mask26] movq mm3, [Mask26]
movq mm6, mm4 movq mm6, mm4
pand mm6, mm7 pand mm6, mm7
pxor mm4, mm6 pxor mm4, mm6
@ -751,7 +751,7 @@ _2xSaISuper2xSaILine:
por mm0, mm3 por mm0, mm3
por mm0, mm2 por mm0, mm2
movq [final1b], mm0 movq [final1b], mm0
;--------- ;---------
movq mm0, [final1a] movq mm0, [final1a]
@ -2052,7 +2052,7 @@ Bits565:
mov [eax+4], edx mov [eax+4], edx
mov eax, 0 mov eax, 0
jmp end3 jmp end3
end3: end3:
pop edx pop edx
mov esp, ebp mov esp, ebp
pop ebp pop ebp

View File

@ -120,7 +120,7 @@ void cheatSearchCleanup(CheatSearchData *cs)
void cheatSearchStart(const CheatSearchData *cs) void cheatSearchStart(const CheatSearchData *cs)
{ {
int count = cs->count; int count = cs->count;
for(int i = 0; i < count; i++) { for(int i = 0; i < count; i++) {
CheatSearchBlock *block = &cs->blocks[i]; CheatSearchBlock *block = &cs->blocks[i];
@ -163,7 +163,7 @@ u32 cheatSearchRead(u8 *data, int off, int size)
return res; return res;
} }
void cheatSearch(const CheatSearchData *cs, int compare, int size, void cheatSearch(const CheatSearchData *cs, int compare, int size,
bool isSigned) bool isSigned)
{ {
if(compare < 0 || compare > SEARCH_GE) if(compare < 0 || compare > SEARCH_GE)
@ -183,7 +183,7 @@ void cheatSearch(const CheatSearchData *cs, int compare, int size,
u8 *bits = block->bits; u8 *bits = block->bits;
u8 *data = block->data; u8 *data = block->data;
u8 *saved = block->saved; u8 *saved = block->saved;
for(int j = 0; j < size2; j += inc) { for(int j = 0; j < size2; j += inc) {
if(IS_BIT_SET(bits, j)) { if(IS_BIT_SET(bits, j)) {
s32 a = cheatSearchSignedRead(data, j, size); s32 a = cheatSearchSignedRead(data, j, size);
@ -210,7 +210,7 @@ void cheatSearch(const CheatSearchData *cs, int compare, int size,
u8 *bits = block->bits; u8 *bits = block->bits;
u8 *data = block->data; u8 *data = block->data;
u8 *saved = block->saved; u8 *saved = block->saved;
for(int j = 0; j < size2; j += inc) { for(int j = 0; j < size2; j += inc) {
if(IS_BIT_SET(bits, j)) { if(IS_BIT_SET(bits, j)) {
u32 a = cheatSearchRead(data, j, size); 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) bool isSigned, u32 value)
{ {
if(compare < 0 || compare > SEARCH_GE) if(compare < 0 || compare > SEARCH_GE)
@ -250,7 +250,7 @@ void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
int size2 = block->size; int size2 = block->size;
u8 *bits = block->bits; u8 *bits = block->bits;
u8 *data = block->data; u8 *data = block->data;
for(int j = 0; j < size2; j += inc) { for(int j = 0; j < size2; j += inc) {
if(IS_BIT_SET(bits, j)) { if(IS_BIT_SET(bits, j)) {
s32 a = cheatSearchSignedRead(data, j, size); s32 a = cheatSearchSignedRead(data, j, size);
@ -276,7 +276,7 @@ void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
int size2 = block->size; int size2 = block->size;
u8 *bits = block->bits; u8 *bits = block->bits;
u8 *data = block->data; u8 *data = block->data;
for(int j = 0; j < size2; j += inc) { for(int j = 0; j < size2; j += inc) {
if(IS_BIT_SET(bits, j)) { if(IS_BIT_SET(bits, j)) {
u32 a = cheatSearchRead(data, j, size); 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 res = 0;
int inc = 1; int inc = 1;
@ -307,7 +307,7 @@ int cheatSearchGetCount(const CheatSearchData *cs, int size)
for(int i = 0; i < cs->count; i++) { for(int i = 0; i < cs->count; i++) {
CheatSearchBlock *block = &cs->blocks[i]; CheatSearchBlock *block = &cs->blocks[i];
int size2 = block->size; int size2 = block->size;
u8 *bits = block->bits; u8 *bits = block->bits;
for(int j = 0; j < size2; j += inc) { for(int j = 0; j < size2; j += inc) {

View File

@ -62,9 +62,9 @@ enum {
extern CheatSearchData cheatSearchData; extern CheatSearchData cheatSearchData;
extern void cheatSearchCleanup(CheatSearchData *cs); extern void cheatSearchCleanup(CheatSearchData *cs);
extern void cheatSearchStart(const 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); 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); bool isSigned, u32 value);
extern int cheatSearchGetCount(const CheatSearchData *cs, int size); extern int cheatSearchGetCount(const CheatSearchData *cs, int size);
extern void cheatSearchUpdateValues(const CheatSearchData *cs); extern void cheatSearchUpdateValues(const CheatSearchData *cs);

View File

@ -66,7 +66,7 @@
* 4AAAAAAA YYYY - Slide code * 4AAAAAAA YYYY - Slide code
* XXXXCCCC IIII (C is count and I is address increment, X is value incr.) * 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) * 5AAAAAAA CCCC - Super code (Write bytes to address, 2*CCCC is count)
* BBBBBBBB BBBB * BBBBBBBB BBBB
* 6AAAAAAA YYYY - 16-bit and * 6AAAAAAA YYYY - 16-bit and
* 7AAAAAAA YYYY - if address contains 16-bit value enable next code * 7AAAAAAA YYYY - if address contains 16-bit value enable next code
* 8AAAAAAA YYYY - 16-bit constant write * 8AAAAAAA YYYY - 16-bit constant write
@ -115,7 +115,7 @@
#define CBA_ADD 32 #define CBA_ADD 32
#define CBA_OR 33 #define CBA_OR 33
#define CBA_LT 34 #define CBA_LT 34
#define CBA_GT 35 #define CBA_GT 35
#define CBA_SUPER 36 #define CBA_SUPER 36
#define GSA_8_BIT_POINTER 37 #define GSA_8_BIT_POINTER 37
#define GSA_16_BIT_POINTER 38 #define GSA_16_BIT_POINTER 38
@ -322,7 +322,7 @@ u8 v3_deadtable2[256] = {
WRITE16LE(((u16 *)&rom[(a) & 0x1ffffff]), v); WRITE16LE(((u16 *)&rom[(a) & 0x1ffffff]), v);
#define CHEAT_PATCH_ROM_32BIT(a,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) static bool isMultilineWithData(int i)
{ {
@ -613,7 +613,7 @@ int cheatsCheckKeys(u32 keys, u32 extended)
cheatsList[i].status |= 4; cheatsList[i].status |= 4;
else else
cheatsList[i].status &= ~4; cheatsList[i].status &= ~4;
if(cheatsList[i].status & 1) if(cheatsList[i].status & 1)
ticks += ((cheatsList[i].value & 0xFFFF) * 7); ticks += ((cheatsList[i].value & 0xFFFF) * 7);
break; break;
@ -752,12 +752,12 @@ int cheatsCheckKeys(u32 keys, u32 extended)
break; break;
case GSA_16_BIT_GS_WRITE: case GSA_16_BIT_GS_WRITE:
if(extended & 4) { if(extended & 4) {
CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value); CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value);
} }
break; break;
case GSA_32_BIT_GS_WRITE: case GSA_32_BIT_GS_WRITE:
if(extended & 4) { if(extended & 4) {
CPUWriteMemory(cheatsList[i].address, cheatsList[i].value); CPUWriteMemory(cheatsList[i].address, cheatsList[i].value);
} }
break; break;
case CBA_IF_KEYS_PRESSED: case CBA_IF_KEYS_PRESSED:
@ -884,12 +884,12 @@ int cheatsCheckKeys(u32 keys, u32 extended)
} }
break; break;
case CBA_ADD: case CBA_ADD:
if ((cheatsList[i].address & 1) == 0) { if ((cheatsList[i].address & 1) == 0) {
CPUWriteHalfWord(cheatsList[i].address, CPUWriteHalfWord(cheatsList[i].address,
CPUReadHalfWord(cheatsList[i].address) + CPUReadHalfWord(cheatsList[i].address) +
cheatsList[i].value); cheatsList[i].value);
} else { } else {
CPUWriteMemory(cheatsList[i].address & 0x0FFFFFFE, CPUWriteMemory(cheatsList[i].address & 0x0FFFFFFE,
CPUReadMemory(cheatsList[i].address & 0x0FFFFFFE) + CPUReadMemory(cheatsList[i].address & 0x0FFFFFFE) +
cheatsList[i].value); cheatsList[i].value);
} }
@ -1121,11 +1121,11 @@ int cheatsCheckKeys(u32 keys, u32 extended)
break; break;
case GSA_16_BIT_WRITE_IOREGS: case GSA_16_BIT_WRITE_IOREGS:
if ((cheatsList[i].address <= 0x3FF) && (cheatsList[i].address != 0x6) && 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; ioMem[cheatsList[i].address & 0x3FE]=cheatsList[i].value & 0xFFFF;
break; break;
case GSA_32_BIT_WRITE_IOREGS: 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)) if (((cheatsList[i].address & 0x3FC) != 0x6) && ((cheatsList[i].address & 0x3FC) != 0x130))
ioMem[cheatsList[i].address & 0x3FC]= (cheatsList[i].value & 0xFFFF); ioMem[cheatsList[i].address & 0x3FC]= (cheatsList[i].value & 0xFFFF);
@ -1400,7 +1400,7 @@ void cheatsDelete(int number, bool restore)
if(cheatsList[x].status & 1) { if(cheatsList[x].status & 1) {
cheatsList[x].status &= ~1; cheatsList[x].status &= ~1;
CHEAT_PATCH_ROM_16BIT(cheatsList[x].address, CHEAT_PATCH_ROM_16BIT(cheatsList[x].address,
cheatsList[x].oldValue); cheatsList[x].oldValue);
} }
break; break;
case GSA_16_BIT_ROM_PATCH2C: case GSA_16_BIT_ROM_PATCH2C:
@ -1476,7 +1476,7 @@ bool cheatsVerifyCheatCode(const char *code, const char *desc)
if(code[8] != ':') { if(code[8] != ':') {
systemMessage(MSG_INVALID_CHEAT_CODE, N_("Invalid cheat code '%s'"), code); systemMessage(MSG_INVALID_CHEAT_CODE, N_("Invalid cheat code '%s'"), code);
return false; return false;
} }
size_t i; size_t i;
@ -1496,10 +1496,10 @@ bool cheatsVerifyCheatCode(const char *code, const char *desc)
return false; return false;
} }
} }
u32 address = 0; u32 address = 0;
u32 value = 0; u32 value = 0;
char buffer[10]; char buffer[10];
strncpy(buffer, code, 8); strncpy(buffer, code, 8);
buffer[8] = 0; buffer[8] = 0;
@ -1525,8 +1525,8 @@ bool cheatsVerifyCheatCode(const char *code, const char *desc)
address); address);
return false; return false;
} }
strncpy(buffer, &code[9], 8); strncpy(buffer, &code[9], 8);
sscanf(buffer, "%x", &value); sscanf(buffer, "%x", &value);
int type = 0; int type = 0;
if(len == 13) if(len == 13)
@ -1575,7 +1575,7 @@ u32 seed_gen(u8 upper, u8 seed, u8 *deadtable1, u8 *deadtable2) {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
newseed = ((newseed << 8) | ((deadtable1[(i + upper) & 0xFF] + deadtable2[seed]) & 0xFF)); newseed = ((newseed << 8) | ((deadtable1[(i + upper) & 0xFF] + deadtable2[seed]) & 0xFF));
return newseed; return newseed;
} }
@ -1583,7 +1583,7 @@ void cheatsDecryptGSACode(u32& address, u32& value, bool v3)
{ {
u32 rollingseed = 0xC6EF3720; u32 rollingseed = 0xC6EF3720;
u32 *seeds = v3 ? seeds_v3 : seeds_v1; u32 *seeds = v3 ? seeds_v3 : seeds_v1;
int bitsleft = 32; int bitsleft = 32;
while (bitsleft > 0) { while (bitsleft > 0) {
value -= ((((address << 4) + seeds[2]) ^ (address + rollingseed)) ^ 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")); N_("Invalid GSA code. Format is XXXXXXXXYYYYYYYY"));
return; return;
} }
int i; int i;
for(i = 0; i < 16; i++) { for(i = 0; i < 16; i++) {
if(!CHEAT_IS_HEX(code[i])) { if(!CHEAT_IS_HEX(code[i])) {
@ -1613,7 +1613,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
return; return;
} }
} }
char buffer[10]; char buffer[10];
strncpy(buffer, code, 8); strncpy(buffer, code, 8);
buffer[8] = 0; 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."), systemMessage(MSG_GBA_CODE_WARNING, N_("Warning: cheats are for game %s. Current game is %s.\nCodes may not work correctly."),
buffer, buffer2); buffer, buffer2);
} }
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, v3 ? 257 : 256, cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, v3 ? 257 : 256,
UNKNOWN_CODE); UNKNOWN_CODE);
return; return;
} }
@ -1940,7 +1940,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
break; break;
} }
} else { } else {
int type = (address >> 28) & 15; int type = (address >> 28) & 15;
switch(type) { switch(type) {
case 0: case 0:
case 1: case 1:
@ -1972,7 +1972,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
break; break;
default: default:
// unsupported code // unsupported code
cheatsAdd(code, desc, address, address, value, 256, cheatsAdd(code, desc, address, address, value, 256,
UNKNOWN_CODE); UNKNOWN_CODE);
break; break;
} }
@ -1981,27 +1981,27 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
address <<= 1; address <<= 1;
type = (value >> 24) & 0xFF; type = (value >> 24) & 0xFF;
if(type == 0x00) { 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); GSA_16_BIT_ROM_PATCH);
break; break;
} }
// unsupported code // unsupported code
cheatsAdd(code, desc, address, address, value, 256, cheatsAdd(code, desc, address, address, value, 256,
UNKNOWN_CODE); UNKNOWN_CODE);
break; break;
case 8: case 8:
switch((address >> 20) & 15) { switch((address >> 20) & 15) {
case 1: case 1:
cheatsAdd(code, desc, address, address & 0x0F0FFFFF, value, 256, cheatsAdd(code, desc, address, address & 0x0F0FFFFF, value, 256,
GSA_8_BIT_GS_WRITE); GSA_8_BIT_GS_WRITE);
break; break;
case 2: case 2:
cheatsAdd(code, desc, address, address & 0x0F0FFFFF, value, 256, cheatsAdd(code, desc, address, address & 0x0F0FFFFF, value, 256,
GSA_16_BIT_GS_WRITE); GSA_16_BIT_GS_WRITE);
break; break;
case 4: case 4:
// This code is buggy : the value is always set to 0 ! // 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); GSA_32_BIT_GS_WRITE);
break; break;
case 15: case 15:
@ -2009,7 +2009,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
break; break;
default: default:
// unsupported code // unsupported code
cheatsAdd(code, desc, address, address, value, 256, cheatsAdd(code, desc, address, address, value, 256,
UNKNOWN_CODE); UNKNOWN_CODE);
break; break;
} }
@ -2018,52 +2018,52 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
if(address != 0xDEADFACE) { if(address != 0xDEADFACE) {
switch((value >> 20) & 0xF) { switch((value >> 20) & 0xF) {
case 0: case 0:
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256, cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
CBA_IF_TRUE); CBA_IF_TRUE);
break; break;
case 1: case 1:
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256, cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value & 0xFFFF, 256,
CBA_IF_FALSE); CBA_IF_FALSE);
break; break;
case 2: 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); GSA_16_BIT_IF_LOWER_OR_EQ_U);
break; break;
case 3: 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); GSA_16_BIT_IF_HIGHER_OR_EQ_U);
break; break;
default: default:
// unsupported code // unsupported code
cheatsAdd(code, desc, address, address, value, 256, cheatsAdd(code, desc, address, address, value, 256,
UNKNOWN_CODE); UNKNOWN_CODE);
break; break;
} }
} else } else
cheatsAdd(code, desc, address, address, value, 256, cheatsAdd(code, desc, address, address, value, 256,
UNKNOWN_CODE); UNKNOWN_CODE);
break; break;
case 0x0e: case 0x0e:
switch((value >> 28) & 0xF) { switch((value >> 28) & 0xF) {
case 0: 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); GSA_16_BIT_MIF_TRUE);
break; break;
case 1: 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); GSA_16_BIT_MIF_FALSE);
break; break;
case 2: 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); GSA_16_BIT_MIF_LOWER_OR_EQ_U);
break; break;
case 3: 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); GSA_16_BIT_MIF_HIGHER_OR_EQ_U);
break; break;
default: default:
// unsupported code // unsupported code
cheatsAdd(code, desc, address, address, value, 256, cheatsAdd(code, desc, address, address, value, 256,
UNKNOWN_CODE); UNKNOWN_CODE);
break; break;
} }
@ -2074,7 +2074,7 @@ void cheatsAddGSACode(const char *code, const char *desc, bool v3)
break; break;
default: default:
// unsupported code // unsupported code
cheatsAdd(code, desc, address, address, value, 256, cheatsAdd(code, desc, address, address, value, 256,
UNKNOWN_CODE); UNKNOWN_CODE);
break; break;
} }
@ -2086,7 +2086,7 @@ bool cheatsImportGSACodeFile(const char *name, int game, bool v3)
FILE *f = fopen(name, "rb"); FILE *f = fopen(name, "rb");
if(!f) if(!f)
return false; return false;
int games = 0; int games = 0;
int len = 0; int len = 0;
fseek(f, 0x1e, SEEK_CUR); fseek(f, 0x1e, SEEK_CUR);
@ -2371,7 +2371,7 @@ void cheatsCBAGenTable() {
u16 cheatsCBACalcCRC(u8 *rom, int count) u16 cheatsCBACalcCRC(u8 *rom, int count)
{ {
u32 crc = 0xffffffff; u32 crc = 0xffffffff;
if (count & 3) { if (count & 3) {
// 0x08000EAE // 0x08000EAE
} else { } else {
@ -2458,7 +2458,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
N_("Invalid CBA code. Format is XXXXXXXX YYYY.")); N_("Invalid CBA code. Format is XXXXXXXX YYYY."));
return; return;
} }
int i; int i;
for(i = 0; i < 8; i++) { for(i = 0; i < 8; i++) {
if(!CHEAT_IS_HEX(code[i])) { if(!CHEAT_IS_HEX(code[i])) {
@ -2472,9 +2472,9 @@ void cheatsAddCBACode(const char *code, const char *desc)
if(code[8] != ' ') { if(code[8] != ' ') {
systemMessage(MSG_INVALID_CBA_CODE, systemMessage(MSG_INVALID_CBA_CODE,
N_("Invalid CBA code. Format is XXXXXXXX YYYY.")); N_("Invalid CBA code. Format is XXXXXXXX YYYY."));
return; return;
} }
for(i = 9; i < 13; i++) { for(i = 9; i < 13; i++) {
if(!CHEAT_IS_HEX(code[i])) { if(!CHEAT_IS_HEX(code[i])) {
// wrong cheat // wrong cheat
@ -2482,8 +2482,8 @@ void cheatsAddCBACode(const char *code, const char *desc)
N_("Invalid CBA code. Format is XXXXXXXX YYYY.")); N_("Invalid CBA code. Format is XXXXXXXX YYYY."));
return; return;
} }
} }
char buffer[10]; char buffer[10];
strncpy(buffer, code, 8); strncpy(buffer, code, 8);
buffer[8] = 0; buffer[8] = 0;
@ -2517,7 +2517,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
address = READ32LE(((u32 *)array)); address = READ32LE(((u32 *)array));
value = READ16LE(((u16 *)&array[4])); value = READ16LE(((u16 *)&array[4]));
int type = (address >> 28) & 15; int type = (address >> 28) & 15;
if(isMultilineWithData(cheatsNumber-1) || (super>0)) { if(isMultilineWithData(cheatsNumber-1) || (super>0)) {
@ -2526,7 +2526,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
super-= 1; super-= 1;
return; return;
} }
switch(type) { switch(type) {
case 0x00: case 0x00:
{ {
@ -2537,7 +2537,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
systemMessage(MSG_CBA_CODE_WARNING, systemMessage(MSG_CBA_CODE_WARNING,
N_("Warning: Codes seem to be for a different game.\nCodes may not work correctly.")); 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); UNKNOWN_CODE);
} }
break; break;
@ -2546,15 +2546,15 @@ void cheatsAddCBACode(const char *code, const char *desc)
mastercode = (address & 0x1FFFFFF) | 0x08000000; mastercode = (address & 0x1FFFFFF) | 0x08000000;
break; break;
case 0x02: case 0x02:
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512, cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
CBA_OR); CBA_OR);
break; break;
case 0x03: case 0x03:
cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, 512, cheatsAdd(code, desc, address, address & 0x0FFFFFFF, value, 512,
INT_8_BIT_WRITE); INT_8_BIT_WRITE);
break; break;
case 0x04: case 0x04:
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512, cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
CBA_SLIDE_CODE); CBA_SLIDE_CODE);
break; break;
case 0x05: case 0x05:
@ -2563,32 +2563,32 @@ void cheatsAddCBACode(const char *code, const char *desc)
super = getCodeLength(cheatsNumber-1); super = getCodeLength(cheatsNumber-1);
break; break;
case 0x06: case 0x06:
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512, cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
CBA_AND); CBA_AND);
break; break;
case 0x07: case 0x07:
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512, cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
CBA_IF_TRUE); CBA_IF_TRUE);
break; break;
case 0x08: case 0x08:
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512, cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
INT_16_BIT_WRITE); INT_16_BIT_WRITE);
break; break;
case 0x0a: case 0x0a:
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512, cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
CBA_IF_FALSE); CBA_IF_FALSE);
break; break;
case 0x0b: case 0x0b:
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512, cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
CBA_GT); CBA_GT);
break; break;
case 0x0c: case 0x0c:
cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512, cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512,
CBA_LT); CBA_LT);
break; break;
case 0x0d: case 0x0d:
if ((address & 0xF0)<0x30) if ((address & 0xF0)<0x30)
cheatsAdd(code, desc, address, address & 0xF0, value, 512, cheatsAdd(code, desc, address, address & 0xF0, value, 512,
CBA_IF_KEYS_PRESSED); CBA_IF_KEYS_PRESSED);
break; break;
case 0x0e: case 0x0e:
@ -2601,7 +2601,7 @@ void cheatsAddCBACode(const char *code, const char *desc)
break; break;
default: default:
// unsupported code // unsupported code
cheatsAdd(code, desc, address, address & 0xFFFFFFFF, value, 512, cheatsAdd(code, desc, address, address & 0xFFFFFFFF, value, 512,
UNKNOWN_CODE); UNKNOWN_CODE);
break; break;
} }
@ -2611,14 +2611,14 @@ void cheatsAddCBACode(const char *code, const char *desc)
void cheatsSaveGame(gzFile file) void cheatsSaveGame(gzFile file)
{ {
utilWriteInt(file, cheatsNumber); utilWriteInt(file, cheatsNumber);
utilGzWrite(file, cheatsList, sizeof(cheatsList)); utilGzWrite(file, cheatsList, sizeof(cheatsList));
} }
void cheatsReadGame(gzFile file, int version) void cheatsReadGame(gzFile file, int version)
{ {
cheatsNumber = 0; cheatsNumber = 0;
cheatsNumber = utilReadInt(file); cheatsNumber = utilReadInt(file);
if (version > 8) if (version > 8)
@ -2626,7 +2626,7 @@ void cheatsReadGame(gzFile file, int version)
bool firstCodeBreaker = true; bool firstCodeBreaker = true;
for(int i = 0; i < cheatsNumber; i++) { for(int i = 0; i < cheatsNumber; i++) {
if (version <9) if (version <9)
{ {
@ -2676,7 +2676,7 @@ void cheatsReadGame(gzFile file, int version)
buffer[4] = 0; buffer[4] = 0;
u32 value; u32 value;
sscanf(buffer, "%x", &value); sscanf(buffer, "%x", &value);
u32 seed[8]; u32 seed[8];
cheatsCBAParseSeedCode(address, value, seed); cheatsCBAParseSeedCode(address, value, seed);
cheatsCBAChangeEncryption(seed); cheatsCBAChangeEncryption(seed);
@ -2717,7 +2717,7 @@ bool cheatsLoadCheatList(const char *file)
fclose(f); fclose(f);
return false; return false;
} }
if(version != 1) { if(version != 1) {
systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_VERSION, systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_VERSION,
N_("Unsupported cheat list version %d"), version); N_("Unsupported cheat list version %d"), version);
@ -2738,7 +2738,7 @@ bool cheatsLoadCheatList(const char *file)
fclose(f); fclose(f);
return false; return false;
} }
if(fread(&count, 1, sizeof(count), f) != sizeof(count)) { if(fread(&count, 1, sizeof(count), f) != sizeof(count)) {
fclose(f); fclose(f);
return false; return false;
@ -2771,7 +2771,7 @@ bool cheatsLoadCheatList(const char *file)
} }
bool firstCodeBreaker = true; bool firstCodeBreaker = true;
for(int i = 0; i < count; i++) { for(int i = 0; i < count; i++) {
cheatsList[i].status = 0; // remove old status as it is not used cheatsList[i].status = 0; // remove old status as it is not used
if(!cheatsList[i].codestring[0]) { if(!cheatsList[i].codestring[0]) {
@ -2790,7 +2790,7 @@ bool cheatsLoadCheatList(const char *file)
break; break;
} }
} }
if(cheatsList[i].code == 512 && firstCodeBreaker) { if(cheatsList[i].code == 512 && firstCodeBreaker) {
firstCodeBreaker = false; firstCodeBreaker = false;
char buffer[10]; char buffer[10];
@ -2803,11 +2803,11 @@ bool cheatsLoadCheatList(const char *file)
buffer[4] = 0; buffer[4] = 0;
u32 value; u32 value;
sscanf(buffer, "%x", &value); sscanf(buffer, "%x", &value);
u32 seed[8]; u32 seed[8];
cheatsCBAParseSeedCode(address, value, seed); cheatsCBAParseSeedCode(address, value, seed);
cheatsCBAChangeEncryption(seed); cheatsCBAChangeEncryption(seed);
} }
} }
} }
cheatsNumber = count; cheatsNumber = count;
@ -2817,7 +2817,7 @@ bool cheatsLoadCheatList(const char *file)
extern int cpuNextEvent; extern int cpuNextEvent;
extern void debuggerBreakOnWrite(u32 , u32, u32, int, int); extern void debuggerBreakOnWrite(u32 , u32, u32, int, int);
static u8 cheatsGetType(u32 address) static u8 cheatsGetType(u32 address)
{ {

View File

@ -140,7 +140,7 @@ void eepromWrite(u32 /* address */, u8 value)
eepromAddress = ((eepromBuffer[0] & 0x3F) << 8) | eepromAddress = ((eepromBuffer[0] & 0x3F) << 8) |
((eepromBuffer[1] & 0xFF)); ((eepromBuffer[1] & 0xFF));
if(!(eepromBuffer[0] & 0x40)) { if(!(eepromBuffer[0] & 0x40)) {
eepromBuffer[0] = bit; eepromBuffer[0] = bit;
eepromBits = 1; eepromBits = 1;
eepromByte = 0; eepromByte = 0;
eepromMode = EEPROM_WRITEDATA; eepromMode = EEPROM_WRITEDATA;
@ -157,7 +157,7 @@ void eepromWrite(u32 /* address */, u8 value)
if(!(eepromBuffer[0] & 0x40)) { if(!(eepromBuffer[0] & 0x40)) {
eepromBuffer[0] = bit; eepromBuffer[0] = bit;
eepromBits = 1; eepromBits = 1;
eepromByte = 0; eepromByte = 0;
eepromMode = EEPROM_WRITEDATA; eepromMode = EEPROM_WRITEDATA;
} else { } else {
eepromMode = EEPROM_READDATA; eepromMode = EEPROM_READDATA;
@ -194,4 +194,4 @@ void eepromWrite(u32 /* address */, u8 value)
break; break;
} }
} }

View File

@ -53,7 +53,7 @@ static variable_desc flashSaveData[] = {
static variable_desc flashSaveData2[] = { static variable_desc flashSaveData2[] = {
{ &flashState, sizeof(int) }, { &flashState, sizeof(int) },
{ &flashReadState, sizeof(int) }, { &flashReadState, sizeof(int) },
{ &flashSize, sizeof(int) }, { &flashSize, sizeof(int) },
{ &flashSaveMemory[0], 0x20000 }, { &flashSaveMemory[0], 0x20000 },
{ NULL, 0 } { NULL, 0 }
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,498 +1,498 @@
// -*- C++ -*- // -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA development team // Copyright (C) 2005 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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 // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef VBA_GBAinline_H #ifndef VBA_GBAinline_H
#define VBA_GBAinline_H #define VBA_GBAinline_H
#include "System.h" #include "System.h"
#include "Port.h" #include "Port.h"
#include "RTC.h" #include "RTC.h"
extern bool cpuSramEnabled; extern bool cpuSramEnabled;
extern bool cpuFlashEnabled; extern bool cpuFlashEnabled;
extern bool cpuEEPROMEnabled; extern bool cpuEEPROMEnabled;
extern bool cpuEEPROMSensorEnabled; extern bool cpuEEPROMSensorEnabled;
extern int lspeed; extern int lspeed;
extern bool linkenable; extern bool linkenable;
extern void LinkSStop(void); extern void LinkSStop(void);
extern bool cpuDmaHack; extern bool cpuDmaHack;
extern bool cpuDmaHack2; extern bool cpuDmaHack2;
extern u32 cpuDmaLast; extern u32 cpuDmaLast;
extern bool timer0On; extern bool timer0On;
extern int timer0Ticks; extern int timer0Ticks;
extern int timer0ClockReload; extern int timer0ClockReload;
extern bool timer1On; extern bool timer1On;
extern int timer1Ticks; extern int timer1Ticks;
extern int timer1ClockReload; extern int timer1ClockReload;
extern bool timer2On; extern bool timer2On;
extern int timer2Ticks; extern int timer2Ticks;
extern int timer2ClockReload; extern int timer2ClockReload;
extern bool timer3On; extern bool timer3On;
extern int timer3Ticks; extern int timer3Ticks;
extern int timer3ClockReload; extern int timer3ClockReload;
extern int cpuTotalTicks; extern int cpuTotalTicks;
#define CPUReadByteQuick(addr) \ #define CPUReadByteQuick(addr) \
map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]
#define CPUReadHalfWordQuick(addr) \ #define CPUReadHalfWordQuick(addr) \
READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
#define CPUReadMemoryQuick(addr) \ #define CPUReadMemoryQuick(addr) \
READ32LE(((u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) READ32LE(((u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
static inline u32 CPUReadMemory(u32 address) static inline u32 CPUReadMemory(u32 address)
{ {
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(address & 3) { if(address & 3) {
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
log("Unaligned word read: %08x at %08x\n", address, armMode ? log("Unaligned word read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2); armNextPC - 4 : armNextPC - 2);
} }
} }
#endif #endif
u32 value; u32 value;
switch(address >> 24) { switch(address >> 24) {
case 0: case 0:
if(reg[15].I >> 24) { if(reg[15].I >> 24) {
if(address < 0x4000) { if(address < 0x4000) {
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) { if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal word read: %08x at %08x\n", address, armMode ? log("Illegal word read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2); armNextPC - 4 : armNextPC - 2);
} }
#endif #endif
value = READ32LE(((u32 *)&biosProtected)); value = READ32LE(((u32 *)&biosProtected));
} }
else goto unreadable; else goto unreadable;
} else } else
value = READ32LE(((u32 *)&bios[address & 0x3FFC])); value = READ32LE(((u32 *)&bios[address & 0x3FFC]));
break; break;
case 2: case 2:
value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC])); value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC]));
break; break;
case 3: case 3:
value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC])); value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC]));
break; break;
case 4: case 4:
if(linkenable && (address>=0x4000120||address<=0x4000126)&&lspeed) if(linkenable && (address>=0x4000120||address<=0x4000126)&&lspeed)
LinkSStop(); LinkSStop();
if((address < 0x4000400) && ioReadable[address & 0x3fc]) { if((address < 0x4000400) && ioReadable[address & 0x3fc]) {
if(ioReadable[(address & 0x3fc) + 2]) if(ioReadable[(address & 0x3fc) + 2])
value = READ32LE(((u32 *)&ioMem[address & 0x3fC])); value = READ32LE(((u32 *)&ioMem[address & 0x3fC]));
else else
value = READ16LE(((u16 *)&ioMem[address & 0x3fc])); value = READ16LE(((u16 *)&ioMem[address & 0x3fc]));
} else goto unreadable; } else goto unreadable;
break; break;
case 5: case 5:
value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC])); value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC]));
break; break;
case 6: case 6:
address = (address & 0x1fffc); address = (address & 0x1fffc);
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000)) if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
{ {
value = 0; value = 0;
break; break;
} }
if ((address & 0x18000) == 0x18000) if ((address & 0x18000) == 0x18000)
address &= 0x17fff; address &= 0x17fff;
value = READ32LE(((u32 *)&vram[address])); value = READ32LE(((u32 *)&vram[address]));
break; break;
case 7: case 7:
value = READ32LE(((u32 *)&oam[address & 0x3FC])); value = READ32LE(((u32 *)&oam[address & 0x3FC]));
break; break;
case 8: case 8:
case 9: case 9:
case 10: case 10:
case 11: case 11:
case 12: case 12:
value = READ32LE(((u32 *)&rom[address&0x1FFFFFC])); value = READ32LE(((u32 *)&rom[address&0x1FFFFFC]));
break; break;
case 13: case 13:
if(cpuEEPROMEnabled) if(cpuEEPROMEnabled)
// no need to swap this // no need to swap this
return eepromRead(address); return eepromRead(address);
goto unreadable; goto unreadable;
case 14: case 14:
if(cpuFlashEnabled | cpuSramEnabled) if(cpuFlashEnabled | cpuSramEnabled)
// no need to swap this // no need to swap this
return flashRead(address); return flashRead(address);
// default // default
default: default:
unreadable: unreadable:
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) { if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal word read: %08x at %08x\n", address, armMode ? log("Illegal word read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2); armNextPC - 4 : armNextPC - 2);
} }
#endif #endif
if(cpuDmaHack || cpuDmaHack2) { if(cpuDmaHack || cpuDmaHack2) {
value = cpuDmaLast; value = cpuDmaLast;
} else { } else {
if(armState) { if(armState) {
value = CPUReadMemoryQuick(reg[15].I); value = CPUReadMemoryQuick(reg[15].I);
} else { } else {
value = CPUReadHalfWordQuick(reg[15].I) | value = CPUReadHalfWordQuick(reg[15].I) |
CPUReadHalfWordQuick(reg[15].I) << 16; CPUReadHalfWordQuick(reg[15].I) << 16;
} }
} }
} }
if(address & 3) { if(address & 3) {
#ifdef C_CORE #ifdef C_CORE
int shift = (address & 3) << 3; int shift = (address & 3) << 3;
value = (value >> shift) | (value << (32 - shift)); value = (value >> shift) | (value << (32 - shift));
#else #else
#ifdef __GNUC__ #ifdef __GNUC__
asm("and $3, %%ecx;" asm("and $3, %%ecx;"
"shl $3 ,%%ecx;" "shl $3 ,%%ecx;"
"ror %%cl, %0" "ror %%cl, %0"
: "=r" (value) : "=r" (value)
: "r" (value), "c" (address)); : "r" (value), "c" (address));
#else #else
__asm { __asm {
mov ecx, address; mov ecx, address;
and ecx, 3; and ecx, 3;
shl ecx, 3; shl ecx, 3;
ror [dword ptr value], cl; ror [dword ptr value], cl;
} }
#endif #endif
#endif #endif
} }
return value; return value;
} }
extern u32 myROM[]; extern u32 myROM[];
static inline u32 CPUReadHalfWord(u32 address) static inline u32 CPUReadHalfWord(u32 address)
{ {
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(address & 1) { if(address & 1) {
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
log("Unaligned halfword read: %08x at %08x\n", address, armMode ? log("Unaligned halfword read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2); armNextPC - 4 : armNextPC - 2);
} }
} }
#endif #endif
u32 value; u32 value;
switch(address >> 24) { switch(address >> 24) {
case 0: case 0:
if (reg[15].I >> 24) { if (reg[15].I >> 24) {
if(address < 0x4000) { if(address < 0x4000) {
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) { if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal halfword read: %08x at %08x\n", address, armMode ? log("Illegal halfword read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2); armNextPC - 4 : armNextPC - 2);
} }
#endif #endif
value = READ16LE(((u16 *)&biosProtected[address&2])); value = READ16LE(((u16 *)&biosProtected[address&2]));
} else goto unreadable; } else goto unreadable;
} else } else
value = READ16LE(((u16 *)&bios[address & 0x3FFE])); value = READ16LE(((u16 *)&bios[address & 0x3FFE]));
break; break;
case 2: case 2:
value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE])); value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE]));
break; break;
case 3: case 3:
value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe])); value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe]));
break; break;
case 4: case 4:
if(linkenable && (address>=0x4000120||address<=0x4000126)&&lspeed) if(linkenable && (address>=0x4000120||address<=0x4000126)&&lspeed)
LinkSStop(); LinkSStop();
if((address < 0x4000400) && ioReadable[address & 0x3fe]) if((address < 0x4000400) && ioReadable[address & 0x3fe])
{ {
value = READ16LE(((u16 *)&ioMem[address & 0x3fe])); value = READ16LE(((u16 *)&ioMem[address & 0x3fe]));
if (((address & 0x3fe)>0xFF) && ((address & 0x3fe)<0x10E)) if (((address & 0x3fe)>0xFF) && ((address & 0x3fe)<0x10E))
{ {
if (((address & 0x3fe) == 0x100) && timer0On) if (((address & 0x3fe) == 0x100) && timer0On)
value = 0xFFFF - ((timer0Ticks-cpuTotalTicks) >> timer0ClockReload); value = 0xFFFF - ((timer0Ticks-cpuTotalTicks) >> timer0ClockReload);
else else
if (((address & 0x3fe) == 0x104) && timer1On && !(TM1CNT & 4)) if (((address & 0x3fe) == 0x104) && timer1On && !(TM1CNT & 4))
value = 0xFFFF - ((timer1Ticks-cpuTotalTicks) >> timer1ClockReload); value = 0xFFFF - ((timer1Ticks-cpuTotalTicks) >> timer1ClockReload);
else else
if (((address & 0x3fe) == 0x108) && timer2On && !(TM2CNT & 4)) if (((address & 0x3fe) == 0x108) && timer2On && !(TM2CNT & 4))
value = 0xFFFF - ((timer2Ticks-cpuTotalTicks) >> timer2ClockReload); value = 0xFFFF - ((timer2Ticks-cpuTotalTicks) >> timer2ClockReload);
else else
if (((address & 0x3fe) == 0x10C) && timer3On && !(TM3CNT & 4)) if (((address & 0x3fe) == 0x10C) && timer3On && !(TM3CNT & 4))
value = 0xFFFF - ((timer3Ticks-cpuTotalTicks) >> timer3ClockReload); value = 0xFFFF - ((timer3Ticks-cpuTotalTicks) >> timer3ClockReload);
} }
} }
else goto unreadable; else goto unreadable;
break; break;
case 5: case 5:
value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe])); value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe]));
break; break;
case 6: case 6:
address = (address & 0x1fffe); address = (address & 0x1fffe);
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000)) if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
{ {
value = 0; value = 0;
break; break;
} }
if ((address & 0x18000) == 0x18000) if ((address & 0x18000) == 0x18000)
address &= 0x17fff; address &= 0x17fff;
value = READ16LE(((u16 *)&vram[address])); value = READ16LE(((u16 *)&vram[address]));
break; break;
case 7: case 7:
value = READ16LE(((u16 *)&oam[address & 0x3fe])); value = READ16LE(((u16 *)&oam[address & 0x3fe]));
break; break;
case 8: case 8:
case 9: case 9:
case 10: case 10:
case 11: case 11:
case 12: case 12:
if(address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8) if(address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8)
value = rtcRead(address); value = rtcRead(address);
else else
value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE])); value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE]));
break; break;
case 13: case 13:
if(cpuEEPROMEnabled) if(cpuEEPROMEnabled)
// no need to swap this // no need to swap this
return eepromRead(address); return eepromRead(address);
goto unreadable; goto unreadable;
case 14: case 14:
if(cpuFlashEnabled | cpuSramEnabled) if(cpuFlashEnabled | cpuSramEnabled)
// no need to swap this // no need to swap this
return flashRead(address); return flashRead(address);
// default // default
default: default:
unreadable: unreadable:
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) { if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal halfword read: %08x at %08x\n", address, armMode ? log("Illegal halfword read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2); armNextPC - 4 : armNextPC - 2);
} }
#endif #endif
if(cpuDmaHack2 || cpuDmaHack) { if(cpuDmaHack2 || cpuDmaHack) {
value = cpuDmaLast & 0xFFFF; value = cpuDmaLast & 0xFFFF;
} else { } else {
if(armState) { if(armState) {
value = CPUReadHalfWordQuick(reg[15].I + (address & 2)); value = CPUReadHalfWordQuick(reg[15].I + (address & 2));
} else { } else {
value = CPUReadHalfWordQuick(reg[15].I); value = CPUReadHalfWordQuick(reg[15].I);
} }
} }
break; break;
} }
if(address & 1) { if(address & 1) {
value = (value >> 8) | (value << 24); value = (value >> 8) | (value << 24);
} }
return value; return value;
} }
static inline u16 CPUReadHalfWordSigned(u32 address) static inline u16 CPUReadHalfWordSigned(u32 address)
{ {
u16 value = CPUReadHalfWord(address); u16 value = CPUReadHalfWord(address);
if((address & 1)) if((address & 1))
value = (s8)value; value = (s8)value;
return value; return value;
} }
static inline u8 CPUReadByte(u32 address) static inline u8 CPUReadByte(u32 address)
{ {
switch(address >> 24) { switch(address >> 24) {
case 0: case 0:
if (reg[15].I >> 24) { if (reg[15].I >> 24) {
if(address < 0x4000) { if(address < 0x4000) {
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) { if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal byte read: %08x at %08x\n", address, armMode ? log("Illegal byte read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2); armNextPC - 4 : armNextPC - 2);
} }
#endif #endif
return biosProtected[address & 3]; return biosProtected[address & 3];
} else goto unreadable; } else goto unreadable;
} }
return bios[address & 0x3FFF]; return bios[address & 0x3FFF];
case 2: case 2:
return workRAM[address & 0x3FFFF]; return workRAM[address & 0x3FFFF];
case 3: case 3:
return internalRAM[address & 0x7fff]; return internalRAM[address & 0x7fff];
case 4: case 4:
if(linkenable&&(address>=0x4000120||address<=0x4000126)&&lspeed) if(linkenable&&(address>=0x4000120||address<=0x4000126)&&lspeed)
LinkSStop(); LinkSStop();
if((address < 0x4000400) && ioReadable[address & 0x3ff]) if((address < 0x4000400) && ioReadable[address & 0x3ff])
return ioMem[address & 0x3ff]; return ioMem[address & 0x3ff];
else goto unreadable; else goto unreadable;
case 5: case 5:
return paletteRAM[address & 0x3ff]; return paletteRAM[address & 0x3ff];
case 6: case 6:
address = (address & 0x1ffff); address = (address & 0x1ffff);
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000)) if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
return 0; return 0;
if ((address & 0x18000) == 0x18000) if ((address & 0x18000) == 0x18000)
address &= 0x17fff; address &= 0x17fff;
return vram[address]; return vram[address];
case 7: case 7:
return oam[address & 0x3ff]; return oam[address & 0x3ff];
case 8: case 8:
case 9: case 9:
case 10: case 10:
case 11: case 11:
case 12: case 12:
return rom[address & 0x1FFFFFF]; return rom[address & 0x1FFFFFF];
case 13: case 13:
if(cpuEEPROMEnabled) if(cpuEEPROMEnabled)
return eepromRead(address); return eepromRead(address);
goto unreadable; goto unreadable;
case 14: case 14:
if(cpuSramEnabled | cpuFlashEnabled) if(cpuSramEnabled | cpuFlashEnabled)
return flashRead(address); return flashRead(address);
if(cpuEEPROMSensorEnabled) { if(cpuEEPROMSensorEnabled) {
switch(address & 0x00008f00) { switch(address & 0x00008f00) {
case 0x8200: case 0x8200:
return systemGetSensorX() & 255; return systemGetSensorX() & 255;
case 0x8300: case 0x8300:
return (systemGetSensorX() >> 8)|0x80; return (systemGetSensorX() >> 8)|0x80;
case 0x8400: case 0x8400:
return systemGetSensorY() & 255; return systemGetSensorY() & 255;
case 0x8500: case 0x8500:
return systemGetSensorY() >> 8; return systemGetSensorY() >> 8;
} }
} }
// default // default
default: default:
unreadable: unreadable:
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_READ) { if(systemVerbose & VERBOSE_ILLEGAL_READ) {
log("Illegal byte read: %08x at %08x\n", address, armMode ? log("Illegal byte read: %08x at %08x\n", address, armMode ?
armNextPC - 4 : armNextPC - 2); armNextPC - 4 : armNextPC - 2);
} }
#endif #endif
if(cpuDmaHack || cpuDmaHack2) { if(cpuDmaHack || cpuDmaHack2) {
return cpuDmaLast & 0xFF; return cpuDmaLast & 0xFF;
} else { } else {
if(armState) { if(armState) {
return CPUReadByteQuick(reg[15].I+(address & 3)); return CPUReadByteQuick(reg[15].I+(address & 3));
} else { } else {
return CPUReadByteQuick(reg[15].I+(address & 1)); return CPUReadByteQuick(reg[15].I+(address & 1));
} }
} }
break; break;
} }
} }
static inline void CPUWriteMemory(u32 address, u32 value) static inline void CPUWriteMemory(u32 address, u32 value)
{ {
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(address & 3) { if(address & 3) {
if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) {
log("Unaligned word write: %08x to %08x from %08x\n", log("Unaligned word write: %08x to %08x from %08x\n",
value, value,
address, address,
armMode ? armNextPC - 4 : armNextPC - 2); armMode ? armNextPC - 4 : armNextPC - 2);
} }
} }
#endif #endif
switch(address >> 24) { switch(address >> 24) {
case 0x02: case 0x02:
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
if(*((u32 *)&freezeWorkRAM[address & 0x3FFFC])) if(*((u32 *)&freezeWorkRAM[address & 0x3FFFC]))
cheatsWriteMemory(address & 0x203FFFC, cheatsWriteMemory(address & 0x203FFFC,
value); value);
else else
#endif #endif
WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value); WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value);
break; break;
case 0x03: case 0x03:
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
if(*((u32 *)&freezeInternalRAM[address & 0x7ffc])) if(*((u32 *)&freezeInternalRAM[address & 0x7ffc]))
cheatsWriteMemory(address & 0x3007FFC, cheatsWriteMemory(address & 0x3007FFC,
value); value);
else else
#endif #endif
WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value); WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value);
break; break;
case 0x04: case 0x04:
if(address < 0x4000400) { if(address < 0x4000400) {
CPUUpdateRegister((address & 0x3FC), value & 0xFFFF); CPUUpdateRegister((address & 0x3FC), value & 0xFFFF);
CPUUpdateRegister((address & 0x3FC) + 2, (value >> 16)); CPUUpdateRegister((address & 0x3FC) + 2, (value >> 16));
} else goto unwritable; } else goto unwritable;
break; break;
case 0x05: case 0x05:
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
if(*((u32 *)&freezePRAM[address & 0x3fc])) if(*((u32 *)&freezePRAM[address & 0x3fc]))
cheatsWriteMemory(address & 0x70003FC, cheatsWriteMemory(address & 0x70003FC,
value); value);
else else
#endif #endif
WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value); WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value);
break; break;
case 0x06: case 0x06:
address = (address & 0x1fffc); address = (address & 0x1fffc);
if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000)) if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000))
return; return;
if ((address & 0x18000) == 0x18000) if ((address & 0x18000) == 0x18000)
address &= 0x17fff; address &= 0x17fff;
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
if(*((u32 *)&freezeVRAM[address])) if(*((u32 *)&freezeVRAM[address]))
cheatsWriteMemory(address + 0x06000000, value); cheatsWriteMemory(address + 0x06000000, value);
else else
#endif #endif
WRITE32LE(((u32 *)&vram[address]), value); WRITE32LE(((u32 *)&vram[address]), value);
break; break;
case 0x07: case 0x07:
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
if(*((u32 *)&freezeOAM[address & 0x3fc])) if(*((u32 *)&freezeOAM[address & 0x3fc]))
cheatsWriteMemory(address & 0x70003FC, cheatsWriteMemory(address & 0x70003FC,
value); value);
else else
#endif #endif
WRITE32LE(((u32 *)&oam[address & 0x3fc]), value); WRITE32LE(((u32 *)&oam[address & 0x3fc]), value);
break; break;
case 0x0D: case 0x0D:
if(cpuEEPROMEnabled) { if(cpuEEPROMEnabled) {
eepromWrite(address, value); eepromWrite(address, value);
break; break;
} }
goto unwritable; goto unwritable;
case 0x0E: case 0x0E:
if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) { if(!eepromInUse | cpuSramEnabled | cpuFlashEnabled) {
(*cpuSaveGameFunc)(address, (u8)value); (*cpuSaveGameFunc)(address, (u8)value);
break; break;
} }
// default // default
default: default:
unwritable: unwritable:
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(systemVerbose & VERBOSE_ILLEGAL_WRITE) { if(systemVerbose & VERBOSE_ILLEGAL_WRITE) {
log("Illegal word write: %08x to %08x from %08x\n", log("Illegal word write: %08x to %08x from %08x\n",
value, value,
address, address,
armMode ? armNextPC - 4 : armNextPC - 2); armMode ? armNextPC - 4 : armNextPC - 2);
} }
#endif #endif
break; break;
} }
} }
#endif //VBA_GBAinline_H #endif //VBA_GBAinline_H

222
src/Gfx.h
View File

@ -148,7 +148,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
int maskX = sizeX-1; int maskX = sizeX-1;
int maskY = sizeY-1; int maskY = sizeY-1;
bool mosaicOn = (control & 0x40) ? true : false; bool mosaicOn = (control & 0x40) ? true : false;
int xxx = hofs & maskX; int xxx = hofs & maskX;
@ -169,26 +169,26 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
if(sizeX > 256) if(sizeX > 256)
screenBase += 0x400; screenBase += 0x400;
} }
int yshift = ((yyy>>3)<<5); int yshift = ((yyy>>3)<<5);
if((control) & 0x80) { if((control) & 0x80) {
u16 *screenSource = screenBase + 0x400 * (xxx>>8) + ((xxx & 255)>>3) + yshift; u16 *screenSource = screenBase + 0x400 * (xxx>>8) + ((xxx & 255)>>3) + yshift;
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u16 data = READ16LE(screenSource); u16 data = READ16LE(screenSource);
int tile = data & 0x3FF; int tile = data & 0x3FF;
int tileX = (xxx & 7); int tileX = (xxx & 7);
int tileY = yyy & 7; int tileY = yyy & 7;
if(data & 0x0400) if(data & 0x0400)
tileX = 7 - tileX; tileX = 7 - tileX;
if(data & 0x0800) if(data & 0x0800)
tileY = 7 - tileY; tileY = 7 - tileY;
u8 color = charBase[tile * 64 + tileY * 8 + tileX]; u8 color = charBase[tile * 64 + tileY * 8 + tileX];
line[x] = color ? (READ16LE(&palette[color]) | prio): 0x80000000; line[x] = color ? (READ16LE(&palette[color]) | prio): 0x80000000;
if(data & 0x0400) { if(data & 0x0400) {
if(tileX == 0) if(tileX == 0)
screenSource++; screenSource++;
@ -212,7 +212,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
yshift; yshift;
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u16 data = READ16LE(screenSource); u16 data = READ16LE(screenSource);
int tile = data & 0x3FF; int tile = data & 0x3FF;
int tileX = (xxx & 7); int tileX = (xxx & 7);
int tileY = yyy & 7; int tileY = yyy & 7;
@ -229,7 +229,7 @@ static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
} else { } else {
color &= 0x0F; color &= 0x0F;
} }
int pal = (READ16LE(screenSource)>>8) & 0xF0; int pal = (READ16LE(screenSource)>>8) & 0xF0;
line[x] = color ? (READ16LE(&palette[pal + color])|prio): 0x80000000; 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 x_l, u16 x_h,
u16 y_l, u16 y_h, u16 y_l, u16 y_h,
u16 pa, u16 pb, u16 pa, u16 pb,
@ -327,8 +327,8 @@ static inline void gfxDrawRotScreen(u16 control,
currentY |= 0xF8000000; currentY |= 0xF8000000;
} else { } else {
currentY += dmy; currentY += dmy;
} }
int realX = currentX; int realX = currentX;
int realY = currentY; int realY = currentY;
@ -338,10 +338,10 @@ static inline void gfxDrawRotScreen(u16 control,
realX -= y*dmx; realX -= y*dmx;
realY -= y*dmy; realY -= y*dmy;
} }
int xxx = (realX >> 8); int xxx = (realX >> 8);
int yyy = (realY >> 8); int yyy = (realY >> 8);
if(control & 0x2000) { if(control & 0x2000) {
xxx %= sizeX; xxx %= sizeX;
yyy %= sizeY; yyy %= sizeY;
@ -350,7 +350,7 @@ static inline void gfxDrawRotScreen(u16 control,
if(yyy < 0) if(yyy < 0)
yyy += sizeY; yyy += sizeY;
} }
if(control & 0x80) { if(control & 0x80) {
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
if(xxx < 0 || if(xxx < 0 ||
@ -360,20 +360,20 @@ static inline void gfxDrawRotScreen(u16 control,
line[x] = 0x80000000; line[x] = 0x80000000;
} else { } else {
int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)]; int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)];
int tileX = (xxx & 7); int tileX = (xxx & 7);
int tileY = yyy & 7; int tileY = yyy & 7;
u8 color = charBase[(tile<<6) + (tileY<<3) + tileX]; u8 color = charBase[(tile<<6) + (tileY<<3) + tileX];
line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000; line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;
} }
realX += dx; realX += dx;
realY += dy; realY += dy;
xxx = (realX >> 8); xxx = (realX >> 8);
yyy = (realY >> 8); yyy = (realY >> 8);
if(control & 0x2000) { if(control & 0x2000) {
xxx %= sizeX; xxx %= sizeX;
yyy %= sizeY; yyy %= sizeY;
@ -392,20 +392,20 @@ static inline void gfxDrawRotScreen(u16 control,
line[x] = 0x80000000; line[x] = 0x80000000;
} else { } else {
int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)]; int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)];
int tileX = (xxx & 7); int tileX = (xxx & 7);
int tileY = yyy & 7; int tileY = yyy & 7;
u8 color = charBase[(tile<<6) + (tileY<<3) + tileX]; u8 color = charBase[(tile<<6) + (tileY<<3) + tileX];
line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000; line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;
} }
realX += dx; realX += dx;
realY += dy; realY += dy;
xxx = (realX >> 8); xxx = (realX >> 8);
yyy = (realY >> 8); yyy = (realY >> 8);
if(control & 0x2000) { if(control & 0x2000) {
xxx %= sizeX; xxx %= sizeX;
yyy %= sizeY; yyy %= sizeY;
@ -414,10 +414,10 @@ static inline void gfxDrawRotScreen(u16 control,
if(yyy < 0) if(yyy < 0)
yyy += sizeY; yyy += sizeY;
} }
} }
} }
if(control & 0x40) { if(control & 0x40) {
int mosaicX = (MOSAIC & 0xF) + 1; int mosaicX = (MOSAIC & 0xF) + 1;
if(mosaicX > 1) { if(mosaicX > 1) {
int m = 1; int m = 1;
@ -430,7 +430,7 @@ static inline void gfxDrawRotScreen(u16 control,
} }
} }
} }
} }
} }
static inline void gfxDrawRotScreen16Bit(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 prio = ((control & 3) << 25) + 0x1000000;
int sizeX = 240; int sizeX = 240;
int sizeY = 160; int sizeY = 160;
int startX = (x_l) | ((x_h & 0x07FF)<<16); int startX = (x_l) | ((x_h & 0x07FF)<<16);
if(x_h & 0x0800) if(x_h & 0x0800)
startX |= 0xF8000000; startX |= 0xF8000000;
@ -469,7 +469,7 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
if(VCOUNT == 0) if(VCOUNT == 0)
changed = 3; changed = 3;
if(changed & 1) { if(changed & 1) {
currentX = (x_l) | ((x_h & 0x07FF)<<16); currentX = (x_l) | ((x_h & 0x07FF)<<16);
if(x_h & 0x0800) if(x_h & 0x0800)
@ -483,8 +483,8 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
currentY |= 0xF8000000; currentY |= 0xF8000000;
} else { } else {
currentY += dmy; currentY += dmy;
} }
int realX = currentX; int realX = currentX;
int realY = currentY; int realY = currentY;
@ -494,10 +494,10 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
realX -= y*dmx; realX -= y*dmx;
realY -= y*dmy; realY -= y*dmy;
} }
int xxx = (realX >> 8); int xxx = (realX >> 8);
int yyy = (realY >> 8); int yyy = (realY >> 8);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
if(xxx < 0 || if(xxx < 0 ||
yyy < 0 || yyy < 0 ||
@ -509,12 +509,12 @@ static inline void gfxDrawRotScreen16Bit(u16 control,
} }
realX += dx; realX += dx;
realY += dy; realY += dy;
xxx = (realX >> 8); xxx = (realX >> 8);
yyy = (realY >> 8); yyy = (realY >> 8);
} }
if(control & 0x40) { if(control & 0x40) {
int mosaicX = (MOSAIC & 0xF) + 1; int mosaicX = (MOSAIC & 0xF) + 1;
if(mosaicX > 1) { if(mosaicX > 1) {
int m = 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 x_l, u16 x_h,
u16 y_l, u16 y_h, u16 y_l, u16 y_h,
u16 pa, u16 pb, u16 pa, u16 pb,
@ -544,7 +544,7 @@ static inline void gfxDrawRotScreen256(u16 control,
int prio = ((control & 3) << 25) + 0x1000000; int prio = ((control & 3) << 25) + 0x1000000;
int sizeX = 240; int sizeX = 240;
int sizeY = 160; int sizeY = 160;
int startX = (x_l) | ((x_h & 0x07FF)<<16); int startX = (x_l) | ((x_h & 0x07FF)<<16);
if(x_h & 0x0800) if(x_h & 0x0800)
startX |= 0xF8000000; startX |= 0xF8000000;
@ -582,8 +582,8 @@ static inline void gfxDrawRotScreen256(u16 control,
currentY |= 0xF8000000; currentY |= 0xF8000000;
} else { } else {
currentY += dmy; currentY += dmy;
} }
int realX = currentX; int realX = currentX;
int realY = currentY; int realY = currentY;
@ -593,10 +593,10 @@ static inline void gfxDrawRotScreen256(u16 control,
realX = startX + y*dmx; realX = startX + y*dmx;
realY = startY + y*dmy; realY = startY + y*dmy;
} }
int xxx = (realX >> 8); int xxx = (realX >> 8);
int yyy = (realY >> 8); int yyy = (realY >> 8);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
if(xxx < 0 || if(xxx < 0 ||
yyy < 0 || yyy < 0 ||
@ -605,17 +605,17 @@ static inline void gfxDrawRotScreen256(u16 control,
line[x] = 0x80000000; line[x] = 0x80000000;
} else { } else {
u8 color = screenBase[yyy * 240 + xxx]; u8 color = screenBase[yyy * 240 + xxx];
line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000; line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;
} }
realX += dx; realX += dx;
realY += dy; realY += dy;
xxx = (realX >> 8); xxx = (realX >> 8);
yyy = (realY >> 8); yyy = (realY >> 8);
} }
if(control & 0x40) { if(control & 0x40) {
int mosaicX = (MOSAIC & 0xF) + 1; int mosaicX = (MOSAIC & 0xF) + 1;
if(mosaicX > 1) { if(mosaicX > 1) {
int m = 1; int m = 1;
@ -628,7 +628,7 @@ static inline void gfxDrawRotScreen256(u16 control,
} }
} }
} }
} }
} }
static inline void gfxDrawRotScreen16Bit160(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 prio = ((control & 3) << 25) + 0x1000000;
int sizeX = 160; int sizeX = 160;
int sizeY = 128; int sizeY = 128;
int startX = (x_l) | ((x_h & 0x07FF)<<16); int startX = (x_l) | ((x_h & 0x07FF)<<16);
if(x_h & 0x0800) if(x_h & 0x0800)
startX |= 0xF8000000; startX |= 0xF8000000;
@ -683,8 +683,8 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
currentY |= 0xF8000000; currentY |= 0xF8000000;
} else { } else {
currentY += dmy; currentY += dmy;
} }
int realX = currentX; int realX = currentX;
int realY = currentY; int realY = currentY;
@ -694,10 +694,10 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
realX = startX + y*dmx; realX = startX + y*dmx;
realY = startY + y*dmy; realY = startY + y*dmy;
} }
int xxx = (realX >> 8); int xxx = (realX >> 8);
int yyy = (realY >> 8); int yyy = (realY >> 8);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
if(xxx < 0 || if(xxx < 0 ||
yyy < 0 || yyy < 0 ||
@ -709,12 +709,12 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
} }
realX += dx; realX += dx;
realY += dy; realY += dy;
xxx = (realX >> 8); xxx = (realX >> 8);
yyy = (realY >> 8); yyy = (realY >> 8);
} }
if(control & 0x40) { if(control & 0x40) {
int mosaicX = (MOSAIC & 0xF) + 1; int mosaicX = (MOSAIC & 0xF) + 1;
if(mosaicX > 1) { if(mosaicX > 1) {
int m = 1; int m = 1;
@ -727,7 +727,7 @@ static inline void gfxDrawRotScreen16Bit160(u16 control,
} }
} }
} }
} }
} }
static inline void gfxDrawSprites(u32 *lineOBJ) static inline void gfxDrawSprites(u32 *lineOBJ)
@ -742,7 +742,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
u16 *sprites = (u16 *)oam; u16 *sprites = (u16 *)oam;
u16 *spritePalette = &((u16 *)paletteRAM)[256]; u16 *spritePalette = &((u16 *)paletteRAM)[256];
int mosaicY = ((MOSAIC & 0xF000)>>12) + 1; 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++) { for(int x = 0; x < 128 ; x++) {
u16 a0 = READ16LE(sprites++); u16 a0 = READ16LE(sprites++);
u16 a1 = READ16LE(sprites++); u16 a1 = READ16LE(sprites++);
@ -763,7 +763,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
a0 &= 0x3FFF; a0 &= 0x3FFF;
a1 &= 0x3FFF; a1 &= 0x3FFF;
} }
int sizeX = 8<<(a1>>14); int sizeX = 8<<(a1>>14);
int sizeY = sizeX; int sizeY = sizeX;
@ -827,7 +827,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
continue; continue;
if(a0 & 0x0100) { if(a0 & 0x0100) {
int fieldX = sizeX; int fieldX = sizeX;
int fieldY = sizeY; int fieldY = sizeY;
@ -846,7 +846,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
} }
if (lineOBJpix>0) if (lineOBJpix>0)
if((sx < 240) || startpix) { if((sx < 240) || startpix) {
lineOBJpix-=8; lineOBJpix-=8;
// int t2 = t - (fieldY >> 1); // int t2 = t - (fieldY >> 1);
int rot = (a1 >> 9) & 0x1F; int rot = (a1 >> 9) & 0x1F;
u16 *OAM = (u16 *)oam; u16 *OAM = (u16 *)oam;
@ -862,7 +862,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
int dmy = READ16LE(&OAM[15 + (rot << 4)]); int dmy = READ16LE(&OAM[15 + (rot << 4)]);
if(dmy & 0x8000) if(dmy & 0x8000)
dmy |= 0xFFFF8000; dmy |= 0xFFFF8000;
if(a0 & 0x1000) { if(a0 & 0x1000) {
t -= (t % mosaicY); t -= (t % mosaicY);
} }
@ -873,7 +873,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
+ t * dmy; + t * dmy;
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
if(a0 & 0x2000) { if(a0 & 0x2000) {
int c = (a2 & 0x3FF); int c = (a2 & 0x3FF);
if((DISPCNT & 7) > 2 && (c < 512)) if((DISPCNT & 7) > 2 && (c < 512))
@ -890,7 +890,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
continue; continue;
int xxx = realX >> 8; int xxx = realX >> 8;
int yyy = realY >> 8; int yyy = realY >> 8;
if(xxx < 0 || xxx >= sizeX || if(xxx < 0 || xxx >= sizeX ||
yyy < 0 || yyy >= sizeY || yyy < 0 || yyy >= sizeY ||
sx >= 240); sx >= 240);
@ -898,7 +898,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5) u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5)
+ ((yyy & 7)<<3) + ((xxx >> 3)<<6) + + ((yyy & 7)<<3) + ((xxx >> 3)<<6) +
(xxx & 7))&0x7FFF)]; (xxx & 7))&0x7FFF)];
if ((color==0) && (((prio >> 25)&3) < if ((color==0) && (((prio >> 25)&3) <
((lineOBJ[sx]>>25)&3))) { ((lineOBJ[sx]>>25)&3))) {
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
if((a0 & 0x1000) && m) if((a0 & 0x1000) && m)
@ -927,7 +927,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
int c = (a2 & 0x3FF); int c = (a2 & 0x3FF);
if((DISPCNT & 7) > 2 && (c < 512)) if((DISPCNT & 7) > 2 && (c < 512))
continue; continue;
int inc = 32; int inc = 32;
if(DISPCNT & 0x40) if(DISPCNT & 0x40)
inc = sizeX >> 3; inc = sizeX >> 3;
@ -950,8 +950,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
color >>= 4; color >>= 4;
else else
color &= 0x0F; color &= 0x0F;
if ((color==0) && (((prio >> 25)&3) < if ((color==0) && (((prio >> 25)&3) <
((lineOBJ[sx]>>25)&3))) { ((lineOBJ[sx]>>25)&3))) {
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
if((a0 & 0x1000) && m) if((a0 & 0x1000) && m)
@ -975,8 +975,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
sx = (sx+1)&511; sx = (sx+1)&511;
realX += dx; realX += dx;
realY += dy; realY += dy;
} }
} }
} }
} }
@ -998,7 +998,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
int c = (a2 & 0x3FF); int c = (a2 & 0x3FF);
if((DISPCNT & 7) > 2 && (c < 512)) if((DISPCNT & 7) > 2 && (c < 512))
continue; continue;
int inc = 32; int inc = 32;
if(DISPCNT & 0x40) { if(DISPCNT & 0x40) {
inc = sizeX >> 2; inc = sizeX >> 2;
@ -1015,11 +1015,11 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
int address = 0x10000 + ((((c+ (t>>3) * inc) << 5) int address = 0x10000 + ((((c+ (t>>3) * inc) << 5)
+ ((t & 7) << 3) + ((xxx>>3)<<6) + (xxx & 7)) & 0x7FFF); + ((t & 7) << 3) + ((xxx>>3)<<6) + (xxx & 7)) & 0x7FFF);
if(a1 & 0x1000) if(a1 & 0x1000)
xxx = 7; xxx = 7;
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
for(int xx = 0; xx < sizeX; xx++) { for(int xx = 0; xx < sizeX; xx++) {
if (xx >= startpix) if (xx >= startpix)
lineOBJpix--; lineOBJpix--;
@ -1027,7 +1027,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
continue; continue;
if(sx < 240) { if(sx < 240) {
u8 color = vram[address]; u8 color = vram[address];
if ((color==0) && (((prio >> 25)&3) < if ((color==0) && (((prio >> 25)&3) <
((lineOBJ[sx]>>25)&3))) { ((lineOBJ[sx]>>25)&3))) {
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
if((a0 & 0x1000) && m) if((a0 & 0x1000) && m)
@ -1049,7 +1049,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
lineOBJ[sx] = 0x001F; lineOBJ[sx] = 0x001F;
#endif #endif
} }
sx = (sx+1) & 511; sx = (sx+1) & 511;
if(a1 & 0x1000) { if(a1 & 0x1000) {
xxx--; xxx--;
@ -1077,7 +1077,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
int c = (a2 & 0x3FF); int c = (a2 & 0x3FF);
if((DISPCNT & 7) > 2 && (c < 512)) if((DISPCNT & 7) > 2 && (c < 512))
continue; continue;
int inc = 32; int inc = 32;
if(DISPCNT & 0x40) { if(DISPCNT & 0x40) {
inc = sizeX >> 3; inc = sizeX >> 3;
@ -1085,7 +1085,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
int xxx = 0; int xxx = 0;
if(a1 & 0x1000) if(a1 & 0x1000)
xxx = sizeX - 1; xxx = sizeX - 1;
if(a0 & 0x1000) { if(a0 & 0x1000) {
t -= (t % mosaicY); t -= (t % mosaicY);
} }
@ -1093,7 +1093,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
int address = 0x10000 + ((((c + (t>>3) * inc)<<5) int address = 0x10000 + ((((c + (t>>3) * inc)<<5)
+ ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7FFF); + ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7FFF);
u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
int palette = (a2 >> 8) & 0xF0; int palette = (a2 >> 8) & 0xF0;
if(a1 & 0x1000) { if(a1 & 0x1000) {
xxx = 7; xxx = 7;
for(int xx = sizeX - 1; xx >= 0; xx--) { for(int xx = sizeX - 1; xx >= 0; xx--) {
@ -1107,8 +1107,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
color = (color >> 4); color = (color >> 4);
} else } else
color &= 0x0F; color &= 0x0F;
if ((color==0) && (((prio >> 25)&3) < if ((color==0) && (((prio >> 25)&3) <
((lineOBJ[sx]>>25)&3))) { ((lineOBJ[sx]>>25)&3))) {
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
if((a0 & 0x1000) && m) if((a0 & 0x1000) && m)
@ -1138,8 +1138,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
} }
if(address < 0x10000) if(address < 0x10000)
address += 0x8000; address += 0x8000;
} }
} else { } else {
for(int xx = 0; xx < sizeX; xx++) { for(int xx = 0; xx < sizeX; xx++) {
if (xx >= startpix) if (xx >= startpix)
lineOBJpix--; lineOBJpix--;
@ -1151,8 +1151,8 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
color = (color >> 4); color = (color >> 4);
} else } else
color &= 0x0F; color &= 0x0F;
if ((color==0) && (((prio >> 25)&3) < if ((color==0) && (((prio >> 25)&3) <
((lineOBJ[sx]>>25)&3))) { ((lineOBJ[sx]>>25)&3))) {
lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio;
if((a0 & 0x1000) && m) if((a0 & 0x1000) && m)
@ -1183,7 +1183,7 @@ static inline void gfxDrawSprites(u32 *lineOBJ)
} }
if(address > 0x17fff) if(address > 0x17fff)
address -= 0x8000; address -= 0x8000;
} }
} }
} }
} }
@ -1215,13 +1215,13 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
if ((a0 & 0x0c00) == 0x0c00) if ((a0 & 0x0c00) == 0x0c00)
a0 &=0xF3FF; a0 &=0xF3FF;
if ((a0>>14) == 3) if ((a0>>14) == 3)
{ {
a0 &= 0x3FFF; a0 &= 0x3FFF;
a1 &= 0x3FFF; a1 &= 0x3FFF;
} }
int sizeX = 8<<(a1>>14); int sizeX = 8<<(a1>>14);
int sizeY = sizeX; int sizeY = sizeX;
@ -1241,7 +1241,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
} }
int sy = (a0 & 255); int sy = (a0 & 255);
if(a0 & 0x0100) { if(a0 & 0x0100) {
int fieldX = sizeX; int fieldX = sizeX;
int fieldY = sizeY; int fieldY = sizeY;
@ -1276,14 +1276,14 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
int dmy = READ16LE(&OAM[15 + (rot << 4)]); int dmy = READ16LE(&OAM[15 + (rot << 4)]);
if(dmy & 0x8000) if(dmy & 0x8000)
dmy |= 0xFFFF8000; dmy |= 0xFFFF8000;
int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx
+ t * dmx; + t * dmx;
int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy
+ t * dmy; + t * dmy;
// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); // u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
if(a0 & 0x2000) { if(a0 & 0x2000) {
int c = (a2 & 0x3FF); int c = (a2 & 0x3FF);
if((DISPCNT & 7) > 2 && (c < 512)) if((DISPCNT & 7) > 2 && (c < 512))
@ -1300,7 +1300,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
continue; continue;
int xxx = realX >> 8; int xxx = realX >> 8;
int yyy = realY >> 8; int yyy = realY >> 8;
if(xxx < 0 || xxx >= sizeX || if(xxx < 0 || xxx >= sizeX ||
yyy < 0 || yyy >= sizeY || yyy < 0 || yyy >= sizeY ||
sx >= 240) { sx >= 240) {
@ -1320,11 +1320,11 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
int c = (a2 & 0x3FF); int c = (a2 & 0x3FF);
if((DISPCNT & 7) > 2 && (c < 512)) if((DISPCNT & 7) > 2 && (c < 512))
continue; continue;
int inc = 32; int inc = 32;
if(DISPCNT & 0x40) if(DISPCNT & 0x40)
inc = sizeX >> 3; inc = sizeX >> 3;
// int palette = (a2 >> 8) & 0xF0; // int palette = (a2 >> 8) & 0xF0;
for(int x = 0; x < fieldX; x++) { for(int x = 0; x < fieldX; x++) {
if (x >= startpix) if (x >= startpix)
lineOBJpix-=2; lineOBJpix-=2;
@ -1348,7 +1348,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
color >>= 4; color >>= 4;
else else
color &= 0x0F; color &= 0x0F;
if(color) { if(color) {
lineOBJWin[sx] = 1; lineOBJWin[sx] = 1;
} }
@ -1357,7 +1357,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
sx = (sx+1)&511; sx = (sx+1)&511;
realX += dx; realX += dx;
realY += dy; realY += dy;
} }
} }
} }
} }
@ -1380,7 +1380,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
int c = (a2 & 0x3FF); int c = (a2 & 0x3FF);
if((DISPCNT & 7) > 2 && (c < 512)) if((DISPCNT & 7) > 2 && (c < 512))
continue; continue;
int inc = 32; int inc = 32;
if(DISPCNT & 0x40) { if(DISPCNT & 0x40) {
inc = sizeX >> 2; inc = sizeX >> 2;
@ -1406,7 +1406,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
lineOBJWin[sx] = 1; lineOBJWin[sx] = 1;
} }
} }
sx = (sx+1) & 511; sx = (sx+1) & 511;
if(a1 & 0x1000) { if(a1 & 0x1000) {
xxx--; xxx--;
@ -1434,7 +1434,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
int c = (a2 & 0x3FF); int c = (a2 & 0x3FF);
if((DISPCNT & 7) > 2 && (c < 512)) if((DISPCNT & 7) > 2 && (c < 512))
continue; continue;
int inc = 32; int inc = 32;
if(DISPCNT & 0x40) { if(DISPCNT & 0x40) {
inc = sizeX >> 3; inc = sizeX >> 3;
@ -1445,7 +1445,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
int address = 0x10000 + ((((c + (t>>3) * inc)<<5) int address = 0x10000 + ((((c + (t>>3) * inc)<<5)
+ ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7fff); + ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7fff);
// u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); // u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6);
// int palette = (a2 >> 8) & 0xF0; // int palette = (a2 >> 8) & 0xF0;
if(a1 & 0x1000) { if(a1 & 0x1000) {
xxx = 7; xxx = 7;
for(int xx = sizeX - 1; xx >= 0; xx--) { for(int xx = sizeX - 1; xx >= 0; xx--) {
@ -1459,7 +1459,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
color = (color >> 4); color = (color >> 4);
} else } else
color &= 0x0F; color &= 0x0F;
if(color) { if(color) {
lineOBJWin[sx] = 1; lineOBJWin[sx] = 1;
} }
@ -1474,8 +1474,8 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
} }
if(address < 0x10000) if(address < 0x10000)
address += 0x8000; address += 0x8000;
} }
} else { } else {
for(int xx = 0; xx < sizeX; xx++) { for(int xx = 0; xx < sizeX; xx++) {
if (xx >= startpix) if (xx >= startpix)
lineOBJpix--; lineOBJpix--;
@ -1487,7 +1487,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
color = (color >> 4); color = (color >> 4);
} else } else
color &= 0x0F; color &= 0x0F;
if(color) { if(color) {
lineOBJWin[sx] = 1; lineOBJWin[sx] = 1;
} }
@ -1502,7 +1502,7 @@ static inline void gfxDrawOBJWin(u32 *lineOBJWin)
} }
if(address > 0x17fff) if(address > 0x17fff)
address -= 0x8000; address -= 0x8000;
} }
} }
} }
} }
@ -1517,7 +1517,7 @@ static inline u32 gfxIncreaseBrightness(u32 color, int coeff)
int r = (color & 0x1F); int r = (color & 0x1F);
int g = ((color >> 5) & 0x1F); int g = ((color >> 5) & 0x1F);
int b = ((color >> 10) & 0x1F); int b = ((color >> 10) & 0x1F);
r = r + (((31 - r) * coeff) >> 4); r = r + (((31 - r) * coeff) >> 4);
g = g + (((31 - g) * coeff) >> 4); g = g + (((31 - g) * coeff) >> 4);
b = b + (((31 - b) * 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 r = (color & 0x1F);
int g = ((color >> 5) & 0x1F); int g = ((color >> 5) & 0x1F);
int b = ((color >> 10) & 0x1F); int b = ((color >> 10) & 0x1F);
r = r + (((31 - r) * coeff) >> 4); r = r + (((31 - r) * coeff) >> 4);
g = g + (((31 - g) * coeff) >> 4); g = g + (((31 - g) * coeff) >> 4);
b = b + (((31 - b) * 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 r = (color & 0x1F);
int g = ((color >> 5) & 0x1F); int g = ((color >> 5) & 0x1F);
int b = ((color >> 10) & 0x1F); int b = ((color >> 10) & 0x1F);
r = r - ((r * coeff) >> 4); r = r - ((r * coeff) >> 4);
g = g - ((g * coeff) >> 4); g = g - ((g * coeff) >> 4);
b = b - ((b * coeff) >> 4); b = b - ((b * coeff) >> 4);
@ -1568,7 +1568,7 @@ static inline u32 gfxDecreaseBrightness(u32 color, int coeff)
if(b < 0) if(b < 0)
b = 0; b = 0;
color = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; color = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
return color; return color;
} }
@ -1579,7 +1579,7 @@ static inline void gfxDecreaseBrightness(u32 *line, int coeff)
int r = (color & 0x1F); int r = (color & 0x1F);
int g = ((color >> 5) & 0x1F); int g = ((color >> 5) & 0x1F);
int b = ((color >> 10) & 0x1F); int b = ((color >> 10) & 0x1F);
r = r - ((r * coeff) >> 4); r = r - ((r * coeff) >> 4);
g = g - ((g * coeff) >> 4); g = g - ((g * coeff) >> 4);
b = b - ((b * 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 r0 = (color2 & 0x1F);
int g0 = ((color2 >> 5) & 0x1F); int g0 = ((color2 >> 5) & 0x1F);
int b0 = ((color2 >> 10) & 0x1F); int b0 = ((color2 >> 10) & 0x1F);
r = ((r * ca) + (r0 * cb)) >> 4; r = ((r * ca) + (r0 * cb)) >> 4;
g = ((g * ca) + (g0 * cb)) >> 4; g = ((g * ca) + (g0 * cb)) >> 4;
b = ((b * ca) + (b0 * 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 r0 = (color2 & 0x1F);
int g0 = ((color2 >> 5) & 0x1F); int g0 = ((color2 >> 5) & 0x1F);
int b0 = ((color2 >> 10) & 0x1F); int b0 = ((color2 >> 10) & 0x1F);
r = ((r * ca) + (r0 * cb)) >> 4; r = ((r * ca) + (r0 * cb)) >> 4;
g = ((g * ca) + (g0 * cb)) >> 4; g = ((g * ca) + (g0 * cb)) >> 4;
b = ((b * ca) + (b0 * cb)) >> 4; b = ((b * ca) + (b0 * cb)) >> 4;
if(r > 31) if(r > 31)
r = 31; r = 31;
if(g > 31) if(g > 31)
g = 31; g = 31;
if(b > 31) if(b > 31)
b = 31; b = 31;
*ta++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; *ta++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r;
} else { } else {
ta++; ta++;

File diff suppressed because it is too large Load Diff

View File

@ -1,124 +1,124 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team // Copyright (C) 2004 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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 // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include<winsock.h> #include<winsock.h>
#ifndef LINKH #ifndef LINKH
#define LINKH #define LINKH
#define LINK_PARENTLOST 0x80 #define LINK_PARENTLOST 0x80
#define UNSUPPORTED -1 #define UNSUPPORTED -1
#define MULTIPLAYER 0 #define MULTIPLAYER 0
#define NORMAL8 1 #define NORMAL8 1
#define NORMAL32 2 #define NORMAL32 2
#define UART 3 #define UART 3
#define JOYBUS 4 #define JOYBUS 4
#define GP 5 #define GP 5
#define RFU_INIT 0 #define RFU_INIT 0
#define RFU_COMM 1 #define RFU_COMM 1
#define RFU_SEND 2 #define RFU_SEND 2
#define RFU_RECV 3 #define RFU_RECV 3
typedef struct { typedef struct {
WORD linkdata[4]; WORD linkdata[4];
WORD linkcmd[4]; WORD linkcmd[4];
WORD numtransfers; WORD numtransfers;
int lastlinktime; int lastlinktime;
unsigned char numgbas; unsigned char numgbas;
unsigned char linkflags; unsigned char linkflags;
int rfu_q[4]; int rfu_q[4];
u8 rfu_request[4]; u8 rfu_request[4];
int rfu_linktime[4]; int rfu_linktime[4];
u32 rfu_bdata[4][7]; u32 rfu_bdata[4][7];
u32 rfu_data[4][32]; u32 rfu_data[4][32];
} LINKDATA; } LINKDATA;
class lserver{ class lserver{
int numbytes; int numbytes;
fd_set fdset; fd_set fdset;
timeval wsocktimeout; timeval wsocktimeout;
//timeval udptimeout; //timeval udptimeout;
char inbuffer[256], outbuffer[256]; char inbuffer[256], outbuffer[256];
int *intinbuffer; int *intinbuffer;
u16 *u16inbuffer; u16 *u16inbuffer;
int *intoutbuffer; int *intoutbuffer;
u16 *u16outbuffer; u16 *u16outbuffer;
int counter; int counter;
int done; int done;
public: public:
int howmanytimes; int howmanytimes;
SOCKET tcpsocket[4]; SOCKET tcpsocket[4];
SOCKADDR_IN udpaddr[4]; SOCKADDR_IN udpaddr[4];
lserver(void); lserver(void);
int Init(void*); int Init(void*);
void Send(void); void Send(void);
void Recv(void); void Recv(void);
}; };
class lclient{ class lclient{
fd_set fdset; fd_set fdset;
timeval wsocktimeout; timeval wsocktimeout;
char inbuffer[256], outbuffer[256]; char inbuffer[256], outbuffer[256];
int *intinbuffer; int *intinbuffer;
u16 *u16inbuffer; u16 *u16inbuffer;
int *intoutbuffer; int *intoutbuffer;
u16 *u16outbuffer; u16 *u16outbuffer;
int numbytes; int numbytes;
public: public:
bool oncesend; bool oncesend;
SOCKADDR_IN serverinfo; SOCKADDR_IN serverinfo;
SOCKET noblock; SOCKET noblock;
int numtransfers; int numtransfers;
lclient(void); lclient(void);
int Init(LPHOSTENT, void*); int Init(LPHOSTENT, void*);
void Send(void); void Send(void);
void Recv(void); void Recv(void);
void CheckConn(void); void CheckConn(void);
}; };
typedef struct { typedef struct {
SOCKET tcpsocket; SOCKET tcpsocket;
//SOCKET udpsocket; //SOCKET udpsocket;
int numgbas; int numgbas;
HANDLE thread; HANDLE thread;
u8 type; u8 type;
u8 server; u8 server;
bool terminate; bool terminate;
bool connected; bool connected;
bool speed; bool speed;
bool active; bool active;
} LANLINKDATA; } LANLINKDATA;
extern void LinkUpdate(void); extern void LinkUpdate(void);
extern void LinkChildStop(void); extern void LinkChildStop(void);
extern void LinkChildSend(u16); extern void LinkChildSend(u16);
extern int openLinkLog(void); extern int openLinkLog(void);
extern void closeLinkLog(); extern void closeLinkLog();
extern void CloseLanLink(void); extern void CloseLanLink(void);
extern char *MakeInstanceFilename(const char *Input); extern char *MakeInstanceFilename(const char *Input);
extern LANLINKDATA lanlink; extern LANLINKDATA lanlink;
extern FILE *linklogfile; extern FILE *linklogfile;
extern int vbaid; extern int vbaid;
extern int linklog; extern int linklog;
extern bool adapter; extern bool adapter;
extern bool linkenable; extern bool linkenable;
extern int linktimeout; extern int linktimeout;
extern lclient lc; extern lclient lc;
extern int linkid; extern int linkid;
#endif #endif

View File

@ -30,7 +30,7 @@ void mode0RenderLine()
} }
return; return;
} }
if(layerEnable & 0x0100) { if(layerEnable & 0x0100) {
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
} }
@ -38,7 +38,7 @@ void mode0RenderLine()
if(layerEnable & 0x0200) { if(layerEnable & 0x0200) {
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
} }
if(layerEnable & 0x0400) { if(layerEnable & 0x0400) {
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2); gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
} }
@ -50,11 +50,11 @@ void mode0RenderLine()
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = backdrop; u32 color = backdrop;
u8 top = 0x20; u8 top = 0x20;
if(line0[x] < color) { if(line0[x] < color) {
color = line0[x]; color = line0[x];
top = 0x01; top = 0x01;
@ -74,7 +74,7 @@ void mode0RenderLine()
color = line3[x]; color = line3[x];
top = 0x08; top = 0x08;
} }
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) { if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) {
color = lineOBJ[x]; color = lineOBJ[x];
top = 0x10; top = 0x10;
@ -84,17 +84,17 @@ void mode0RenderLine()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((u8)(line0[x]>>24) < (u8)(back >> 24)) { if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
back = line0[x]; back = line0[x];
top2 = 0x01; top2 = 0x01;
} }
if((u8)(line1[x]>>24) < (u8)(back >> 24)) { if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
if((u8)(line2[x]>>24) < (u8)(back >> 24)) { if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
@ -119,8 +119,8 @@ void mode0RenderLine()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
@ -137,7 +137,7 @@ void mode0RenderLineNoWindow()
} }
return; return;
} }
if(layerEnable & 0x0100) { if(layerEnable & 0x0100) {
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
} }
@ -145,7 +145,7 @@ void mode0RenderLineNoWindow()
if(layerEnable & 0x0200) { if(layerEnable & 0x0200) {
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
} }
if(layerEnable & 0x0400) { if(layerEnable & 0x0400) {
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2); gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
} }
@ -159,11 +159,11 @@ void mode0RenderLineNoWindow()
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
int effect = (BLDMOD >> 6) & 3; int effect = (BLDMOD >> 6) & 3;
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = backdrop; u32 color = backdrop;
u8 top = 0x20; u8 top = 0x20;
if(line0[x] < color) { if(line0[x] < color) {
color = line0[x]; color = line0[x];
top = 0x01; top = 0x01;
@ -183,7 +183,7 @@ void mode0RenderLineNoWindow()
color = line3[x]; color = line3[x];
top = 0x08; top = 0x08;
} }
if(lineOBJ[x] < (color & 0xFF000000)) { if(lineOBJ[x] < (color & 0xFF000000)) {
color = lineOBJ[x]; color = lineOBJ[x];
top = 0x10; top = 0x10;
@ -204,40 +204,40 @@ void mode0RenderLineNoWindow()
top2 = 0x01; top2 = 0x01;
} }
} }
if(line1[x] < (back & 0xFF000000)) { if(line1[x] < (back & 0xFF000000)) {
if(top != 0x02) { if(top != 0x02) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
} }
if(line2[x] < (back & 0xFF000000)) { if(line2[x] < (back & 0xFF000000)) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if(line3[x] < (back & 0xFF000000)) { if(line3[x] < (back & 0xFF000000)) {
if(top != 0x08) { if(top != 0x08) {
back = line3[x]; back = line3[x];
top2 = 0x08; top2 = 0x08;
} }
} }
if(lineOBJ[x] < (back & 0xFF000000)) { if(lineOBJ[x] < (back & 0xFF000000)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
coeff[(COLEV >> 8) & 0x1F]); coeff[(COLEV >> 8) & 0x1F]);
} }
} }
break; break;
@ -254,17 +254,17 @@ void mode0RenderLineNoWindow()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if(line0[x] < back) { if(line0[x] < back) {
back = line0[x]; back = line0[x];
top2 = 0x01; top2 = 0x01;
} }
if(line1[x] < (back & 0xFF000000)) { if(line1[x] < (back & 0xFF000000)) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
if(line2[x] < (back & 0xFF000000)) { if(line2[x] < (back & 0xFF000000)) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
@ -289,7 +289,7 @@ void mode0RenderLineNoWindow()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
@ -323,13 +323,13 @@ void mode0RenderLineAll()
if(layerEnable & 0x4000) { if(layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8; u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255; u8 v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if(v1 >= v0) if(v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
else else
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
} }
if((layerEnable & 0x0100)) { if((layerEnable & 0x0100)) {
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
} }
@ -337,7 +337,7 @@ void mode0RenderLineAll()
if((layerEnable & 0x0200)) { if((layerEnable & 0x0200)) {
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
} }
if((layerEnable & 0x0400)) { if((layerEnable & 0x0400)) {
gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2); gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
} }
@ -347,14 +347,14 @@ void mode0RenderLineAll()
} }
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
gfxDrawOBJWin(lineOBJWin); gfxDrawOBJWin(lineOBJWin);
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
u8 inWin0Mask = WININ & 0xFF; u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8; u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF; u8 outMask = WINOUT & 0xFF;
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = backdrop; u32 color = backdrop;
u8 top = 0x20; u8 top = 0x20;
@ -374,32 +374,32 @@ void mode0RenderLineAll()
mask = inWin0Mask; mask = inWin0Mask;
} }
} }
if((mask & 1) && (line0[x] < color)) { if((mask & 1) && (line0[x] < color)) {
color = line0[x]; color = line0[x];
top = 0x01; top = 0x01;
} }
if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(color >> 24))) { if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(color >> 24))) {
color = line1[x]; color = line1[x];
top = 0x02; top = 0x02;
} }
if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(color >> 24))) { if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(color >> 24))) {
color = line2[x]; color = line2[x];
top = 0x04; top = 0x04;
} }
if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(color >> 24))) { if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(color >> 24))) {
color = line3[x]; color = line3[x];
top = 0x08; top = 0x08;
} }
if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))) { if((mask & 16) && ((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))) {
color = lineOBJ[x]; color = lineOBJ[x];
top = 0x10; top = 0x10;
} }
// special FX on in the window // special FX on in the window
if(mask & 32) { if(mask & 32) {
if(!(color & 0x00010000)) { if(!(color & 0x00010000)) {
@ -417,35 +417,35 @@ void mode0RenderLineAll()
top2 = 0x01; top2 = 0x01;
} }
} }
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) { if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
if(top != 0x02) { if(top != 0x02) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
} }
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) { if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) { if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
if(top != 0x08) { if(top != 0x08) {
back = line3[x]; back = line3[x];
top2 = 0x08; top2 = 0x08;
} }
} }
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -466,27 +466,27 @@ void mode0RenderLineAll()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24))) { if((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24))) {
back = line0[x]; back = line0[x];
top2 = 0x01; top2 = 0x01;
} }
if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24))) { if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24))) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24))) { if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24))) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24))) { if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24))) {
back = line3[x]; back = line3[x];
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -501,34 +501,34 @@ void mode0RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
} else if(color & 0x00010000) { } else if(color & 0x00010000) {
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24))) { if((mask & 1) && ((u8)(line0[x]>>24) < (u8)(back >> 24))) {
back = line0[x]; back = line0[x];
top2 = 0x01; top2 = 0x01;
} }
if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24))) { if((mask & 2) && ((u8)(line1[x]>>24) < (u8)(back >> 24))) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24))) { if((mask & 4) && ((u8)(line2[x]>>24) < (u8)(back >> 24))) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24))) { if((mask & 8) && ((u8)(line3[x]>>24) < (u8)(back >> 24))) {
back = line3[x]; back = line3[x];
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -543,10 +543,10 @@ void mode0RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
} }

View File

@ -23,19 +23,19 @@
void mode1RenderLine() void mode1RenderLine()
{ {
u16 *palette = (u16 *)paletteRAM; u16 *palette = (u16 *)paletteRAM;
if(DISPCNT & 0x80) { if(DISPCNT & 0x80) {
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
if(layerEnable & 0x0100) { if(layerEnable & 0x0100) {
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
} }
if(layerEnable & 0x0200) { if(layerEnable & 0x0200) {
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
} }
@ -81,17 +81,17 @@ void mode1RenderLine()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((u8)(line0[x]>>24) < (u8)(back >> 24)) { if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
back = line0[x]; back = line0[x];
top2 = 0x01; top2 = 0x01;
} }
if((u8)(line1[x]>>24) < (u8)(back >> 24)) { if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
if((u8)(line2[x]>>24) < (u8)(back >> 24)) { if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
@ -111,25 +111,25 @@ void mode1RenderLine()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }
void mode1RenderLineNoWindow() void mode1RenderLineNoWindow()
{ {
u16 *palette = (u16 *)paletteRAM; u16 *palette = (u16 *)paletteRAM;
if(DISPCNT & 0x80) { if(DISPCNT & 0x80) {
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
@ -137,7 +137,7 @@ void mode1RenderLineNoWindow()
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
} }
if(layerEnable & 0x0200) { if(layerEnable & 0x0200) {
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
} }
@ -194,28 +194,28 @@ void mode1RenderLineNoWindow()
top2 = 0x01; top2 = 0x01;
} }
} }
if((u8)(line1[x]>>24) < (u8)(back >> 24)) { if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
if(top != 0x02) { if(top != 0x02) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
} }
if((u8)(line2[x]>>24) < (u8)(back >> 24)) { if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -236,17 +236,17 @@ void mode1RenderLineNoWindow()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((u8)(line0[x]>>24) < (u8)(back >> 24)) { if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
back = line0[x]; back = line0[x];
top2 = 0x01; top2 = 0x01;
} }
if((u8)(line1[x]>>24) < (u8)(back >> 24)) { if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
if((u8)(line2[x]>>24) < (u8)(back >> 24)) { if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
@ -266,25 +266,25 @@ void mode1RenderLineNoWindow()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }
void mode1RenderLineAll() void mode1RenderLineAll()
{ {
u16 *palette = (u16 *)paletteRAM; u16 *palette = (u16 *)paletteRAM;
if(DISPCNT & 0x80) { if(DISPCNT & 0x80) {
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
@ -303,17 +303,17 @@ void mode1RenderLineAll()
if(layerEnable & 0x4000) { if(layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8; u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255; u8 v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if(v1 >= v0) if(v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
else else
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
} }
if(layerEnable & 0x0100) { if(layerEnable & 0x0100) {
gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0); gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
} }
if(layerEnable & 0x0200) { if(layerEnable & 0x0200) {
gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1); gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
} }
@ -329,13 +329,13 @@ void mode1RenderLineAll()
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
gfxDrawOBJWin(lineOBJWin); gfxDrawOBJWin(lineOBJWin);
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
u8 inWin0Mask = WININ & 0xFF; u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8; u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF; u8 outMask = WINOUT & 0xFF;
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = backdrop; u32 color = backdrop;
u8 top = 0x20; u8 top = 0x20;
@ -355,7 +355,7 @@ void mode1RenderLineAll()
mask = inWin0Mask; mask = inWin0Mask;
} }
} }
if(line0[x] < color && (mask & 1)) { if(line0[x] < color && (mask & 1)) {
color = line0[x]; color = line0[x];
top = 0x01; top = 0x01;
@ -393,28 +393,28 @@ void mode1RenderLineAll()
top2 = 0x01; top2 = 0x01;
} }
} }
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) { if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
if(top != 0x02) { if(top != 0x02) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
} }
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) { if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -435,22 +435,22 @@ void mode1RenderLineAll()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) { if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) {
back = line0[x]; back = line0[x];
top2 = 0x01; top2 = 0x01;
} }
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) { if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) { if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -465,29 +465,29 @@ void mode1RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
} else if(color & 0x00010000) { } else if(color & 0x00010000) {
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) { if((mask & 1) && (u8)(line0[x]>>24) < (u8)(back >> 24)) {
back = line0[x]; back = line0[x];
top2 = 0x01; top2 = 0x01;
} }
if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) { if((mask & 2) && (u8)(line1[x]>>24) < (u8)(back >> 24)) {
back = line1[x]; back = line1[x];
top2 = 0x02; top2 = 0x02;
} }
if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) { if((mask & 4) && (u8)(line2[x]>>24) < (u8)(back >> 24)) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -502,12 +502,12 @@ void mode1RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }

View File

@ -31,12 +31,12 @@ void mode2RenderLine()
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
if(layerEnable & 0x0400) { if(layerEnable & 0x0400) {
int changed = gfxBG2Changed; int changed = gfxBG2Changed;
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y, BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y,
changed, line2); changed, line2);
@ -46,7 +46,7 @@ void mode2RenderLine()
int changed = gfxBG3Changed; int changed = gfxBG3Changed;
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H, gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y, BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y,
changed, line3); changed, line3);
@ -80,12 +80,12 @@ void mode2RenderLine()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((u8)(line2[x]>>24) < (u8)(back >> 24)) { if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if((u8)(line3[x]>>24) < (u8)(back >> 24)) { if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
back = line3[x]; back = line3[x];
top2 = 0x08; top2 = 0x08;
@ -105,15 +105,15 @@ void mode2RenderLine()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxBG3Changed = 0; gfxBG3Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }
void mode2RenderLineNoWindow() void mode2RenderLineNoWindow()
@ -127,12 +127,12 @@ void mode2RenderLineNoWindow()
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
if(layerEnable & 0x0400) { if(layerEnable & 0x0400) {
int changed = gfxBG2Changed; int changed = gfxBG2Changed;
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y, BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y,
changed, line2); changed, line2);
@ -142,7 +142,7 @@ void mode2RenderLineNoWindow()
int changed = gfxBG3Changed; int changed = gfxBG3Changed;
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H, gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y, BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y,
changed, line3); changed, line3);
@ -181,28 +181,28 @@ void mode2RenderLineNoWindow()
if(top & BLDMOD) { if(top & BLDMOD) {
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((u8)(line2[x]>>24) < (u8)(back >> 24)) { if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((u8)(line3[x]>>24) < (u8)(back >> 24)) { if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
if(top != 0x08) { if(top != 0x08) {
back = line3[x]; back = line3[x];
top2 = 0x08; top2 = 0x08;
} }
} }
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -223,12 +223,12 @@ void mode2RenderLineNoWindow()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((u8)(line2[x]>>24) < (u8)(back >> 24)) { if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if((u8)(line3[x]>>24) < (u8)(back >> 24)) { if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
back = line3[x]; back = line3[x];
top2 = 0x08; top2 = 0x08;
@ -248,15 +248,15 @@ void mode2RenderLineNoWindow()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxBG3Changed = 0; gfxBG3Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }
void mode2RenderLineAll() void mode2RenderLineAll()
@ -286,18 +286,18 @@ void mode2RenderLineAll()
if(layerEnable & 0x4000) { if(layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8; u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255; u8 v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if(v1 >= v0) if(v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
else else
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
} }
if(layerEnable & 0x0400) { if(layerEnable & 0x0400) {
int changed = gfxBG2Changed; int changed = gfxBG2Changed;
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y, BG2PA, BG2PB, BG2PC, BG2PD, gfxBG2X, gfxBG2Y,
changed, line2); changed, line2);
@ -307,7 +307,7 @@ void mode2RenderLineAll()
int changed = gfxBG3Changed; int changed = gfxBG3Changed;
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H, gfxDrawRotScreen(BG3CNT, BG3X_L, BG3X_H, BG3Y_L, BG3Y_H,
BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y, BG3PA, BG3PB, BG3PC, BG3PD, gfxBG3X, gfxBG3Y,
changed, line3); changed, line3);
@ -325,8 +325,8 @@ void mode2RenderLineAll()
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = backdrop; u32 color = backdrop;
u8 top = 0x20; u8 top = 0x20;
u8 mask = outMask; u8 mask = outMask;
if(!(lineOBJWin[x] & 0x80000000)) { if(!(lineOBJWin[x] & 0x80000000)) {
mask = WINOUT >> 8; mask = WINOUT >> 8;
} }
@ -341,22 +341,22 @@ void mode2RenderLineAll()
mask = inWin0Mask; mask = inWin0Mask;
} }
} }
if(line2[x] < color && (mask & 4)) { if(line2[x] < color && (mask & 4)) {
color = line2[x]; color = line2[x];
top = 0x04; top = 0x04;
} }
if((u8)(line3[x]>>24) < (u8)(color >> 24) && (mask & 8)) { if((u8)(line3[x]>>24) < (u8)(color >> 24) && (mask & 8)) {
color = line3[x]; color = line3[x];
top = 0x08; top = 0x08;
} }
if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24) && (mask & 16)) { if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24) && (mask & 16)) {
color = lineOBJ[x]; color = lineOBJ[x];
top = 0x10; top = 0x10;
} }
if(mask & 32) { if(mask & 32) {
if(!(color & 0x00010000)) { if(!(color & 0x00010000)) {
switch((BLDMOD >> 6) & 3) { switch((BLDMOD >> 6) & 3) {
@ -367,32 +367,32 @@ void mode2RenderLineAll()
if(top & BLDMOD) { if(top & BLDMOD) {
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) { if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
if(top != 0x08) { if(top != 0x08) {
back = line3[x]; back = line3[x];
top2 = 0x08; top2 = 0x08;
} }
} }
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
coeff[(COLEV >> 8) & 0x1F]); coeff[(COLEV >> 8) & 0x1F]);
} }
} }
break; break;
@ -409,17 +409,17 @@ void mode2RenderLineAll()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) { if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
back = line3[x]; back = line3[x];
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -434,24 +434,24 @@ void mode2RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
} else if(color & 0x00010000) { } else if(color & 0x00010000) {
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) { if((mask & 8) && (u8)(line3[x]>>24) < (u8)(back >> 24)) {
back = line3[x]; back = line3[x];
top2 = 0x08; top2 = 0x08;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -466,13 +466,13 @@ void mode2RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxBG3Changed = 0; gfxBG3Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }

View File

@ -23,32 +23,32 @@
void mode3RenderLine() void mode3RenderLine()
{ {
u16 *palette = (u16 *)paletteRAM; u16 *palette = (u16 *)paletteRAM;
if(DISPCNT & 0x80) { if(DISPCNT & 0x80) {
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
if(layerEnable & 0x0400) { if(layerEnable & 0x0400) {
int changed = gfxBG2Changed; int changed = gfxBG2Changed;
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H, gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
BG2Y_L, BG2Y_H, BG2PA, BG2PB, BG2Y_L, BG2Y_H, BG2PA, BG2PB,
BG2PC, BG2PD, BG2PC, BG2PD,
gfxBG2X, gfxBG2Y, changed, gfxBG2X, gfxBG2Y, changed,
line2); line2);
} }
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
u32 background = (READ16LE(&palette[0]) | 0x30000000); u32 background = (READ16LE(&palette[0]) | 0x30000000);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = background; u32 color = background;
u8 top = 0x20; u8 top = 0x20;
@ -67,12 +67,12 @@ void mode3RenderLine()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if(line2[x] < back) { if(line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -87,25 +87,25 @@ void mode3RenderLine()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }
void mode3RenderLineNoWindow() void mode3RenderLineNoWindow()
{ {
u16 *palette = (u16 *)paletteRAM; u16 *palette = (u16 *)paletteRAM;
if(DISPCNT & 0x80) { if(DISPCNT & 0x80) {
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
@ -114,18 +114,18 @@ void mode3RenderLineNoWindow()
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H, gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
BG2Y_L, BG2Y_H, BG2PA, BG2PB, BG2Y_L, BG2Y_H, BG2PA, BG2PB,
BG2PC, BG2PD, BG2PC, BG2PD,
gfxBG2X, gfxBG2Y, changed, gfxBG2X, gfxBG2Y, changed,
line2); line2);
} }
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
u32 background = (READ16LE(&palette[0]) | 0x30000000); u32 background = (READ16LE(&palette[0]) | 0x30000000);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = background; u32 color = background;
u8 top = 0x20; u8 top = 0x20;
@ -149,26 +149,26 @@ void mode3RenderLineNoWindow()
if(top & BLDMOD) { if(top & BLDMOD) {
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if(line2[x] < back) { if(line2[x] < back) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
coeff[(COLEV >> 8) & 0x1F]); coeff[(COLEV >> 8) & 0x1F]);
} }
} }
break; break;
@ -185,12 +185,12 @@ void mode3RenderLineNoWindow()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if(line2[x] < back) { if(line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -205,25 +205,25 @@ void mode3RenderLineNoWindow()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }
void mode3RenderLineAll() void mode3RenderLineAll()
{ {
u16 *palette = (u16 *)paletteRAM; u16 *palette = (u16 *)paletteRAM;
if(DISPCNT & 0x80) { if(DISPCNT & 0x80) {
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
@ -242,35 +242,35 @@ void mode3RenderLineAll()
if(layerEnable & 0x4000) { if(layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8; u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255; u8 v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if(v1 >= v0) if(v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
else else
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
} }
if(layerEnable & 0x0400) { if(layerEnable & 0x0400) {
int changed = gfxBG2Changed; int changed = gfxBG2Changed;
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H, gfxDrawRotScreen16Bit(BG2CNT, BG2X_L, BG2X_H,
BG2Y_L, BG2Y_H, BG2PA, BG2PB, BG2Y_L, BG2Y_H, BG2PA, BG2PB,
BG2PC, BG2PD, BG2PC, BG2PD,
gfxBG2X, gfxBG2Y, changed, gfxBG2X, gfxBG2Y, changed,
line2); line2);
} }
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
gfxDrawOBJWin(lineOBJWin); gfxDrawOBJWin(lineOBJWin);
u8 inWin0Mask = WININ & 0xFF; u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8; u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF; u8 outMask = WINOUT & 0xFF;
u32 background = (READ16LE(&palette[0]) | 0x30000000); u32 background = (READ16LE(&palette[0]) | 0x30000000);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = background; u32 color = background;
u8 top = 0x20; u8 top = 0x20;
@ -290,7 +290,7 @@ void mode3RenderLineAll()
mask = inWin0Mask; mask = inWin0Mask;
} }
} }
if((mask & 4) && (line2[x] < color)) { if((mask & 4) && (line2[x] < color)) {
color = line2[x]; color = line2[x];
top = 0x04; top = 0x04;
@ -311,26 +311,26 @@ void mode3RenderLineAll()
if(top & BLDMOD) { if(top & BLDMOD) {
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
coeff[(COLEV >> 8) & 0x1F]); coeff[(COLEV >> 8) & 0x1F]);
} }
} }
break; break;
@ -347,12 +347,12 @@ void mode3RenderLineAll()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -367,19 +367,19 @@ void mode3RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
} else if(color & 0x00010000) { } else if(color & 0x00010000) {
// semi-transparent OBJ // semi-transparent OBJ
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -394,12 +394,12 @@ void mode3RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }

View File

@ -28,7 +28,7 @@ void mode4RenderLine()
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
@ -37,7 +37,7 @@ void mode4RenderLine()
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
BG2PA, BG2PB, BG2PC, BG2PD, BG2PA, BG2PB, BG2PC, BG2PD,
gfxBG2X, gfxBG2Y, changed, gfxBG2X, gfxBG2Y, changed,
@ -47,7 +47,7 @@ void mode4RenderLine()
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = backdrop; u32 color = backdrop;
u8 top = 0x20; u8 top = 0x20;
@ -66,12 +66,12 @@ void mode4RenderLine()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if(line2[x] < back) { if(line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -86,14 +86,14 @@ void mode4RenderLine()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }
void mode4RenderLineNoWindow() void mode4RenderLineNoWindow()
@ -104,7 +104,7 @@ void mode4RenderLineNoWindow()
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
@ -113,7 +113,7 @@ void mode4RenderLineNoWindow()
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
BG2PA, BG2PB, BG2PC, BG2PD, BG2PA, BG2PB, BG2PC, BG2PD,
gfxBG2X, gfxBG2Y, changed, gfxBG2X, gfxBG2Y, changed,
@ -123,7 +123,7 @@ void mode4RenderLineNoWindow()
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = backdrop; u32 color = backdrop;
u8 top = 0x20; u8 top = 0x20;
@ -147,26 +147,26 @@ void mode4RenderLineNoWindow()
if(top & BLDMOD) { if(top & BLDMOD) {
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if(line2[x] < back) { if(line2[x] < back) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
coeff[(COLEV >> 8) & 0x1F]); coeff[(COLEV >> 8) & 0x1F]);
} }
} }
break; break;
@ -183,7 +183,7 @@ void mode4RenderLineNoWindow()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if(line2[x] < back) { if(line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
@ -203,14 +203,14 @@ void mode4RenderLineNoWindow()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }
void mode4RenderLineAll() void mode4RenderLineAll()
@ -221,7 +221,7 @@ void mode4RenderLineAll()
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
@ -240,19 +240,19 @@ void mode4RenderLineAll()
if(layerEnable & 0x4000) { if(layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8; u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255; u8 v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if(v1 >= v0) if(v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
else else
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
} }
if(layerEnable & 0x400) { if(layerEnable & 0x400) {
int changed = gfxBG2Changed; int changed = gfxBG2Changed;
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, gfxDrawRotScreen256(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
BG2PA, BG2PB, BG2PC, BG2PD, BG2PA, BG2PB, BG2PC, BG2PD,
gfxBG2X, gfxBG2Y, changed, gfxBG2X, gfxBG2Y, changed,
@ -260,18 +260,18 @@ void mode4RenderLineAll()
} }
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
gfxDrawOBJWin(lineOBJWin); gfxDrawOBJWin(lineOBJWin);
u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);
u8 inWin0Mask = WININ & 0xFF; u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8; u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF; u8 outMask = WINOUT & 0xFF;
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = backdrop; u32 color = backdrop;
u8 top = 0x20; u8 top = 0x20;
u8 mask = outMask; u8 mask = outMask;
if(!(lineOBJWin[x] & 0x80000000)) { if(!(lineOBJWin[x] & 0x80000000)) {
mask = WINOUT >> 8; mask = WINOUT >> 8;
@ -287,7 +287,7 @@ void mode4RenderLineAll()
mask = inWin0Mask; mask = inWin0Mask;
} }
} }
if((mask & 4) && (line2[x] < color)) { if((mask & 4) && (line2[x] < color)) {
color = line2[x]; color = line2[x];
top = 0x04; top = 0x04;
@ -308,26 +308,26 @@ void mode4RenderLineAll()
if(top & BLDMOD) { if(top & BLDMOD) {
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
coeff[(COLEV >> 8) & 0x1F]); coeff[(COLEV >> 8) & 0x1F]);
} }
} }
break; break;
@ -344,12 +344,12 @@ void mode4RenderLineAll()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -364,19 +364,19 @@ void mode4RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
} else if(color & 0x00010000) { } else if(color & 0x00010000) {
// semi-transparent OBJ // semi-transparent OBJ
u32 back = backdrop; u32 back = backdrop;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -391,12 +391,12 @@ void mode4RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }

View File

@ -26,7 +26,7 @@ void mode5RenderLine()
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
@ -37,7 +37,7 @@ void mode5RenderLine()
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H, gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
BG2Y_L, BG2Y_H, BG2PA, BG2PB, BG2Y_L, BG2Y_H, BG2PA, BG2PB,
BG2PC, BG2PD, BG2PC, BG2PD,
@ -48,7 +48,7 @@ void mode5RenderLine()
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
u32 background = (READ16LE(&palette[0]) | 0x30000000); u32 background = (READ16LE(&palette[0]) | 0x30000000);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = background; u32 color = background;
u8 top = 0x20; u8 top = 0x20;
@ -67,12 +67,12 @@ void mode5RenderLine()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if(line2[x] < back) { if(line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -87,14 +87,14 @@ void mode5RenderLine()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }
void mode5RenderLineNoWindow() void mode5RenderLineNoWindow()
@ -103,7 +103,7 @@ void mode5RenderLineNoWindow()
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
@ -114,7 +114,7 @@ void mode5RenderLineNoWindow()
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H, gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
BG2Y_L, BG2Y_H, BG2PA, BG2PB, BG2Y_L, BG2Y_H, BG2PA, BG2PB,
BG2PC, BG2PD, BG2PC, BG2PD,
@ -125,7 +125,7 @@ void mode5RenderLineNoWindow()
gfxDrawSprites(lineOBJ); gfxDrawSprites(lineOBJ);
u32 background = ( READ16LE(&palette[0]) | 0x30000000); u32 background = ( READ16LE(&palette[0]) | 0x30000000);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = background; u32 color = background;
u8 top = 0x20; u8 top = 0x20;
@ -149,26 +149,26 @@ void mode5RenderLineNoWindow()
if(top & BLDMOD) { if(top & BLDMOD) {
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if(line2[x] < back) { if(line2[x] < back) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
coeff[(COLEV >> 8) & 0x1F]); coeff[(COLEV >> 8) & 0x1F]);
} }
} }
break; break;
@ -185,12 +185,12 @@ void mode5RenderLineNoWindow()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if(line2[x] < back) { if(line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -205,14 +205,14 @@ void mode5RenderLineNoWindow()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }
void mode5RenderLineAll() void mode5RenderLineAll()
@ -221,7 +221,7 @@ void mode5RenderLineAll()
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
lineMix[x] = 0x7fff; lineMix[x] = 0x7fff;
} }
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
return; return;
} }
@ -232,7 +232,7 @@ void mode5RenderLineAll()
if(gfxLastVCOUNT > VCOUNT) if(gfxLastVCOUNT > VCOUNT)
changed = 3; changed = 3;
gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H, gfxDrawRotScreen16Bit160(BG2CNT, BG2X_L, BG2X_H,
BG2Y_L, BG2Y_H, BG2PA, BG2PB, BG2Y_L, BG2Y_H, BG2PA, BG2PB,
BG2PC, BG2PD, BG2PC, BG2PD,
@ -258,19 +258,19 @@ void mode5RenderLineAll()
if(layerEnable & 0x4000) { if(layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8; u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255; u8 v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8)); inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if(v1 >= v0) if(v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
else else
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1); inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
} }
u8 inWin0Mask = WININ & 0xFF; u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8; u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF; u8 outMask = WINOUT & 0xFF;
u32 background = (READ16LE(&palette[0]) | 0x30000000); u32 background = (READ16LE(&palette[0]) | 0x30000000);
for(int x = 0; x < 240; x++) { for(int x = 0; x < 240; x++) {
u32 color = background; u32 color = background;
u8 top = 0x20; u8 top = 0x20;
@ -311,26 +311,26 @@ void mode5RenderLineAll()
if(top & BLDMOD) { if(top & BLDMOD) {
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
if(top != 0x04) { if(top != 0x04) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
} }
if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) { if((mask & 16) && (u8)(lineOBJ[x]>>24) < (u8)(back >> 24)) {
if(top != 0x10) { if(top != 0x10) {
back = lineOBJ[x]; back = lineOBJ[x];
top2 = 0x10; top2 = 0x10;
} }
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
coeff[(COLEV >> 8) & 0x1F]); coeff[(COLEV >> 8) & 0x1F]);
} }
} }
break; break;
@ -347,12 +347,12 @@ void mode5RenderLineAll()
// semi-transparent OBJ // semi-transparent OBJ
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -367,19 +367,19 @@ void mode5RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
} else if(color & 0x00010000) { } else if(color & 0x00010000) {
// semi-transparent OBJ // semi-transparent OBJ
u32 back = background; u32 back = background;
u8 top2 = 0x20; u8 top2 = 0x20;
if((mask & 4) && line2[x] < back) { if((mask & 4) && line2[x] < back) {
back = line2[x]; back = line2[x];
top2 = 0x04; top2 = 0x04;
} }
if(top2 & (BLDMOD>>8)) if(top2 & (BLDMOD>>8))
color = gfxAlphaBlend(color, back, color = gfxAlphaBlend(color, back,
coeff[COLEV & 0x1F], coeff[COLEV & 0x1F],
@ -394,12 +394,12 @@ void mode5RenderLineAll()
if(BLDMOD & top) if(BLDMOD & top)
color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]); color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
break; break;
} }
} }
} }
lineMix[x] = color; lineMix[x] = color;
} }
gfxBG2Changed = 0; gfxBG2Changed = 0;
gfxLastVCOUNT = VCOUNT; gfxLastVCOUNT = VCOUNT;
} }

View File

@ -47,10 +47,10 @@ static inline u32 swap32(u32 v)
#define WRITE16LE(base, value) \ #define WRITE16LE(base, value) \
__asm__ ("sthbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory") __asm__ ("sthbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory")
#define WRITE32LE(base, value) \ #define WRITE32LE(base, value) \
__asm__ ("stwbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory") __asm__ ("stwbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory")
#else #else
#define READ16LE(x) \ #define READ16LE(x) \
swap16(*((u16 *)(x))) swap16(*((u16 *)(x)))

View File

@ -67,7 +67,7 @@ u16 rtcRead(u32 address)
return rtcClockData.byte0; return rtcClockData.byte0;
} }
} }
return READ16LE((&rom[address & 0x1FFFFFE])); return READ16LE((&rom[address & 0x1FFFFFE]));
} }
@ -83,7 +83,7 @@ bool rtcWrite(u32 address, u16 value)
{ {
if(!rtcEnabled) if(!rtcEnabled)
return false; return false;
if(address == 0x80000c8) { if(address == 0x80000c8) {
rtcClockData.byte2 = (u8)value; // enable ? rtcClockData.byte2 = (u8)value; // enable ?
} else if(address == 0x80000c6) { } else if(address == 0x80000c6) {
@ -95,7 +95,7 @@ bool rtcWrite(u32 address, u16 value)
rtcClockData.bits = 0; rtcClockData.bits = 0;
rtcClockData.command = 0; rtcClockData.command = 0;
} else if(!(rtcClockData.byte0 & 1) && (value & 1)) { // bit transfer } else if(!(rtcClockData.byte0 & 1) && (value & 1)) { // bit transfer
rtcClockData.byte0 = (u8)value; rtcClockData.byte0 = (u8)value;
switch(rtcClockData.state) { switch(rtcClockData.state) {
case COMMAND: case COMMAND:
rtcClockData.command |= ((value & 2) >> 1) << (7-rtcClockData.bits); 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. */ time( &long_time ); /* Get time as long integer. */
newtime = localtime( &long_time ); /* Convert to local time. */ newtime = localtime( &long_time ); /* Convert to local time. */
rtcClockData.dataLen = 7; rtcClockData.dataLen = 7;
rtcClockData.data[0] = toBCD(newtime->tm_year); rtcClockData.data[0] = toBCD(newtime->tm_year);
rtcClockData.data[1] = toBCD(newtime->tm_mon+1); 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.data[6] = toBCD(newtime->tm_sec);
rtcClockData.state = DATA; rtcClockData.state = DATA;
} }
break; break;
case 0x67: case 0x67:
{ {
struct tm *newtime; struct tm *newtime;
@ -147,7 +147,7 @@ bool rtcWrite(u32 address, u16 value)
time( &long_time ); /* Get time as long integer. */ time( &long_time ); /* Get time as long integer. */
newtime = localtime( &long_time ); /* Convert to local time. */ newtime = localtime( &long_time ); /* Convert to local time. */
rtcClockData.dataLen = 3; rtcClockData.dataLen = 3;
rtcClockData.data[0] = toBCD(newtime->tm_hour); rtcClockData.data[0] = toBCD(newtime->tm_hour);
rtcClockData.data[1] = toBCD(newtime->tm_min); rtcClockData.data[1] = toBCD(newtime->tm_min);
@ -201,7 +201,7 @@ bool rtcWrite(u32 address, u16 value)
void rtcReset() void rtcReset()
{ {
memset(&rtcClockData, 0, sizeof(rtcClockData)); memset(&rtcClockData, 0, sizeof(rtcClockData));
rtcClockData.byte0 = 0; rtcClockData.byte0 = 0;
rtcClockData.byte1 = 0; rtcClockData.byte1 = 0;
rtcClockData.byte2 = 0; rtcClockData.byte2 = 0;

File diff suppressed because it is too large Load Diff

View File

@ -1,90 +1,90 @@
// -*- C++ -*- // -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team // Copyright (C) 2004 Forgotten and the VBA development team
// Copyright (C) 2004-2006 VBA development team // Copyright (C) 2004-2006 VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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 // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef VBA_SOUND_H #ifndef VBA_SOUND_H
#define VBA_SOUND_H #define VBA_SOUND_H
#include "System.h" #include "System.h"
#define NR10 0x60 #define NR10 0x60
#define NR11 0x62 #define NR11 0x62
#define NR12 0x63 #define NR12 0x63
#define NR13 0x64 #define NR13 0x64
#define NR14 0x65 #define NR14 0x65
#define NR21 0x68 #define NR21 0x68
#define NR22 0x69 #define NR22 0x69
#define NR23 0x6c #define NR23 0x6c
#define NR24 0x6d #define NR24 0x6d
#define NR30 0x70 #define NR30 0x70
#define NR31 0x72 #define NR31 0x72
#define NR32 0x73 #define NR32 0x73
#define NR33 0x74 #define NR33 0x74
#define NR34 0x75 #define NR34 0x75
#define NR41 0x78 #define NR41 0x78
#define NR42 0x79 #define NR42 0x79
#define NR43 0x7c #define NR43 0x7c
#define NR44 0x7d #define NR44 0x7d
#define NR50 0x80 #define NR50 0x80
#define NR51 0x81 #define NR51 0x81
#define NR52 0x84 #define NR52 0x84
#define SGCNT0_H 0x82 #define SGCNT0_H 0x82
#define FIFOA_L 0xa0 #define FIFOA_L 0xa0
#define FIFOA_H 0xa2 #define FIFOA_H 0xa2
#define FIFOB_L 0xa4 #define FIFOB_L 0xa4
#define FIFOB_H 0xa6 #define FIFOB_H 0xa6
extern void setSoundFn(); extern void setSoundFn();
extern void (*psoundTickfn)(); extern void (*psoundTickfn)();
extern void soundShutdown(); extern void soundShutdown();
extern bool soundInit(); extern bool soundInit();
extern void soundPause(); extern void soundPause();
extern void soundResume(); extern void soundResume();
extern void soundEnable(int); extern void soundEnable(int);
extern void soundDisable(int); extern void soundDisable(int);
extern int soundGetEnable(); extern int soundGetEnable();
extern void soundReset(); extern void soundReset();
extern void soundSaveGame(gzFile); extern void soundSaveGame(gzFile);
extern void soundReadGame(gzFile, int); extern void soundReadGame(gzFile, int);
extern void soundEvent(u32, u8); extern void soundEvent(u32, u8);
extern void soundEvent(u32, u16); extern void soundEvent(u32, u16);
extern void soundTimerOverflow(int); extern void soundTimerOverflow(int);
extern void soundSetQuality(int); extern void soundSetQuality(int);
extern void setsystemSoundOn(bool value); extern void setsystemSoundOn(bool value);
extern void setsoundPaused(bool value); extern void setsoundPaused(bool value);
extern void setsoundMasterOn(bool value); extern void setsoundMasterOn(bool value);
extern void interp_rate(); extern void interp_rate();
extern int SOUND_CLOCK_TICKS; extern int SOUND_CLOCK_TICKS;
extern int soundTicks; extern int soundTicks;
extern bool soundOffFlag; extern bool soundOffFlag;
extern bool soundPaused; extern bool soundPaused;
extern int soundQuality; extern int soundQuality;
extern int soundBufferLen; extern int soundBufferLen;
extern int soundBufferTotalLen; extern int soundBufferTotalLen;
extern u32 soundNextPosition; extern u32 soundNextPosition;
extern u16 soundFinalWave[1470]; extern u16 soundFinalWave[1470];
extern int soundVolume; extern int soundVolume;
extern int soundInterpolation; extern int soundInterpolation;
extern bool soundEcho; extern bool soundEcho;
extern bool soundLowPass; extern bool soundLowPass;
extern bool soundReverse; extern bool soundReverse;
#endif // VBA_SOUND_H #endif // VBA_SOUND_H

View File

@ -58,7 +58,7 @@ struct EmulatedSystem {
// write battery file // write battery file
bool (*emuWriteBattery)(const char *); bool (*emuWriteBattery)(const char *);
// load state // load state
bool (*emuReadState)(const char *); bool (*emuReadState)(const char *);
// save state // save state
bool (*emuWriteState)(const char *); bool (*emuWriteState)(const char *);
// load memory state (rewind) // load memory state (rewind)

View File

@ -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 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) const char *string, bool trans)
{ {
screen += y*pitch; screen += y*pitch;
@ -56,14 +56,14 @@ static void drawTextInternal(u8 *screen, int pitch, int x, int y,
while(*string) { while(*string) {
char c = *string++; char c = *string++;
u8 *scr = screen; u8 *scr = screen;
u16 mask = ~RGB_LOW_BITS_MASK; u16 mask = ~RGB_LOW_BITS_MASK;
int h, w; int h, w;
u16 *s = (u16 *)scr; u16 *s = (u16 *)scr;
for (h = 0; h < 8; h++) { for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s++) { for (w = 0; w < 8; w++, s++) {
int on = (fontdata2[(c<<3)+h]>>w)&1; int on = (fontdata2[(c<<3)+h]>>w)&1;
if(trans) { if(trans) {
if(on) if(on)
*s = ((0xf) << systemRedShift) + *s = ((0xf) << systemRedShift) +
@ -85,13 +85,13 @@ static void drawTextInternal(u8 *screen, int pitch, int x, int y,
while(*string) { while(*string) {
char c = *string++; char c = *string++;
u8 *scr = screen; u8 *scr = screen;
int h, w; int h, w;
u8 *s = (u8 *)scr; u8 *s = (u8 *)scr;
for (h = 0; h < 8; h++) { for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s+=3) { for (w = 0; w < 8; w++, s+=3) {
int on = (fontdata2[(c<<3)+h]>>w)&1; int on = (fontdata2[(c<<3)+h]>>w)&1;
if(trans) { if(trans) {
if(on) { if(on) {
u32 color = (0x1f) << systemRedShift; u32 color = (0x1f) << systemRedShift;
@ -114,20 +114,20 @@ static void drawTextInternal(u8 *screen, int pitch, int x, int y,
screen += inc*8; screen += inc*8;
} }
} }
break; break;
case 32: case 32:
{ {
while(*string) { while(*string) {
char c = *string++; char c = *string++;
u8 *scr = screen; u8 *scr = screen;
int h, w; int h, w;
u32 mask = 0xfefefe; u32 mask = 0xfefefe;
u32 *s = (u32 *)scr; u32 *s = (u32 *)scr;
for (h = 0; h < 8; h++) { for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s++) { for (w = 0; w < 8; w++, s++) {
int on = (fontdata2[(c<<3)+h]>>w)&1; int on = (fontdata2[(c<<3)+h]>>w)&1;
if(trans) { if(trans) {
if(on) if(on)
*s = ((0xf) << systemRedShift) + ((*s & mask)>>1); *s = ((0xf) << systemRedShift) + ((*s & mask)>>1);
@ -142,7 +142,7 @@ static void drawTextInternal(u8 *screen, int pitch, int x, int y,
screen += inc*8; screen += inc*8;
} }
} }
break; break;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -63,14 +63,14 @@ static void internal_scale2x_16_def(u16 *dst, const u16* src0, const u16* src1,
dst[0] = src1[0]; dst[0] = src1[0];
dst[1] = src1[0]; dst[1] = src1[0];
} }
++src0; ++src0;
++src1; ++src1;
++src2; ++src2;
dst += 2; dst += 2;
--count; --count;
} }
/* last pixel */ /* last pixel */
if (src1[-1] == src0[0] && src2[0] != src0[0]) if (src1[-1] == src0[0] && src2[0] != src0[0])
dst[0] = src0[0]; dst[0] = src0[0];
@ -83,7 +83,7 @@ static void internal_scale2x_32_def(u32* dst,
const u32* src0, const u32* src0,
const u32* src1, const u32* src1,
const u32* src2, const u32* src2,
unsigned count) unsigned count)
{ {
/* first pixel */ /* first pixel */
dst[0] = src1[0]; dst[0] = src1[0];
@ -95,7 +95,7 @@ static void internal_scale2x_32_def(u32* dst,
++src1; ++src1;
++src2; ++src2;
dst += 2; dst += 2;
/* central pixels */ /* central pixels */
count -= 2; count -= 2;
while (count) { while (count) {
@ -106,14 +106,14 @@ static void internal_scale2x_32_def(u32* dst,
dst[0] = src1[0]; dst[0] = src1[0];
dst[1] = src1[0]; dst[1] = src1[0];
} }
++src0; ++src0;
++src1; ++src1;
++src2; ++src2;
dst += 2; dst += 2;
--count; --count;
} }
/* last pixel */ /* last pixel */
if (src1[-1] == src0[0] && src2[0] != src0[0]) if (src1[-1] == src0[0] && src2[0] != src0[0])
dst[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 */ /* always do the first and last run */
count -= 2*4; count -= 2*4;
#ifdef __GNUC__ #ifdef __GNUC__
__asm__ __volatile__( __asm__ __volatile__(
/* first run */ /* first run */
/* set the current, current_pre, current_next registers */ /* 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 ecx, src2;
mov edx, dst; mov edx, dst;
mov esi, count; mov esi, count;
/* first run */ /* first run */
/* set the current, current_pre, current_next registers */ /* set the current, current_pre, current_next registers */
movq mm0, qword ptr [ebx]; 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 ebx,8;
add ecx,8; add ecx,8;
add edx,16; add edx,16;
dec esi; dec esi;
jnz label0; jnz label0;
label1: label1:
@ -699,7 +699,7 @@ static void internal_scale2x_32_mmx_single(u32* dst, const u32* src0, const u32*
mov ecx, src2; mov ecx, src2;
mov edx, dst; mov edx, dst;
mov esi, count; mov esi, count;
/* first run */ /* first run */
/* set the current, current_pre, current_next registers */ /* set the current, current_pre, current_next registers */
movq mm0,qword ptr [ebx]; 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; shr esi,1;
jz label1; jz label1;
label0: label0:
/* set the current, current_pre, current_next registers */ /* set the current, current_pre, current_next registers */
movq mm0,qword ptr [ebx-8]; movq mm0,qword ptr [ebx-8];
movq mm7,qword ptr [ebx]; movq mm7,qword ptr [ebx];
@ -822,7 +822,7 @@ label0:
dec esi; dec esi;
jnz label0; jnz label0;
label1: label1:
/* final run */ /* final run */
/* set the current, current_pre, current_next registers */ /* set the current, current_pre, current_next registers */
movq mm1,qword ptr [ebx]; movq mm1,qword ptr [ebx];
@ -904,14 +904,14 @@ void AdMame2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
{ {
u16 *dst0 = (u16 *)dstPtr; u16 *dst0 = (u16 *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1); u16 *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr; u16 *src0 = (u16 *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1); u16 *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1); u16 *src2 = src1 + (srcPitch >> 1);
#ifdef MMX #ifdef MMX
if(cpu_mmx) { if(cpu_mmx) {
internal_scale2x_16_mmx(dst0, dst1, src0, src0, src1, width); internal_scale2x_16_mmx(dst0, dst1, src0, src0, src1, width);
int count = height; int count = height;
count -= 2; count -= 2;
@ -931,7 +931,7 @@ void AdMame2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
#endif #endif
internal_scale2x_16_def(dst0, src0, src0, src1, width); internal_scale2x_16_def(dst0, src0, src0, src1, width);
internal_scale2x_16_def(dst1, src1, src0, src0, width); internal_scale2x_16_def(dst1, src1, src0, src0, width);
int count = height; int count = height;
count -= 2; count -= 2;
@ -959,14 +959,14 @@ void AdMame2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
{ {
u32 *dst0 = (u32 *)dstPtr; u32 *dst0 = (u32 *)dstPtr;
u32 *dst1 = dst0 + (dstPitch >> 2); u32 *dst1 = dst0 + (dstPitch >> 2);
u32 *src0 = (u32 *)srcPtr; u32 *src0 = (u32 *)srcPtr;
u32 *src1 = src0 + (srcPitch >> 2); u32 *src1 = src0 + (srcPitch >> 2);
u32 *src2 = src1 + (srcPitch >> 2); u32 *src2 = src1 + (srcPitch >> 2);
#ifdef MMX #ifdef MMX
if(cpu_mmx) { if(cpu_mmx) {
internal_scale2x_32_mmx(dst0, dst1, src0, src0, src1, width); internal_scale2x_32_mmx(dst0, dst1, src0, src0, src1, width);
int count = height; int count = height;
count -= 2; count -= 2;
@ -986,7 +986,7 @@ void AdMame2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
#endif #endif
internal_scale2x_32_def(dst0, src0, src0, src1, width); internal_scale2x_32_def(dst0, src0, src0, src1, width);
internal_scale2x_32_def(dst1, src1, src0, src0, width); internal_scale2x_32_def(dst1, src1, src0, src0, width);
int count = height; int count = height;
count -= 2; count -= 2;

View File

@ -68,7 +68,7 @@ bool agbPrintIsEnabled()
} }
extern void (*dbgOutput)(const char *, u32); extern void (*dbgOutput)(const char *, u32);
void agbPrintFlush() void agbPrintFlush()
{ {
u16 get = debuggerReadHalfWord(0x9fe20fc); u16 get = debuggerReadHalfWord(0x9fe20fc);
@ -78,7 +78,7 @@ void agbPrintFlush()
if(address != 0xfd0000 && address != 0x1fd0000) { if(address != 0xfd0000 && address != 0x1fd0000) {
dbgOutput("Did you forget to call AGBPrintInit?\n", 0); dbgOutput("Did you forget to call AGBPrintInit?\n", 0);
// get rid of the text otherwise we will continue to be called // get rid of the text otherwise we will continue to be called
debuggerWriteHalfWord(0x9fe20fc, put); debuggerWriteHalfWord(0x9fe20fc, put);
return; return;
} }

View File

@ -442,7 +442,7 @@
C_FLAG = (Flags >> 25) & 1; \ C_FLAG = (Flags >> 25) & 1; \
V_FLAG = (Flags >> 26) & 1; \ V_FLAG = (Flags >> 26) & 1; \
} }
#define LOGICAL_LSL_REG \ #define LOGICAL_LSL_REG \
{\ {\
u32 v = reg[opcode & 0x0f].I;\ u32 v = reg[opcode & 0x0f].I;\
@ -666,14 +666,14 @@
asm("ror %%cl, %%eax;"\ asm("ror %%cl, %%eax;"\
"setcb %%cl;"\ "setcb %%cl;"\
: "=a" (value), "=c" (C_OUT)\ : "=a" (value), "=c" (C_OUT)\
: "a" (reg[opcode & 0x0f].I), "c" (shift)); : "a" (reg[opcode & 0x0f].I), "c" (shift));
#define LOGICAL_RRX_REG \ #define LOGICAL_RRX_REG \
asm("bt $0, C_FLAG;"\ asm("bt $0, C_FLAG;"\
"rcr $1, %%eax;"\ "rcr $1, %%eax;"\
"setcb %%cl;"\ "setcb %%cl;"\
: "=a" (value), "=c" (C_OUT)\ : "=a" (value), "=c" (C_OUT)\
: "a" (reg[opcode & 0x0f].I)); : "a" (reg[opcode & 0x0f].I));
#define LOGICAL_ROR_IMM \ #define LOGICAL_ROR_IMM \
asm("ror %%cl, %%eax;"\ asm("ror %%cl, %%eax;"\
@ -702,14 +702,14 @@
asm("\ asm("\
ror %%cl, %%eax;"\ ror %%cl, %%eax;"\
: "=a" (value)\ : "=a" (value)\
: "a" (reg[opcode & 0x0f].I), "c" (shift)); : "a" (reg[opcode & 0x0f].I), "c" (shift));
#define ARITHMETIC_RRX_REG \ #define ARITHMETIC_RRX_REG \
asm("\ asm("\
bt $0, C_FLAG;\ bt $0, C_FLAG;\
rcr $1, %%eax;"\ rcr $1, %%eax;"\
: "=a" (value)\ : "=a" (value)\
: "a" (reg[opcode & 0x0f].I)); : "a" (reg[opcode & 0x0f].I));
#define ARITHMETIC_ROR_IMM \ #define ARITHMETIC_ROR_IMM \
asm("\ asm("\
@ -2410,13 +2410,13 @@
if(cond == 0x0e) { if(cond == 0x0e) {
cond_res = true; cond_res = true;
} else { } else {
switch(cond) { switch(cond) {
case 0x00: // EQ case 0x00: // EQ
cond_res = Z_FLAG; cond_res = Z_FLAG;
break; break;
case 0x01: // NE case 0x01: // NE
cond_res = !Z_FLAG; cond_res = !Z_FLAG;
break; break;
case 0x02: // CS case 0x02: // CS
cond_res = C_FLAG; cond_res = C_FLAG;
break; break;
@ -2449,12 +2449,12 @@
break; break;
case 0x0C: // GT case 0x0C: // GT
cond_res = !Z_FLAG &&(N_FLAG == V_FLAG); cond_res = !Z_FLAG &&(N_FLAG == V_FLAG);
break; break;
case 0x0D: // LE case 0x0D: // LE
cond_res = Z_FLAG || (N_FLAG != V_FLAG); cond_res = Z_FLAG || (N_FLAG != V_FLAG);
break; break;
case 0x0E: case 0x0E:
cond_res = true; cond_res = true;
break; break;
case 0x0F: case 0x0F:
default: default:
@ -2463,7 +2463,7 @@
break; break;
} }
} }
if(cond_res) { if(cond_res) {
switch(((opcode>>16)&0xFF0) | ((opcode>>4)&0x0F)) { switch(((opcode>>16)&0xFF0) | ((opcode>>4)&0x0F)) {
LOGICAL_DATA_OPCODE_WITHOUT_base(OP_AND, OP_AND, 0x000); LOGICAL_DATA_OPCODE_WITHOUT_base(OP_AND, OP_AND, 0x000);
@ -2473,7 +2473,7 @@ if(cond_res) {
// MUL Rd, Rm, Rs // MUL Rd, Rm, Rs
int dest = (opcode >> 16) & 0x0F; int dest = (opcode >> 16) & 0x0F;
int mult = (opcode & 0x0F); int mult = (opcode & 0x0F);
clockTicks = 1; clockTicks = 1;
u32 rs = reg[(opcode >> 8) & 0x0F].I; u32 rs = reg[(opcode >> 8) & 0x0F].I;
reg[dest].I = reg[mult].I * rs; reg[dest].I = reg[mult].I * rs;
if(((s32)rs)<0) if(((s32)rs)<0)
@ -3605,7 +3605,7 @@ if(cond_res) {
clockTicks = 2; clockTicks = 2;
u32 umult = reg[(opcode & 0x0F)].I; u32 umult = reg[(opcode & 0x0F)].I;
u32 usource = reg[(opcode >> 8) & 0x0F].I; u32 usource = reg[(opcode >> 8) & 0x0F].I;
int destLo = (opcode >> 12) & 0x0F; int destLo = (opcode >> 12) & 0x0F;
int destHi = (opcode >> 16) & 0x0F; int destHi = (opcode >> 16) & 0x0F;
u64 uTemp = ((u64)umult)*((u64)usource); u64 uTemp = ((u64)umult)*((u64)usource);
reg[destLo].I = (u32)uTemp; reg[destLo].I = (u32)uTemp;
@ -3629,7 +3629,7 @@ if(cond_res) {
clockTicks = 2; clockTicks = 2;
u32 umult = reg[(opcode & 0x0F)].I; u32 umult = reg[(opcode & 0x0F)].I;
u32 usource = reg[(opcode >> 8) & 0x0F].I; u32 usource = reg[(opcode >> 8) & 0x0F].I;
int destLo = (opcode >> 12) & 0x0F; int destLo = (opcode >> 12) & 0x0F;
int destHi = (opcode >> 16) & 0x0F; int destHi = (opcode >> 16) & 0x0F;
u64 uTemp = ((u64)umult)*((u64)usource); u64 uTemp = ((u64)umult)*((u64)usource);
reg[destLo].I = (u32)uTemp; reg[destLo].I = (u32)uTemp;
@ -3657,7 +3657,7 @@ if(cond_res) {
clockTicks = 3; clockTicks = 3;
u32 umult = reg[(opcode & 0x0F)].I; u32 umult = reg[(opcode & 0x0F)].I;
u32 usource = reg[(opcode >> 8) & 0x0F].I; u32 usource = reg[(opcode >> 8) & 0x0F].I;
int destLo = (opcode >> 12) & 0x0F; int destLo = (opcode >> 12) & 0x0F;
int destHi = (opcode >> 16) & 0x0F; int destHi = (opcode >> 16) & 0x0F;
u64 uTemp = (u64)reg[destHi].I; u64 uTemp = (u64)reg[destHi].I;
uTemp <<= 32; uTemp <<= 32;
@ -3684,7 +3684,7 @@ if(cond_res) {
clockTicks = 3; clockTicks = 3;
u32 umult = reg[(opcode & 0x0F)].I; u32 umult = reg[(opcode & 0x0F)].I;
u32 usource = reg[(opcode >> 8) & 0x0F].I; u32 usource = reg[(opcode >> 8) & 0x0F].I;
int destLo = (opcode >> 12) & 0x0F; int destLo = (opcode >> 12) & 0x0F;
int destHi = (opcode >> 16) & 0x0F; int destHi = (opcode >> 16) & 0x0F;
u64 uTemp = (u64)reg[destHi].I; u64 uTemp = (u64)reg[destHi].I;
uTemp <<= 32; uTemp <<= 32;
@ -3713,7 +3713,7 @@ if(cond_res) {
{ {
// SMULL RdLo, RdHi, Rm, Rs // SMULL RdLo, RdHi, Rm, Rs
clockTicks = 2; clockTicks = 2;
int destLo = (opcode >> 12) & 0x0F; int destLo = (opcode >> 12) & 0x0F;
int destHi = (opcode >> 16) & 0x0F; int destHi = (opcode >> 16) & 0x0F;
u32 rs = reg[(opcode >> 8) & 0x0F].I; u32 rs = reg[(opcode >> 8) & 0x0F].I;
s64 m = (s32)reg[(opcode & 0x0F)].I; s64 m = (s32)reg[(opcode & 0x0F)].I;
@ -3740,7 +3740,7 @@ if(cond_res) {
{ {
// SMULLS RdLo, RdHi, Rm, Rs // SMULLS RdLo, RdHi, Rm, Rs
clockTicks = 2; clockTicks = 2;
int destLo = (opcode >> 12) & 0x0F; int destLo = (opcode >> 12) & 0x0F;
int destHi = (opcode >> 16) & 0x0F; int destHi = (opcode >> 16) & 0x0F;
u32 rs = reg[(opcode >> 8) & 0x0F].I; u32 rs = reg[(opcode >> 8) & 0x0F].I;
s64 m = (s32)reg[(opcode & 0x0F)].I; s64 m = (s32)reg[(opcode & 0x0F)].I;
@ -3771,7 +3771,7 @@ if(cond_res) {
{ {
// SMLAL RdLo, RdHi, Rm, Rs // SMLAL RdLo, RdHi, Rm, Rs
clockTicks = codeTicksAccess32(armNextPC) + 4; clockTicks = codeTicksAccess32(armNextPC) + 4;
int destLo = (opcode >> 12) & 0x0F; int destLo = (opcode >> 12) & 0x0F;
int destHi = (opcode >> 16) & 0x0F; int destHi = (opcode >> 16) & 0x0F;
u32 rs = reg[(opcode >> 8) & 0x0F].I; u32 rs = reg[(opcode >> 8) & 0x0F].I;
s64 m = (s32)reg[(opcode & 0x0F)].I; s64 m = (s32)reg[(opcode & 0x0F)].I;
@ -3800,7 +3800,7 @@ if(cond_res) {
{ {
// SMLALS RdLo, RdHi, Rm, Rs // SMLALS RdLo, RdHi, Rm, Rs
clockTicks = codeTicksAccess32(armNextPC) + 4; clockTicks = codeTicksAccess32(armNextPC) + 4;
int destLo = (opcode >> 12) & 0x0F; int destLo = (opcode >> 12) & 0x0F;
int destHi = (opcode >> 16) & 0x0F; int destHi = (opcode >> 16) & 0x0F;
u32 rs = reg[(opcode >> 8) & 0x0F].I; u32 rs = reg[(opcode >> 8) & 0x0F].I;
s64 m = (s32)reg[(opcode & 0x0F)].I; s64 m = (s32)reg[(opcode & 0x0F)].I;
@ -4030,7 +4030,7 @@ if(cond_res) {
} }
break; break;
CASE_16(0x400) CASE_16(0x400)
// T versions shouldn't be different on GBA // T versions shouldn't be different on GBA
CASE_16(0x420) CASE_16(0x420)
{ {
// STR Rd, [Rn], -# // STR Rd, [Rn], -#
@ -4310,7 +4310,7 @@ if(cond_res) {
} }
break; break;
CASE_16(0x440) CASE_16(0x440)
// T versions shouldn't be different on GBA // T versions shouldn't be different on GBA
CASE_16(0x460) CASE_16(0x460)
{ {
// STRB Rd, [Rn], -# // STRB Rd, [Rn], -#
@ -4825,7 +4825,7 @@ if(cond_res) {
int dest = (opcode >> 12) & 15; int dest = (opcode >> 12) & 15;
int base = (opcode >> 16) & 15; int base = (opcode >> 16) & 15;
u32 address = reg[base].I - offset; u32 address = reg[base].I - offset;
reg[base].I = address; reg[base].I = address;
CPUWriteMemory(address, reg[dest].I); CPUWriteMemory(address, reg[dest].I);
clockTicks = 2 + dataTicksAccess32(address) + clockTicks = 2 + dataTicksAccess32(address) +
codeTicksAccess32(armNextPC); codeTicksAccess32(armNextPC);
@ -4870,7 +4870,7 @@ if(cond_res) {
int dest = (opcode >> 12) & 15; int dest = (opcode >> 12) & 15;
int base = (opcode >> 16) & 15; int base = (opcode >> 16) & 15;
u32 address = reg[base].I - value; u32 address = reg[base].I - value;
reg[base].I = address; reg[base].I = address;
CPUWriteMemory(address, reg[dest].I); CPUWriteMemory(address, reg[dest].I);
clockTicks = 2 + dataTicksAccess32(address) + clockTicks = 2 + dataTicksAccess32(address) +
codeTicksAccess32(armNextPC); codeTicksAccess32(armNextPC);
@ -4977,7 +4977,7 @@ if(cond_res) {
int dest = (opcode >> 12) & 15; int dest = (opcode >> 12) & 15;
int base = (opcode >> 16) & 15; int base = (opcode >> 16) & 15;
u32 address = reg[base].I + offset; u32 address = reg[base].I + offset;
reg[base].I = address; reg[base].I = address;
CPUWriteMemory(address, reg[dest].I); CPUWriteMemory(address, reg[dest].I);
clockTicks = 2 + dataTicksAccess32(address) + clockTicks = 2 + dataTicksAccess32(address) +
codeTicksAccess32(armNextPC); codeTicksAccess32(armNextPC);
@ -5022,7 +5022,7 @@ if(cond_res) {
int dest = (opcode >> 12) & 15; int dest = (opcode >> 12) & 15;
int base = (opcode >> 16) & 15; int base = (opcode >> 16) & 15;
u32 address = reg[base].I + value; u32 address = reg[base].I + value;
reg[base].I = address; reg[base].I = address;
CPUWriteMemory(address, reg[dest].I); CPUWriteMemory(address, reg[dest].I);
clockTicks = 2 + dataTicksAccess32(address) + clockTicks = 2 + dataTicksAccess32(address) +
codeTicksAccess32(armNextPC); codeTicksAccess32(armNextPC);
@ -5424,7 +5424,7 @@ if(cond_res) {
u32 address = reg[base].I - offset; u32 address = reg[base].I - offset;
reg[dest].I = CPUReadMemory(address); reg[dest].I = CPUReadMemory(address);
if(dest != base) if(dest != base)
reg[base].I = address; reg[base].I = address;
clockTicks = 0; clockTicks = 0;
if(dest == 15) { if(dest == 15) {
reg[15].I &= 0xFFFFFFFC; reg[15].I &= 0xFFFFFFFC;
@ -5487,7 +5487,7 @@ if(cond_res) {
u32 address = reg[base].I - value; u32 address = reg[base].I - value;
reg[dest].I = CPUReadMemory(address); reg[dest].I = CPUReadMemory(address);
if(dest != base) if(dest != base)
reg[base].I = address; reg[base].I = address;
clockTicks = 0; clockTicks = 0;
if(dest == 15) { if(dest == 15) {
reg[15].I &= 0xFFFFFFFC; reg[15].I &= 0xFFFFFFFC;
@ -5644,7 +5644,7 @@ if(cond_res) {
u32 address = reg[base].I + offset; u32 address = reg[base].I + offset;
reg[dest].I = CPUReadMemory(address); reg[dest].I = CPUReadMemory(address);
if(dest != base) if(dest != base)
reg[base].I = address; reg[base].I = address;
clockTicks = 0; clockTicks = 0;
if(dest == 15) { if(dest == 15) {
reg[15].I &= 0xFFFFFFFC; reg[15].I &= 0xFFFFFFFC;
@ -6001,7 +6001,7 @@ if(cond_res) {
int dest = (opcode >> 12) & 15; int dest = (opcode >> 12) & 15;
int base = (opcode >> 16) & 15; int base = (opcode >> 16) & 15;
u32 address = reg[base].I - offset; u32 address = reg[base].I - offset;
reg[base].I = address; reg[base].I = address;
CPUWriteByte(address, reg[dest].B.B0); CPUWriteByte(address, reg[dest].B.B0);
clockTicks = 2 + dataTicksAccess16(address) + clockTicks = 2 + dataTicksAccess16(address) +
codeTicksAccess32(armNextPC); codeTicksAccess32(armNextPC);
@ -6046,7 +6046,7 @@ if(cond_res) {
int dest = (opcode >> 12) & 15; int dest = (opcode >> 12) & 15;
int base = (opcode >> 16) & 15; int base = (opcode >> 16) & 15;
u32 address = reg[base].I - value; u32 address = reg[base].I - value;
reg[base].I = address; reg[base].I = address;
CPUWriteByte(address, reg[dest].B.B0); CPUWriteByte(address, reg[dest].B.B0);
clockTicks = 2 + dataTicksAccess16(address) + clockTicks = 2 + dataTicksAccess16(address) +
codeTicksAccess32(armNextPC); codeTicksAccess32(armNextPC);
@ -6153,7 +6153,7 @@ if(cond_res) {
int dest = (opcode >> 12) & 15; int dest = (opcode >> 12) & 15;
int base = (opcode >> 16) & 15; int base = (opcode >> 16) & 15;
u32 address = reg[base].I + offset; u32 address = reg[base].I + offset;
reg[base].I = address; reg[base].I = address;
CPUWriteByte(address, reg[dest].B.B0); CPUWriteByte(address, reg[dest].B.B0);
clockTicks = 2 + dataTicksAccess16(address) + clockTicks = 2 + dataTicksAccess16(address) +
codeTicksAccess32(armNextPC); codeTicksAccess32(armNextPC);
@ -6198,7 +6198,7 @@ if(cond_res) {
int dest = (opcode >> 12) & 15; int dest = (opcode >> 12) & 15;
int base = (opcode >> 16) & 15; int base = (opcode >> 16) & 15;
u32 address = reg[base].I + value; u32 address = reg[base].I + value;
reg[base].I = address; reg[base].I = address;
CPUWriteByte(address, reg[dest].B.B0); CPUWriteByte(address, reg[dest].B.B0);
clockTicks = 2 + dataTicksAccess16(address) + clockTicks = 2 + dataTicksAccess16(address) +
codeTicksAccess32(armNextPC); codeTicksAccess32(armNextPC);
@ -6600,7 +6600,7 @@ if(cond_res) {
u32 address = reg[base].I - offset; u32 address = reg[base].I - offset;
reg[dest].I = CPUReadByte(address); reg[dest].I = CPUReadByte(address);
if(dest != base) if(dest != base)
reg[base].I = address; reg[base].I = address;
clockTicks = 0; clockTicks = 0;
if(dest == 15) { if(dest == 15) {
reg[15].I &= 0xFFFFFFFC; reg[15].I &= 0xFFFFFFFC;
@ -6663,7 +6663,7 @@ if(cond_res) {
u32 address = reg[base].I - value; u32 address = reg[base].I - value;
reg[dest].I = CPUReadByte(address); reg[dest].I = CPUReadByte(address);
if(dest != base) if(dest != base)
reg[base].I = address; reg[base].I = address;
clockTicks = 0; clockTicks = 0;
if(dest == 15) { if(dest == 15) {
reg[15].I &= 0xFFFFFFFC; reg[15].I &= 0xFFFFFFFC;
@ -6820,7 +6820,7 @@ if(cond_res) {
u32 address = reg[base].I + offset; u32 address = reg[base].I + offset;
reg[dest].I = CPUReadByte(address); reg[dest].I = CPUReadByte(address);
if(dest != base) if(dest != base)
reg[base].I = address; reg[base].I = address;
clockTicks = 0; clockTicks = 0;
if(dest == 15) { if(dest == 15) {
reg[15].I &= 0xFFFFFFFC; reg[15].I &= 0xFFFFFFFC;
@ -6883,7 +6883,7 @@ if(cond_res) {
u32 address = reg[base].I + value; u32 address = reg[base].I + value;
reg[dest].I = CPUReadByte(address); reg[dest].I = CPUReadByte(address);
if(dest != base) if(dest != base)
reg[base].I = address; reg[base].I = address;
clockTicks = 0; clockTicks = 0;
if(dest == 15) { if(dest == 15) {
reg[15].I &= 0xFFFFFFFC; reg[15].I &= 0xFFFFFFFC;
@ -6919,14 +6919,14 @@ if(cond_res) {
}\ }\
address += 4;\ address += 4;\
} }
CASE_16(0x800) CASE_16(0x800)
{ {
// STMDA Rn, {Rlist} // STMDA Rn, {Rlist}
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = (temp + 4) & 0xFFFFFFFC; u32 address = (temp + 4) & 0xFFFFFFFC;
int offset = 0; int offset = 0;
@ -6961,7 +6961,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = (temp+4) & 0xFFFFFFFC; u32 address = (temp+4) & 0xFFFFFFFC;
int offset = 0; int offset = 0;
@ -6998,7 +6998,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = (temp+4) & 0xFFFFFFFC; u32 address = (temp+4) & 0xFFFFFFFC;
int offset = 0; int offset = 0;
@ -7050,7 +7050,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = (temp+4) & 0xFFFFFFFC; u32 address = (temp+4) & 0xFFFFFFFC;
int offset = 0; int offset = 0;
@ -7097,7 +7097,7 @@ if(cond_res) {
clockTicks += 1 + codeTicksAccess32(armNextPC); clockTicks += 1 + codeTicksAccess32(armNextPC);
} }
break; break;
CASE_16(0x880) CASE_16(0x880)
{ {
// STMIA Rn, {Rlist} // STMIA Rn, {Rlist}
@ -7194,7 +7194,7 @@ if(cond_res) {
STM_REG(512, 9); STM_REG(512, 9);
STM_REG(1024, 10); STM_REG(1024, 10);
STM_REG(2048, 11); STM_REG(2048, 11);
STM_REG(4096, 12); STM_REG(4096, 12);
} }
if(armMode != 0x10 && armMode != 0x1f) { if(armMode != 0x10 && armMode != 0x1f) {
STM_REG(8192, R13_USR); STM_REG(8192, R13_USR);
@ -7222,7 +7222,7 @@ if(cond_res) {
u32 address = reg[base].I & 0xFFFFFFFC; u32 address = reg[base].I & 0xFFFFFFFC;
int offset = 0; int offset = 0;
u32 temp = reg[base].I + 4*(cpuBitsSet[opcode & 0xFF] + u32 temp = reg[base].I + 4*(cpuBitsSet[opcode & 0xFF] +
cpuBitsSet[(opcode >> 8) & 255]); cpuBitsSet[(opcode >> 8) & 255]);
STMW_REG(1, 0); STMW_REG(1, 0);
STMW_REG(2, 1); STMW_REG(2, 1);
STMW_REG(4, 2); STMW_REG(4, 2);
@ -7242,7 +7242,7 @@ if(cond_res) {
STMW_REG(512, 9); STMW_REG(512, 9);
STMW_REG(1024, 10); STMW_REG(1024, 10);
STMW_REG(2048, 11); STMW_REG(2048, 11);
STMW_REG(4096, 12); STMW_REG(4096, 12);
} }
if(armMode != 0x10 && armMode != 0x1f) { if(armMode != 0x10 && armMode != 0x1f) {
STMW_REG(8192, R13_USR); STMW_REG(8192, R13_USR);
@ -7262,14 +7262,14 @@ if(cond_res) {
clockTicks += 1 + codeTicksAccess32(armNextPC); clockTicks += 1 + codeTicksAccess32(armNextPC);
} }
break; break;
CASE_16(0x900) CASE_16(0x900)
{ {
// STMDB Rn, {Rlist} // STMDB Rn, {Rlist}
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = temp & 0xFFFFFFFC; u32 address = temp & 0xFFFFFFFC;
int offset = 0; int offset = 0;
@ -7304,7 +7304,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = temp & 0xFFFFFFFC; u32 address = temp & 0xFFFFFFFC;
int offset = 0; int offset = 0;
@ -7341,7 +7341,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = temp & 0xFFFFFFFC; u32 address = temp & 0xFFFFFFFC;
int offset = 0; int offset = 0;
@ -7393,7 +7393,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = temp & 0xFFFFFFFC; u32 address = temp & 0xFFFFFFFC;
int offset = 0; int offset = 0;
@ -7537,7 +7537,7 @@ if(cond_res) {
STM_REG(512, 9); STM_REG(512, 9);
STM_REG(1024, 10); STM_REG(1024, 10);
STM_REG(2048, 11); STM_REG(2048, 11);
STM_REG(4096, 12); STM_REG(4096, 12);
} }
if(armMode != 0x10 && armMode != 0x1f) { if(armMode != 0x10 && armMode != 0x1f) {
STM_REG(8192, R13_USR); STM_REG(8192, R13_USR);
@ -7565,7 +7565,7 @@ if(cond_res) {
u32 address = (reg[base].I+4) & 0xFFFFFFFC; u32 address = (reg[base].I+4) & 0xFFFFFFFC;
int offset = 0; int offset = 0;
u32 temp = reg[base].I + 4*(cpuBitsSet[opcode & 0xFF] + u32 temp = reg[base].I + 4*(cpuBitsSet[opcode & 0xFF] +
cpuBitsSet[(opcode >> 8) & 255]); cpuBitsSet[(opcode >> 8) & 255]);
STMW_REG(1, 0); STMW_REG(1, 0);
STMW_REG(2, 1); STMW_REG(2, 1);
STMW_REG(4, 2); STMW_REG(4, 2);
@ -7585,7 +7585,7 @@ if(cond_res) {
STMW_REG(512, 9); STMW_REG(512, 9);
STMW_REG(1024, 10); STMW_REG(1024, 10);
STMW_REG(2048, 11); STMW_REG(2048, 11);
STMW_REG(4096, 12); STMW_REG(4096, 12);
} }
if(armMode != 0x10 && armMode != 0x1f) { if(armMode != 0x10 && armMode != 0x1f) {
STMW_REG(8192, R13_USR); STMW_REG(8192, R13_USR);
@ -7605,7 +7605,7 @@ if(cond_res) {
clockTicks += 1 + codeTicksAccess32(armNextPC); clockTicks += 1 + codeTicksAccess32(armNextPC);
} }
break; break;
#define LDM_REG(val,num) \ #define LDM_REG(val,num) \
if(opcode & (val)) {\ if(opcode & (val)) {\
reg[(num)].I = CPUReadMemory(address);\ reg[(num)].I = CPUReadMemory(address);\
@ -7624,7 +7624,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = (temp + 4) & 0xFFFFFFFC; u32 address = (temp + 4) & 0xFFFFFFFC;
clockTicks = 0; clockTicks = 0;
@ -7664,7 +7664,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = (temp + 4) & 0xFFFFFFFC; u32 address = (temp + 4) & 0xFFFFFFFC;
clockTicks = 0; clockTicks = 0;
@ -7707,7 +7707,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = (temp + 4) & 0xFFFFFFFC; u32 address = (temp + 4) & 0xFFFFFFFC;
clockTicks = 0; clockTicks = 0;
@ -7787,7 +7787,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = (temp + 4) & 0xFFFFFFFC; u32 address = (temp + 4) & 0xFFFFFFFC;
clockTicks = 0; clockTicks = 0;
@ -7811,7 +7811,7 @@ if(cond_res) {
reg[15].I = CPUReadMemory(address); reg[15].I = CPUReadMemory(address);
if(!(opcode & (1 << base))) if(!(opcode & (1 << base)))
reg[base].I = temp; reg[base].I = temp;
CPUSwitchMode(reg[17].I & 0x1f, false); CPUSwitchMode(reg[17].I & 0x1f, false);
@ -7856,7 +7856,7 @@ if(cond_res) {
LDM_REG(16384, 14); LDM_REG(16384, 14);
} }
if(!(opcode & (1 << base))) if(!(opcode & (1 << base)))
reg[base].I = temp; reg[base].I = temp;
if (!offset) if (!offset)
clockTicks += 1 + dataTicksAccess32(address); clockTicks += 1 + dataTicksAccess32(address);
@ -7867,7 +7867,7 @@ if(cond_res) {
clockTicks += 2 + codeTicksAccess32(armNextPC); clockTicks += 2 + codeTicksAccess32(armNextPC);
} }
break; break;
CASE_16(0x890) CASE_16(0x890)
{ {
// LDMIA Rn, {Rlist} // LDMIA Rn, {Rlist}
@ -7913,7 +7913,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I + u32 temp = reg[base].I +
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = reg[base].I & 0xFFFFFFFC; u32 address = reg[base].I & 0xFFFFFFFC;
clockTicks = 0; clockTicks = 0;
@ -8058,7 +8058,7 @@ if(cond_res) {
reg[15].I = CPUReadMemory(address); reg[15].I = CPUReadMemory(address);
if(!(opcode & (1 << base))) if(!(opcode & (1 << base)))
reg[base].I = temp; reg[base].I = temp;
CPUSwitchMode(reg[17].I & 0x1f, false); CPUSwitchMode(reg[17].I & 0x1f, false);
@ -8103,7 +8103,7 @@ if(cond_res) {
LDM_REG(16384, 14); LDM_REG(16384, 14);
} }
if(!(opcode & (1 << base))) if(!(opcode & (1 << base)))
reg[base].I = temp; reg[base].I = temp;
if (!offset) if (!offset)
clockTicks += 1 + dataTicksAccess32(address); clockTicks += 1 + dataTicksAccess32(address);
@ -8114,14 +8114,14 @@ if(cond_res) {
clockTicks += 2 + codeTicksAccess32(armNextPC); clockTicks += 2 + codeTicksAccess32(armNextPC);
} }
break; break;
CASE_16(0x910) CASE_16(0x910)
{ {
// LDMDB Rn, {Rlist} // LDMDB Rn, {Rlist}
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = temp & 0xFFFFFFFC; u32 address = temp & 0xFFFFFFFC;
clockTicks = 0; clockTicks = 0;
@ -8162,7 +8162,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = temp & 0xFFFFFFFC; u32 address = temp & 0xFFFFFFFC;
clockTicks = 0; clockTicks = 0;
@ -8205,7 +8205,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = temp & 0xFFFFFFFC; u32 address = temp & 0xFFFFFFFC;
clockTicks = 0; clockTicks = 0;
@ -8285,7 +8285,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I - u32 temp = reg[base].I -
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = temp & 0xFFFFFFFC; u32 address = temp & 0xFFFFFFFC;
clockTicks = 0; clockTicks = 0;
@ -8309,7 +8309,7 @@ if(cond_res) {
reg[15].I = CPUReadMemory(address); reg[15].I = CPUReadMemory(address);
if(!(opcode & (1 << base))) if(!(opcode & (1 << base)))
reg[base].I = temp; reg[base].I = temp;
CPUSwitchMode(reg[17].I & 0x1f, false); CPUSwitchMode(reg[17].I & 0x1f, false);
@ -8354,7 +8354,7 @@ if(cond_res) {
LDM_REG(16384, 14); LDM_REG(16384, 14);
} }
if(!(opcode & (1 << base))) if(!(opcode & (1 << base)))
reg[base].I = temp; reg[base].I = temp;
if (!offset) if (!offset)
clockTicks += 1 + dataTicksAccess32(address); clockTicks += 1 + dataTicksAccess32(address);
@ -8365,7 +8365,7 @@ if(cond_res) {
clockTicks += 2 + codeTicksAccess32(armNextPC); clockTicks += 2 + codeTicksAccess32(armNextPC);
} }
break; break;
CASE_16(0x990) CASE_16(0x990)
{ {
// LDMIB Rn, {Rlist} // LDMIB Rn, {Rlist}
@ -8411,7 +8411,7 @@ if(cond_res) {
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
int base = (opcode & 0x000F0000) >> 16; int base = (opcode & 0x000F0000) >> 16;
u32 temp = reg[base].I + u32 temp = reg[base].I +
4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]); 4 * (cpuBitsSet[opcode & 255] + cpuBitsSet[(opcode >> 8) & 255]);
u32 address = (reg[base].I+4) & 0xFFFFFFFC; u32 address = (reg[base].I+4) & 0xFFFFFFFC;
clockTicks = 0; clockTicks = 0;
@ -8452,7 +8452,7 @@ if(cond_res) {
if(!(opcode & (1 << base))) if(!(opcode & (1 << base)))
reg[base].I = temp; reg[base].I = temp;
} }
break; break;
CASE_16(0x9d0) CASE_16(0x9d0)
{ {
// LDMIB Rn, {Rlist}^ // LDMIB Rn, {Rlist}^
@ -8561,7 +8561,7 @@ if(cond_res) {
reg[15].I = CPUReadMemory(address); reg[15].I = CPUReadMemory(address);
if(!(opcode & (1 << base))) if(!(opcode & (1 << base)))
reg[base].I = temp; reg[base].I = temp;
CPUSwitchMode(reg[17].I & 0x1f, false); CPUSwitchMode(reg[17].I & 0x1f, false);
@ -8606,7 +8606,7 @@ if(cond_res) {
LDM_REG(16384, 14); LDM_REG(16384, 14);
} }
if(!(opcode & (1 << base))) if(!(opcode & (1 << base)))
reg[base].I = temp; reg[base].I = temp;
if (!offset) if (!offset)
clockTicks += 1 + dataTicksAccess32(address); clockTicks += 1 + dataTicksAccess32(address);
@ -8616,7 +8616,7 @@ if(cond_res) {
} }
clockTicks += 2 + codeTicksAccess32(armNextPC); clockTicks += 2 + codeTicksAccess32(armNextPC);
} }
break; break;
CASE_256(0xa00) CASE_256(0xa00)
{ {
// B <offset> // B <offset>
@ -8660,7 +8660,7 @@ if(cond_res) {
clockTicks += 2 + codeTicksAccess32(armNextPC) + clockTicks += 2 + codeTicksAccess32(armNextPC) +
codeTicksAccessSeq32(armNextPC); codeTicksAccessSeq32(armNextPC);
busPrefetchCount=0; busPrefetchCount=0;
CPUSoftwareInterrupt(opcode & 0x00FFFFFF); CPUSoftwareInterrupt(opcode & 0x00FFFFFF);
break; break;
#ifdef GP_SUPPORT #ifdef GP_SUPPORT
@ -8683,7 +8683,7 @@ if(cond_res) {
case 0xe0d: case 0xe0d:
case 0xe0f: case 0xe0f:
// MRC // MRC
break; break;
#endif #endif
default: default:
#ifdef DEV_VERSION #ifdef DEV_VERSION

View File

@ -135,11 +135,11 @@ const Opcodes thumbOpcodes[] = {
// Format 13 // Format 13
{0xff00, 0xb000, "add sp, %s"}, {0xff00, 0xb000, "add sp, %s"},
// Format 14 // Format 14
{0xffff, 0xb500, "push {lr}"}, {0xffff, 0xb500, "push {lr}"},
{0xff00, 0xb400, "push {%l}"}, {0xff00, 0xb400, "push {%l}"},
{0xff00, 0xb500, "push {%l,lr}"}, {0xff00, 0xb500, "push {%l,lr}"},
{0xffff, 0xbd00, "pop {pc}"}, {0xffff, 0xbd00, "pop {pc}"},
{0xff00, 0xbd00, "pop {%l,pc}"}, {0xff00, 0xbd00, "pop {%l,pc}"},
{0xff00, 0xbc00, "pop {%l}"}, {0xff00, 0xbc00, "pop {%l}"},
// Format 15 // Format 15
{0xf800, 0xc000, "stmia %r8!, {%l}"}, {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){ int disArm(u32 offset, char *dest, int flags){
u32 opcode = debuggerReadMemory(offset); u32 opcode = debuggerReadMemory(offset);
const Opcodes *sp = armOpcodes; const Opcodes *sp = armOpcodes;
while( sp->cval != (opcode & sp->mask) ) while( sp->cval != (opcode & sp->mask) )
sp++; sp++;
@ -431,7 +431,7 @@ int disArm(u32 offset, char *dest, int flags){
if(opcode & 0x00100000) if(opcode & 0x00100000)
dest = addStr(dest, armMultLoadStore[8+((opcode>>23)&3)]); dest = addStr(dest, armMultLoadStore[8+((opcode>>23)&3)]);
else else
dest = addStr(dest, armMultLoadStore[4+((opcode>>23)&3)]); dest = addStr(dest, armMultLoadStore[4+((opcode>>23)&3)]);
} else } else
dest = addStr(dest, armMultLoadStore[(opcode>>23)&3]); dest = addStr(dest, armMultLoadStore[(opcode>>23)&3]);
break; break;
@ -540,18 +540,18 @@ int disArm(u32 offset, char *dest, int flags){
} }
} }
*dest++ = 0; *dest++ = 0;
return 4; return 4;
} }
int disThumb(u32 offset, char *dest, int flags){ int disThumb(u32 offset, char *dest, int flags){
u32 opcode = debuggerReadHalfWord(offset); u32 opcode = debuggerReadHalfWord(offset);
const Opcodes *sp = thumbOpcodes; const Opcodes *sp = thumbOpcodes;
int ret = 2; int ret = 2;
while( sp->cval != (opcode & sp->mask) ) while( sp->cval != (opcode & sp->mask) )
sp++; sp++;
if (flags&DIS_VIEW_ADDRESS){ if (flags&DIS_VIEW_ADDRESS){
dest = addHex(dest, 32, offset); dest = addHex(dest, 32, offset);
*dest++ = ' '; *dest++ = ' ';
@ -560,7 +560,7 @@ int disThumb(u32 offset, char *dest, int flags){
dest = addHex(dest, 16, opcode); dest = addHex(dest, 16, opcode);
*dest++ = ' '; *dest++ = ' ';
} }
const char *src = sp->mnemonic; const char *src = sp->mnemonic;
while (*src){ while (*src){
if (*src!='%') if (*src!='%')
@ -636,7 +636,7 @@ int disThumb(u32 offset, char *dest, int flags){
if(*s) { if(*s) {
*dest++ = ' '; *dest++ = ' ';
dest = addStr(dest, s); dest = addStr(dest, s);
} }
} }
break; break;
case 'b': case 'b':

View File

@ -93,13 +93,13 @@ void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
for(int y = 0; y < height; y++) { for(int y = 0; y < height; y++) {
u16 *from_orig = from; u16 *from_orig = from;
u16 *to_orig = to; u16 *to_orig = to;
if (y+1 < height) 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); width+1);
else else
fill_rgb_row_16(from, from_width, rgb_row_next, width+1); 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 // every pixel in the src region, is extended to 4 pixels in the
// destination, arranged in a square 'quad'; if the current src // destination, arranged in a square 'quad'; if the current src
// pixel is 'a', then in what follows 'b' is the src pixel to the // 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 // upper left pixel in quad: just copy it in
*to++ = RGB(*ar, *ag, *ab); *to++ = RGB(*ar, *ag, *ab);
// upper right // upper right
*to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1); *to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1);
// lower left // lower left
*to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1); *to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1);
// lower right // lower right
*to_odd++ = RGB((*ar+*br+*cr+*dr)>>2, *to_odd++ = RGB((*ar+*br+*cr+*dr)>>2,
(*ag+*bg+*cg+*dg)>>2, (*ag+*bg+*cg+*dg)>>2,
(*ab+*bb+*cb+*db)>>2); (*ab+*bb+*cb+*db)>>2);
// 'b' becomes 'a', 'd' becomes 'c' // 'b' becomes 'a', 'd' becomes 'c'
ar = br; ar = br;
ag = bg; ag = bg;
@ -143,14 +143,14 @@ void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
cg = dg; cg = dg;
cb = db; cb = db;
} }
// the "next" rgb row becomes the current; the old current rgb row is // the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row // recycled and serves as the new "next" row
u8 *temp; u8 *temp;
temp = rgb_row_cur; temp = rgb_row_cur;
rgb_row_cur = rgb_row_next; rgb_row_cur = rgb_row_next;
rgb_row_next = temp; rgb_row_next = temp;
// update the pointers for start of next pair of lines // update the pointers for start of next pair of lines
from = (u16 *)((u8 *)from_orig + srcPitch); from = (u16 *)((u8 *)from_orig + srcPitch);
to = (u16 *)((u8 *)to_orig + (dstPitch << 1)); 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++) { for(int y = 0; y < height; y++) {
u16 *from_orig = from; u16 *from_orig = from;
u16 *to_orig = to; u16 *to_orig = to;
if (y+1 < height) 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); width+1);
else else
fill_rgb_row_16(from, from_width, rgb_row_next, width+1); 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 // every pixel in the src region, is extended to 4 pixels in the
// destination, arranged in a square 'quad'; if the current src // destination, arranged in a square 'quad'; if the current src
// pixel is 'a', then in what follows 'b' is the src pixel to the // 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 *dr = next_row++;
u8 *dg = next_row++; u8 *dg = next_row++;
u8 *db = next_row++; u8 *db = next_row++;
// upper left pixel in quad: just copy it in // upper left pixel in quad: just copy it in
//*to++ = manip.rgb(*ar, *ag, *ab); //*to++ = manip.rgb(*ar, *ag, *ab);
#ifdef USE_ORIGINAL_BILINEAR_PLUS #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, (((*ag)<<3) +((*ag)<<1) + (*cg+*bg+*bg+*cg) )>> 4,
(((*ab)<<3) +((*ab)<<1) + (*cb+*bb+*bb+*cb) )>> 4); (((*ab)<<3) +((*ab)<<1) + (*cb+*bb+*bb+*cb) )>> 4);
#endif #endif
// upper right // upper right
*to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1); *to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1);
// lower left // lower left
*to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1); *to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1);
// lower right // lower right
*to_odd++ = RGB((*ar+*br+*cr+*dr)>>2, *to_odd++ = RGB((*ar+*br+*cr+*dr)>>2,
(*ag+*bg+*cg+*dg)>>2, (*ag+*bg+*cg+*dg)>>2,
(*ab+*bb+*cb+*db)>>2); (*ab+*bb+*cb+*db)>>2);
// 'b' becomes 'a', 'd' becomes 'c' // 'b' becomes 'a', 'd' becomes 'c'
ar = br; ar = br;
ag = bg; ag = bg;
@ -232,14 +232,14 @@ void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
cg = dg; cg = dg;
cb = db; cb = db;
} }
// the "next" rgb row becomes the current; the old current rgb row is // the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row // recycled and serves as the new "next" row
u8 *temp; u8 *temp;
temp = rgb_row_cur; temp = rgb_row_cur;
rgb_row_cur = rgb_row_next; rgb_row_cur = rgb_row_next;
rgb_row_next = temp; rgb_row_next = temp;
// update the pointers for start of next pair of lines // update the pointers for start of next pair of lines
from = (u16 *)((u8 *)from_orig + srcPitch); from = (u16 *)((u8 *)from_orig + srcPitch);
to = (u16 *)((u8 *)to_orig + (dstPitch << 1)); 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++) { for(int y = 0; y < height; y++) {
u32 *from_orig = from; u32 *from_orig = from;
u32 *to_orig = to; u32 *to_orig = to;
if (y+1 < height) 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); width+1);
else else
fill_rgb_row_32(from, from_width, rgb_row_next, width+1); 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 // every pixel in the src region, is extended to 4 pixels in the
// destination, arranged in a square 'quad'; if the current src // destination, arranged in a square 'quad'; if the current src
// pixel is 'a', then in what follows 'b' is the src pixel to the // 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 // upper left pixel in quad: just copy it in
*to++ = RGB(*ar, *ag, *ab); *to++ = RGB(*ar, *ag, *ab);
// upper right // upper right
*to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1); *to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1);
// lower left // lower left
*to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1); *to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1);
// lower right // lower right
*to_odd++ = RGB((*ar+*br+*cr+*dr)>>2, *to_odd++ = RGB((*ar+*br+*cr+*dr)>>2,
(*ag+*bg+*cg+*dg)>>2, (*ag+*bg+*cg+*dg)>>2,
(*ab+*bb+*cb+*db)>>2); (*ab+*bb+*cb+*db)>>2);
// 'b' becomes 'a', 'd' becomes 'c' // 'b' becomes 'a', 'd' becomes 'c'
ar = br; ar = br;
ag = bg; ag = bg;
@ -312,14 +312,14 @@ void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
cg = dg; cg = dg;
cb = db; cb = db;
} }
// the "next" rgb row becomes the current; the old current rgb row is // the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row // recycled and serves as the new "next" row
u8 *temp; u8 *temp;
temp = rgb_row_cur; temp = rgb_row_cur;
rgb_row_cur = rgb_row_next; rgb_row_cur = rgb_row_next;
rgb_row_next = temp; rgb_row_next = temp;
// update the pointers for start of next pair of lines // update the pointers for start of next pair of lines
from = (u32 *)((u8 *)from_orig + srcPitch); from = (u32 *)((u8 *)from_orig + srcPitch);
to = (u32 *)((u8 *)to_orig + (dstPitch << 1)); 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++) { for(int y = 0; y < height; y++) {
u32 *from_orig = from; u32 *from_orig = from;
u32 *to_orig = to; u32 *to_orig = to;
if (y+1 < height) 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); width+1);
else else
fill_rgb_row_32(from, from_width, rgb_row_next, width+1); 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 // every pixel in the src region, is extended to 4 pixels in the
// destination, arranged in a square 'quad'; if the current src // destination, arranged in a square 'quad'; if the current src
// pixel is 'a', then in what follows 'b' is the src pixel to the // 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 *dr = next_row++;
u8 *dg = next_row++; u8 *dg = next_row++;
u8 *db = next_row++; u8 *db = next_row++;
// upper left pixel in quad: just copy it in // upper left pixel in quad: just copy it in
//*to++ = manip.rgb(*ar, *ag, *ab); //*to++ = manip.rgb(*ar, *ag, *ab);
#ifdef USE_ORIGINAL_BILINEAR_PLUS #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, (((*ag)<<3) +((*ag)<<1) + (*cg+*bg+*bg+*cg) )>> 4,
(((*ab)<<3) +((*ab)<<1) + (*cb+*bb+*bb+*cb) )>> 4); (((*ab)<<3) +((*ab)<<1) + (*cb+*bb+*bb+*cb) )>> 4);
#endif #endif
// upper right // upper right
*to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1); *to++ = RGB((*ar+*br)>>1, (*ag+*bg)>>1, (*ab+*bb)>>1);
// lower left // lower left
*to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1); *to_odd++ = RGB((*ar+*cr)>>1, (*ag+*cg)>>1, (*ab+*cb)>>1);
// lower right // lower right
*to_odd++ = RGB((*ar+*br+*cr+*dr)>>2, *to_odd++ = RGB((*ar+*br+*cr+*dr)>>2,
(*ag+*bg+*cg+*dg)>>2, (*ag+*bg+*cg+*dg)>>2,
(*ab+*bb+*cb+*db)>>2); (*ab+*bb+*cb+*db)>>2);
// 'b' becomes 'a', 'd' becomes 'c' // 'b' becomes 'a', 'd' becomes 'c'
ar = br; ar = br;
ag = bg; ag = bg;
@ -403,14 +403,14 @@ void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
cg = dg; cg = dg;
cb = db; cb = db;
} }
// the "next" rgb row becomes the current; the old current rgb row is // the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row // recycled and serves as the new "next" row
u8 *temp; u8 *temp;
temp = rgb_row_cur; temp = rgb_row_cur;
rgb_row_cur = rgb_row_next; rgb_row_cur = rgb_row_next;
rgb_row_next = temp; rgb_row_next = temp;
// update the pointers for start of next pair of lines // update the pointers for start of next pair of lines
from = (u32 *)((u8 *)from_orig + srcPitch); from = (u32 *)((u8 *)from_orig + srcPitch);
to = (u32 *)((u8 *)to_orig + (dstPitch << 1)); to = (u32 *)((u8 *)to_orig + (dstPitch << 1));

View File

@ -99,7 +99,7 @@ void BIOS_ArcTan2()
VCOUNT); VCOUNT);
} }
#endif #endif
s32 x = reg[0].I; s32 x = reg[0].I;
s32 y = reg[1].I; s32 y = reg[1].I;
u32 res = 0; u32 res = 0;
@ -127,18 +127,18 @@ void BIOS_ArcTan2()
} }
} }
reg[0].I = res; reg[0].I = res;
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(systemVerbose & VERBOSE_SWI) { if(systemVerbose & VERBOSE_SWI) {
log("ArcTan2: return=%08x\n", log("ArcTan2: return=%08x\n",
reg[0].I); reg[0].I);
} }
#endif #endif
} }
void BIOS_BitUnPack() void BIOS_BitUnPack()
{ {
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(systemVerbose & VERBOSE_SWI) { if(systemVerbose & VERBOSE_SWI) {
log("BitUnPack: %08x,%08x,%08x (VCOUNT=%2d)\n", log("BitUnPack: %08x,%08x,%08x (VCOUNT=%2d)\n",
reg[0].I, reg[0].I,
@ -151,7 +151,7 @@ void BIOS_BitUnPack()
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
u32 header = reg[2].I; u32 header = reg[2].I;
int len = CPUReadHalfWord(header); int len = CPUReadHalfWord(header);
// check address // check address
if(((source & 0xe000000) == 0) || if(((source & 0xe000000) == 0) ||
@ -159,21 +159,21 @@ void BIOS_BitUnPack()
return; return;
int bits = CPUReadByte(header+2); int bits = CPUReadByte(header+2);
int revbits = 8 - bits; int revbits = 8 - bits;
// u32 value = 0; // u32 value = 0;
u32 base = CPUReadMemory(header+4); u32 base = CPUReadMemory(header+4);
bool addBase = (base & 0x80000000) ? true : false; bool addBase = (base & 0x80000000) ? true : false;
base &= 0x7fffffff; base &= 0x7fffffff;
int dataSize = CPUReadByte(header+3); int dataSize = CPUReadByte(header+3);
int data = 0; int data = 0;
int bitwritecount = 0; int bitwritecount = 0;
while(1) { while(1) {
len -= 1; len -= 1;
if(len < 0) if(len < 0)
break; break;
int mask = 0xff >> revbits; int mask = 0xff >> revbits;
u8 b = CPUReadByte(source); u8 b = CPUReadByte(source);
source++; source++;
int bitcount = 0; int bitcount = 0;
while(1) { while(1) {
@ -205,7 +205,7 @@ void BIOS_GetBiosChecksum()
void BIOS_BgAffineSet() void BIOS_BgAffineSet()
{ {
#ifdef DEV_VERSION #ifdef DEV_VERSION
if(systemVerbose & VERBOSE_SWI) { if(systemVerbose & VERBOSE_SWI) {
log("BgAffineSet: %08x,%08x,%08x (VCOUNT=%2d)\n", log("BgAffineSet: %08x,%08x,%08x (VCOUNT=%2d)\n",
reg[0].I, reg[0].I,
@ -214,7 +214,7 @@ void BIOS_BgAffineSet()
VCOUNT); VCOUNT);
} }
#endif #endif
u32 src = reg[0].I; u32 src = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
int num = reg[2].I; int num = reg[2].I;
@ -241,7 +241,7 @@ void BIOS_BgAffineSet()
s16 dmx = (rx * b)>>14; s16 dmx = (rx * b)>>14;
s16 dy = (ry * b)>>14; s16 dy = (ry * b)>>14;
s16 dmy = (ry * a)>>14; s16 dmy = (ry * a)>>14;
CPUWriteHalfWord(dest, dx); CPUWriteHalfWord(dest, dx);
dest += 2; dest += 2;
CPUWriteHalfWord(dest, -dmx); CPUWriteHalfWord(dest, -dmx);
@ -253,13 +253,13 @@ void BIOS_BgAffineSet()
s32 startx = cx - dx * dispx + dmx * dispy; s32 startx = cx - dx * dispx + dmx * dispy;
s32 starty = cy - dy * dispx - dmy * dispy; s32 starty = cy - dy * dispx - dmy * dispy;
CPUWriteMemory(dest, startx); CPUWriteMemory(dest, startx);
dest += 4; dest += 4;
CPUWriteMemory(dest, starty); CPUWriteMemory(dest, starty);
dest += 4; dest += 4;
} }
} }
void BIOS_CpuSet() void BIOS_CpuSet()
{ {
@ -269,7 +269,7 @@ void BIOS_CpuSet()
reg[2].I, VCOUNT); reg[2].I, VCOUNT);
} }
#endif #endif
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
u32 cnt = reg[2].I; u32 cnt = reg[2].I;
@ -331,7 +331,7 @@ void BIOS_CpuFastSet()
reg[2].I, VCOUNT); reg[2].I, VCOUNT);
} }
#endif #endif
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
u32 cnt = reg[2].I; u32 cnt = reg[2].I;
@ -343,9 +343,9 @@ void BIOS_CpuFastSet()
// needed for 32-bit mode! // needed for 32-bit mode!
source &= 0xFFFFFFFC; source &= 0xFFFFFFFC;
dest &= 0xFFFFFFFC; dest &= 0xFFFFFFFC;
int count = cnt & 0x1FFFFF; int count = cnt & 0x1FFFFF;
// fill? // fill?
if((cnt >> 24) & 1) { if((cnt >> 24) & 1) {
while(count > 0) { while(count > 0) {
@ -379,7 +379,7 @@ void BIOS_Diff8bitUnFilterWram()
reg[1].I, VCOUNT); reg[1].I, VCOUNT);
} }
#endif #endif
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
@ -388,20 +388,20 @@ void BIOS_Diff8bitUnFilterWram()
if(((source & 0xe000000) == 0) || if(((source & 0xe000000) == 0) ||
((source + ((header >> 8) & 0x1fffff) & 0xe000000) == 0)) ((source + ((header >> 8) & 0x1fffff) & 0xe000000) == 0))
return; return;
int len = header >> 8; int len = header >> 8;
u8 data = CPUReadByte(source++); u8 data = CPUReadByte(source++);
CPUWriteByte(dest++, data); CPUWriteByte(dest++, data);
len--; len--;
while(len > 0) { while(len > 0) {
u8 diff = CPUReadByte(source++); u8 diff = CPUReadByte(source++);
data += diff; data += diff;
CPUWriteByte(dest++, data); CPUWriteByte(dest++, data);
len--; len--;
} }
} }
void BIOS_Diff8bitUnFilterVram() void BIOS_Diff8bitUnFilterVram()
@ -412,7 +412,7 @@ void BIOS_Diff8bitUnFilterVram()
reg[1].I, VCOUNT); reg[1].I, VCOUNT);
} }
#endif #endif
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
@ -421,15 +421,15 @@ void BIOS_Diff8bitUnFilterVram()
if(((source & 0xe000000) == 0) || if(((source & 0xe000000) == 0) ||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
return; return;
int len = header >> 8; int len = header >> 8;
u8 data = CPUReadByte(source++); u8 data = CPUReadByte(source++);
u16 writeData = data; u16 writeData = data;
int shift = 8; int shift = 8;
int bytes = 1; int bytes = 1;
while(len >= 2) { while(len >= 2) {
u8 diff = CPUReadByte(source++); u8 diff = CPUReadByte(source++);
data += diff; data += diff;
@ -444,7 +444,7 @@ void BIOS_Diff8bitUnFilterVram()
writeData = 0; writeData = 0;
shift = 0; shift = 0;
} }
} }
} }
void BIOS_Diff16bitUnFilter() void BIOS_Diff16bitUnFilter()
@ -455,7 +455,7 @@ void BIOS_Diff16bitUnFilter()
reg[1].I, VCOUNT); reg[1].I, VCOUNT);
} }
#endif #endif
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
@ -464,8 +464,8 @@ void BIOS_Diff16bitUnFilter()
if(((source & 0xe000000) == 0) || if(((source & 0xe000000) == 0) ||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
return; return;
int len = header >> 8; int len = header >> 8;
u16 data = CPUReadHalfWord(source); u16 data = CPUReadHalfWord(source);
@ -473,7 +473,7 @@ void BIOS_Diff16bitUnFilter()
CPUWriteHalfWord(dest, data); CPUWriteHalfWord(dest, data);
dest += 2; dest += 2;
len -= 2; len -= 2;
while(len >= 2) { while(len >= 2) {
u16 diff = CPUReadHalfWord(source); u16 diff = CPUReadHalfWord(source);
source += 2; source += 2;
@ -494,7 +494,7 @@ void BIOS_Div()
VCOUNT); VCOUNT);
} }
#endif #endif
int number = reg[0].I; int number = reg[0].I;
int denom = reg[1].I; int denom = reg[1].I;
@ -523,7 +523,7 @@ void BIOS_DivARM()
VCOUNT); VCOUNT);
} }
#endif #endif
u32 temp = reg[0].I; u32 temp = reg[0].I;
reg[0].I = reg[1].I; reg[0].I = reg[1].I;
reg[1].I = temp; reg[1].I = temp;
@ -540,7 +540,7 @@ void BIOS_HuffUnComp()
VCOUNT); VCOUNT);
} }
#endif #endif
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
@ -549,14 +549,14 @@ void BIOS_HuffUnComp()
if(((source & 0xe000000) == 0) || if(((source & 0xe000000) == 0) ||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
return; return;
u8 treeSize = CPUReadByte(source++); u8 treeSize = CPUReadByte(source++);
u32 treeStart = source; u32 treeStart = source;
source += ((treeSize+1)<<1)-1; // minus because we already skipped one byte source += ((treeSize+1)<<1)-1; // minus because we already skipped one byte
int len = header >> 8; int len = header >> 8;
u32 mask = 0x80000000; u32 mask = 0x80000000;
@ -578,7 +578,7 @@ void BIOS_HuffUnComp()
pos++; pos++;
else else
pos += (((currentNode & 0x3F)+1)<<1); pos += (((currentNode & 0x3F)+1)<<1);
if(data & mask) { if(data & mask) {
// right // right
if(currentNode & 0x40) if(currentNode & 0x40)
@ -590,7 +590,7 @@ void BIOS_HuffUnComp()
writeData = true; writeData = true;
currentNode = CPUReadByte(treeStart+pos); currentNode = CPUReadByte(treeStart+pos);
} }
if(writeData) { if(writeData) {
writeValue |= (currentNode << byteShift); writeValue |= (currentNode << byteShift);
byteCount++; byteCount++;
@ -637,7 +637,7 @@ void BIOS_HuffUnComp()
writeData = true; writeData = true;
currentNode = CPUReadByte(treeStart+pos); currentNode = CPUReadByte(treeStart+pos);
} }
if(writeData) { if(writeData) {
if(halfLen == 0) if(halfLen == 0)
value |= currentNode; value |= currentNode;
@ -649,7 +649,7 @@ void BIOS_HuffUnComp()
writeValue |= (value << byteShift); writeValue |= (value << byteShift);
byteCount++; byteCount++;
byteShift += 8; byteShift += 8;
halfLen = 0; halfLen = 0;
value = 0; value = 0;
@ -672,7 +672,7 @@ void BIOS_HuffUnComp()
data = CPUReadMemory(source); data = CPUReadMemory(source);
source += 4; source += 4;
} }
} }
} }
} }
@ -686,7 +686,7 @@ void BIOS_LZ77UnCompVram()
VCOUNT); VCOUNT);
} }
#endif #endif
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
@ -695,12 +695,12 @@ void BIOS_LZ77UnCompVram()
if(((source & 0xe000000) == 0) || if(((source & 0xe000000) == 0) ||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
return; return;
int byteCount = 0; int byteCount = 0;
int byteShift = 0; int byteShift = 0;
u32 writeValue = 0; u32 writeValue = 0;
int len = header >> 8; int len = header >> 8;
while(len > 0) { while(len > 0) {
@ -754,7 +754,7 @@ void BIOS_LZ77UnCompVram()
byteCount++; byteCount++;
if(byteCount == 2) { if(byteCount == 2) {
CPUWriteHalfWord(dest, writeValue); CPUWriteHalfWord(dest, writeValue);
dest += 2; dest += 2;
byteShift = 0; byteShift = 0;
byteCount = 0; byteCount = 0;
writeValue = 0; writeValue = 0;
@ -775,7 +775,7 @@ void BIOS_LZ77UnCompWram()
VCOUNT); VCOUNT);
} }
#endif #endif
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
@ -784,8 +784,8 @@ void BIOS_LZ77UnCompWram()
if(((source & 0xe000000) == 0) || if(((source & 0xe000000) == 0) ||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
return; return;
int len = header >> 8; int len = header >> 8;
while(len > 0) { while(len > 0) {
@ -836,7 +836,7 @@ void BIOS_ObjAffineSet()
VCOUNT); VCOUNT);
} }
#endif #endif
u32 src = reg[0].I; u32 src = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
int num = reg[2].I; int num = reg[2].I;
@ -857,7 +857,7 @@ void BIOS_ObjAffineSet()
s16 dmx = ((s32)rx * b)>>14; s16 dmx = ((s32)rx * b)>>14;
s16 dy = ((s32)ry * b)>>14; s16 dy = ((s32)ry * b)>>14;
s16 dmy = ((s32)ry * a)>>14; s16 dmy = ((s32)ry * a)>>14;
CPUWriteHalfWord(dest, dx); CPUWriteHalfWord(dest, dx);
dest += offset; dest += offset;
CPUWriteHalfWord(dest, -dmx); CPUWriteHalfWord(dest, -dmx);
@ -875,7 +875,7 @@ void BIOS_RegisterRamReset(u32 flags)
// to emulate bios initialization // to emulate bios initialization
CPUUpdateRegister(0x0, 0x80); CPUUpdateRegister(0x0, 0x80);
if(flags) { if(flags) {
if(flags & 0x01) { if(flags & 0x01) {
// clear work RAM // clear work RAM
@ -918,7 +918,7 @@ void BIOS_RegisterRamReset(u32 flags)
CPUUpdateRegister(0x26, 0x100); CPUUpdateRegister(0x26, 0x100);
CPUUpdateRegister(0x36, 0x100); CPUUpdateRegister(0x36, 0x100);
} }
if(flags & 0x20) { if(flags & 0x20) {
int i; int i;
for(i = 0; i < 8; i++) for(i = 0; i < 8; i++)
@ -968,7 +968,7 @@ void BIOS_RLUnCompVram()
VCOUNT); VCOUNT);
} }
#endif #endif
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
@ -977,8 +977,8 @@ void BIOS_RLUnCompVram()
if(((source & 0xe000000) == 0) || if(((source & 0xe000000) == 0) ||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
return; return;
int len = header >> 8; int len = header >> 8;
int byteCount = 0; int byteCount = 0;
int byteShift = 0; int byteShift = 0;
@ -1037,7 +1037,7 @@ void BIOS_RLUnCompWram()
VCOUNT); VCOUNT);
} }
#endif #endif
u32 source = reg[0].I; u32 source = reg[0].I;
u32 dest = reg[1].I; u32 dest = reg[1].I;
@ -1046,8 +1046,8 @@ void BIOS_RLUnCompWram()
if(((source & 0xe000000) == 0) || if(((source & 0xe000000) == 0) ||
((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)
return; return;
int len = header >> 8; int len = header >> 8;
while(len > 0) { while(len > 0) {
@ -1092,7 +1092,7 @@ void BIOS_SoftReset()
reg[R13_IRQ].I = 0x03007FA0; reg[R13_IRQ].I = 0x03007FA0;
reg[R14_IRQ].I = 0x00000000; reg[R14_IRQ].I = 0x00000000;
reg[SPSR_IRQ].I = 0x00000000; reg[SPSR_IRQ].I = 0x00000000;
reg[R13_SVC].I = 0x03007FE0; reg[R13_SVC].I = 0x03007FE0;
reg[R14_SVC].I = 0x00000000; reg[R14_SVC].I = 0x00000000;
reg[SPSR_SVC].I = 0x00000000; reg[SPSR_SVC].I = 0x00000000;
u8 b = internalRAM[0x7ffa]; u8 b = internalRAM[0x7ffa];

View File

@ -54,7 +54,7 @@
#define DW_AT_sibling 0x01 #define DW_AT_sibling 0x01
#define DW_AT_location 0x02 #define DW_AT_location 0x02
#define DW_AT_name 0x03 #define DW_AT_name 0x03
#define DW_AT_byte_size 0x0b #define DW_AT_byte_size 0x0b
#define DW_AT_bit_offset 0x0c #define DW_AT_bit_offset 0x0c
#define DW_AT_bit_size 0x0d #define DW_AT_bit_size 0x0d
@ -328,7 +328,7 @@ const char *elfGetAddressSymbol(u32 addr)
} }
} }
} }
return ""; return "";
} }
@ -448,9 +448,9 @@ bool elfGetObject(const char *name, Function *f, CompileUnit *u, Object **o)
v = v->next; v = v->next;
} }
} }
CompileUnit *c = elfCompileUnits; CompileUnit *c = elfCompileUnits;
while(c) { while(c) {
if(c != u) { if(c != u) {
Object *v = c->variables; Object *v = c->variables;
@ -464,7 +464,7 @@ bool elfGetObject(const char *name, Function *f, CompileUnit *u, Object **o)
} }
c = c->next; c = c->next;
} }
return false; return false;
} }
@ -626,7 +626,7 @@ ELFFrameState *elfGetFrameState(ELFfde *fde, u32 address)
state->dataAlign = fde->cie->dataAlign; state->dataAlign = fde->cie->dataAlign;
state->codeAlign = fde->cie->codeAlign; state->codeAlign = fde->cie->codeAlign;
state->returnAddress = fde->cie->returnAddress; state->returnAddress = fde->cie->returnAddress;
elfExecuteCFAInstructions(state, elfExecuteCFAInstructions(state,
fde->cie->data, fde->cie->data,
fde->cie->dataLen, fde->cie->dataLen,
@ -647,33 +647,33 @@ void elfPrintCallChain(u32 address)
reg_pair newRegs[15]; reg_pair newRegs[15];
memcpy(&regs[0], &reg[0], sizeof(reg_pair) * 15); memcpy(&regs[0], &reg[0], sizeof(reg_pair) * 15);
while(count < 20) { while(count < 20) {
const char *addr = elfGetAddressSymbol(address); const char *addr = elfGetAddressSymbol(address);
if(*addr == 0) if(*addr == 0)
addr = "???"; addr = "???";
printf("%08x %s\n", address, addr); printf("%08x %s\n", address, addr);
ELFfde *fde = elfGetFde(address); ELFfde *fde = elfGetFde(address);
if(fde == NULL) { if(fde == NULL) {
break; break;
} }
ELFFrameState *state = elfGetFrameState(fde, address); ELFFrameState *state = elfGetFrameState(fde, address);
if(!state) { if(!state) {
break; break;
} }
if(state->cfaMode == CFA_REG_OFFSET) { if(state->cfaMode == CFA_REG_OFFSET) {
memcpy(&newRegs[0], &regs[0], sizeof(reg_pair) * 15); memcpy(&newRegs[0], &regs[0], sizeof(reg_pair) * 15);
u32 addr = 0; u32 addr = 0;
for(int i = 0; i < 15; i++) { for(int i = 0; i < 15; i++) {
ELFFrameStateRegister *r = &state->registers. ELFFrameStateRegister *r = &state->registers.
regs[i]; regs[i];
switch(r->mode) { switch(r->mode) {
case REG_NOT_SET: case REG_NOT_SET:
newRegs[i].I = regs[i].I; newRegs[i].I = regs[i].I;
@ -742,7 +742,7 @@ u32 elfDecodeLocation(Function *f, ELFBlock *o, LocationType *type, u32 base)
break; break;
} }
} }
ELFBlock *loc = o; ELFBlock *loc = o;
u32 location = 0; u32 location = 0;
int bytes = 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_reg12:
case DW_OP_reg13: case DW_OP_reg13:
case DW_OP_reg14: case DW_OP_reg14:
case DW_OP_reg15: case DW_OP_reg15:
location = *loc->data - 0x50; location = *loc->data - 0x50;
*type = LOCATION_register; *type = LOCATION_register;
break; break;
@ -829,7 +829,7 @@ s32 elfReadSignedLEB128(u8 *data, int *bytesRead)
s32 result = 0; s32 result = 0;
int shift = 0; int shift = 0;
int count = 0; int count = 0;
u8 byte; u8 byte;
do { do {
byte = *data++; byte = *data++;
@ -971,7 +971,7 @@ u8 *elfReadAttribute(u8 *data, ELFAttr *attr)
case DW_FORM_ref_udata: case DW_FORM_ref_udata:
attr->value = (u32)((elfDebugInfo->infodata + (elfGetCompileUnitForData(data)->top - elfDebugInfo->infodata) + elfReadLEB128(data, &bytes)) - elfCurrentUnit->top); attr->value = (u32)((elfDebugInfo->infodata + (elfGetCompileUnitForData(data)->top - elfDebugInfo->infodata) + elfReadLEB128(data, &bytes)) - elfCurrentUnit->top);
data += bytes; data += bytes;
break; break;
case DW_FORM_indirect: case DW_FORM_indirect:
form = elfReadLEB128(data, &bytes); form = elfReadLEB128(data, &bytes);
data += bytes; data += bytes;
@ -1063,17 +1063,17 @@ void elfParseCFA(u8 *top)
u8 *end = data + READ32LE(&h->size); u8 *end = data + READ32LE(&h->size);
ELFcie *cies = NULL; ELFcie *cies = NULL;
while(data < end) { while(data < end) {
u32 offset = (u32)(data - topOffset); u32 offset = (u32)(data - topOffset);
u32 len = elfRead4Bytes(data); u32 len = elfRead4Bytes(data);
data += 4; data += 4;
u8 *dataEnd = data + len; u8 *dataEnd = data + len;
u32 id = elfRead4Bytes(data); u32 id = elfRead4Bytes(data);
data += 4; data += 4;
if(id == 0xffffffff) { if(id == 0xffffffff) {
// skip version // skip version
*data++; *data++;
@ -1084,24 +1084,24 @@ void elfParseCFA(u8 *top)
cies = cie; cies = cie;
cie->offset = offset; cie->offset = offset;
cie->augmentation = data; cie->augmentation = data;
while(*data) while(*data)
data++; data++;
data++; data++;
if(*cie->augmentation) { if(*cie->augmentation) {
fprintf(stderr, "Error: augmentation not supported\n"); fprintf(stderr, "Error: augmentation not supported\n");
exit(-1); exit(-1);
} }
int bytes; int bytes;
cie->codeAlign = elfReadLEB128(data, &bytes); cie->codeAlign = elfReadLEB128(data, &bytes);
data += bytes; data += bytes;
cie->dataAlign = elfReadSignedLEB128(data, &bytes); cie->dataAlign = elfReadSignedLEB128(data, &bytes);
data += bytes; data += bytes;
cie->returnAddress = *data++; cie->returnAddress = *data++;
cie->data = data; cie->data = data;
@ -1123,10 +1123,10 @@ void elfParseCFA(u8 *top)
} }
fde->cie = cie; fde->cie = cie;
fde->address = elfRead4Bytes(data); fde->address = elfRead4Bytes(data);
data += 4; data += 4;
fde->end = fde->address + elfRead4Bytes(data); fde->end = fde->address + elfRead4Bytes(data);
data += 4; data += 4;
@ -1169,7 +1169,7 @@ void elfParseLineInfo(CompileUnit *unit, u8 *top)
l->number = 0; l->number = 0;
int max = 1000; int max = 1000;
l->lines = (LineInfoItem *)malloc(1000*sizeof(LineInfoItem)); l->lines = (LineInfoItem *)malloc(1000*sizeof(LineInfoItem));
u8 *data = elfReadSection(top, h); u8 *data = elfReadSection(top, h);
data += unit->lineInfo; data += unit->lineInfo;
u32 totalLen = elfRead4Bytes(data); u32 totalLen = elfRead4Bytes(data);
@ -1202,10 +1202,10 @@ void elfParseLineInfo(CompileUnit *unit, u8 *top)
int count = 4; int count = 4;
int index = 0; int index = 0;
l->files = (char **)malloc(sizeof(char *)*count); l->files = (char **)malloc(sizeof(char *)*count);
while((s = elfReadString(data, &bytes)) != NULL) { while((s = elfReadString(data, &bytes)) != NULL) {
l->files[index++] = s; l->files[index++] = s;
data += bytes; data += bytes;
// directory // directory
elfReadLEB128(data, &bytes); elfReadLEB128(data, &bytes);
@ -1293,7 +1293,7 @@ void elfParseLineInfo(CompileUnit *unit, u8 *top)
op = op - opcodeBase; op = op - opcodeBase;
address += (op / lineRange) * minInstrSize; address += (op / lineRange) * minInstrSize;
line += lineBase + (op % lineRange); 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); // fprintf(stderr, "Address %08x line %d (%d)\n", address, line,file);
basicBlock = 1; basicBlock = 1;
break; break;
@ -1307,32 +1307,32 @@ u8 *elfSkipData(u8 *data, ELFAbbrev *abbrev, ELFAbbrev **abbrevs)
{ {
int i; int i;
int bytes; int bytes;
for(i = 0; i < abbrev->numAttrs; i++) { for(i = 0; i < abbrev->numAttrs; i++) {
data = elfReadAttribute(data, &abbrev->attrs[i]); data = elfReadAttribute(data, &abbrev->attrs[i]);
if(abbrev->attrs[i].form == DW_FORM_block1) if(abbrev->attrs[i].form == DW_FORM_block1)
free(abbrev->attrs[i].block); free(abbrev->attrs[i].block);
} }
if(abbrev->hasChildren) { if(abbrev->hasChildren) {
int nesting = 1; int nesting = 1;
while(nesting) { while(nesting) {
u32 abbrevNum = elfReadLEB128(data, &bytes); u32 abbrevNum = elfReadLEB128(data, &bytes);
data += bytes; data += bytes;
if(!abbrevNum) { if(!abbrevNum) {
nesting--; nesting--;
continue; continue;
} }
abbrev = elfGetAbbrev(abbrevs, abbrevNum); abbrev = elfGetAbbrev(abbrevs, abbrevNum);
for(i = 0; i < abbrev->numAttrs; i++) { for(i = 0; i < abbrev->numAttrs; i++) {
data = elfReadAttribute(data, &abbrev->attrs[i]); data = elfReadAttribute(data, &abbrev->attrs[i]);
if(abbrev->attrs[i].form == DW_FORM_block1) if(abbrev->attrs[i].form == DW_FORM_block1)
free(abbrev->attrs[i].block); free(abbrev->attrs[i].block);
} }
if(abbrev->hasChildren) { if(abbrev->hasChildren) {
nesting++; nesting++;
} }
@ -1356,7 +1356,7 @@ void elfAddType(Type *type, CompileUnit *unit, u32 offset)
type->next = unit->types; type->next = unit->types;
unit->types = type; unit->types = type;
} }
} }
} }
void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit, 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: case DW_TAG_typedef:
{ {
u32 typeref = 0; u32 typeref = 0;
char *name = NULL; char *name = NULL;
for(int i = 0; i < abbrev->numAttrs; i++) { for(int i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data = elfReadAttribute(data, attr); data = elfReadAttribute(data, attr);
@ -1379,7 +1379,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
break; break;
case DW_AT_decl_file: case DW_AT_decl_file:
case DW_AT_decl_line: case DW_AT_decl_line:
break; break;
default: default:
fprintf(stderr, "Unknown attribute for typedef %02x\n", attr->name); fprintf(stderr, "Unknown attribute for typedef %02x\n", attr->name);
break; break;
@ -1401,11 +1401,11 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
t->type = TYPE_struct; t->type = TYPE_struct;
else else
t->type = TYPE_union; t->type = TYPE_union;
Struct *s = (Struct *)calloc(sizeof(Struct), 1); Struct *s = (Struct *)calloc(sizeof(Struct), 1);
t->structure = s; t->structure = s;
elfAddType(t, unit, offset); elfAddType(t, unit, offset);
for(int i = 0; i < abbrev->numAttrs; i++) { for(int i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data = elfReadAttribute(data, attr); data = elfReadAttribute(data, attr);
@ -1435,7 +1435,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
int index = 0; int index = 0;
while(num) { while(num) {
ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num); ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
switch(abbr->tag) { switch(abbr->tag) {
case DW_TAG_member: case DW_TAG_member:
{ {
@ -1561,7 +1561,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
t->type = TYPE_pointer; t->type = TYPE_pointer;
elfAddType(t, unit, offset); elfAddType(t, unit, offset);
for(int i = 0; i < abbrev->numAttrs; i++) { for(int i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data =elfReadAttribute(data, attr); data =elfReadAttribute(data, attr);
@ -1590,7 +1590,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
t->type = TYPE_reference; t->type = TYPE_reference;
elfAddType(t, unit, offset); elfAddType(t, unit, offset);
for(int i = 0; i < abbrev->numAttrs; i++) { for(int i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data =elfReadAttribute(data, attr); data =elfReadAttribute(data, attr);
@ -1615,7 +1615,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
case DW_TAG_volatile_type: case DW_TAG_volatile_type:
{ {
u32 typeref = 0; u32 typeref = 0;
for(int i = 0; i < abbrev->numAttrs; i++) { for(int i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data = elfReadAttribute(data, attr); data = elfReadAttribute(data, attr);
@ -1638,7 +1638,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
case DW_TAG_const_type: case DW_TAG_const_type:
{ {
u32 typeref = 0; u32 typeref = 0;
for(int i = 0; i < abbrev->numAttrs; i++) { for(int i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data = elfReadAttribute(data, attr); data = elfReadAttribute(data, attr);
@ -1690,7 +1690,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
data += bytes; data += bytes;
while(num) { while(num) {
ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num); ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
switch(abbr->tag) { switch(abbr->tag) {
case DW_TAG_enumerator: case DW_TAG_enumerator:
{ {
@ -1717,7 +1717,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
break; break;
default: default:
fprintf(stderr, "Unknown enum tag %02x\n", abbr->tag); fprintf(stderr, "Unknown enum tag %02x\n", abbr->tag);
data = elfSkipData(data, abbr, unit->abbrevs); data = elfSkipData(data, abbr, unit->abbrevs);
break; break;
} }
num = elfReadLEB128(data, &bytes); 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); Type *t = (Type *)calloc(sizeof(Type), 1);
t->type = TYPE_function; t->type = TYPE_function;
FunctionType *f = (FunctionType *)calloc(sizeof(FunctionType), 1); FunctionType *f = (FunctionType *)calloc(sizeof(FunctionType), 1);
t->function = f; t->function = f;
elfAddType(t, unit, offset); elfAddType(t, unit, offset);
for(int i = 0; i < abbrev->numAttrs; i++) { for(int i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data = elfReadAttribute(data, attr); data = elfReadAttribute(data, attr);
switch(attr->name) { switch(attr->name) {
case DW_AT_prototyped: case DW_AT_prototyped:
case DW_AT_sibling: case DW_AT_sibling:
break; break;
case DW_AT_type: case DW_AT_type:
f->returnType = elfParseType(unit, attr->value); f->returnType = elfParseType(unit, attr->value);
@ -1754,10 +1754,10 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
int bytes; int bytes;
u32 num = elfReadLEB128(data, &bytes); u32 num = elfReadLEB128(data, &bytes);
data += bytes; data += bytes;
Object *lastVar = NULL; Object *lastVar = NULL;
while(num) { while(num) {
ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num); ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
switch(abbr->tag) { switch(abbr->tag) {
case DW_TAG_formal_parameter: case DW_TAG_formal_parameter:
{ {
@ -1780,7 +1780,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
break; break;
default: default:
fprintf(stderr, "Unknown subroutine tag %02x\n", abbr->tag); fprintf(stderr, "Unknown subroutine tag %02x\n", abbr->tag);
data = elfSkipData(data, abbr, unit->abbrevs); data = elfSkipData(data, abbr, unit->abbrevs);
break; break;
} }
num = elfReadLEB128(data, &bytes); 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); Type *t = (Type *)calloc(sizeof(Type), 1);
t->type = TYPE_array; t->type = TYPE_array;
elfAddType(t, unit, offset); elfAddType(t, unit, offset);
for(i = 0; i < abbrev->numAttrs; i++) { for(i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data = elfReadAttribute(data, attr); data = elfReadAttribute(data, attr);
@ -1822,7 +1822,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
int maxBounds = 0; int maxBounds = 0;
while(num) { while(num) {
ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num); ELFAbbrev *abbr = elfGetAbbrev(unit->abbrevs, num);
switch(abbr->tag) { switch(abbr->tag) {
case DW_TAG_subrange_type: case DW_TAG_subrange_type:
{ {
@ -1850,7 +1850,7 @@ void elfParseType(u8 *data, u32 offset, ELFAbbrev *abbrev, CompileUnit *unit,
break; break;
default: default:
fprintf(stderr, "Unknown array tag %02x\n", abbr->tag); fprintf(stderr, "Unknown array tag %02x\n", abbr->tag);
data = elfSkipData(data, abbr, unit->abbrevs); data = elfSkipData(data, abbr, unit->abbrevs);
break; break;
} }
num = elfReadLEB128(data, &bytes); num = elfReadLEB128(data, &bytes);
@ -1895,7 +1895,7 @@ Type *elfParseType(CompileUnit *unit, u32 offset)
Type *type = NULL; Type *type = NULL;
ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
elfParseType(data, offset, abbrev, unit, &type); elfParseType(data, offset, abbrev, unit, &type);
return type; return type;
} }
@ -1906,13 +1906,13 @@ void elfGetObjectAttributes(CompileUnit *unit, u32 offset, Object *o)
int bytes; int bytes;
u32 abbrevNum = elfReadLEB128(data, &bytes); u32 abbrevNum = elfReadLEB128(data, &bytes);
data += bytes; data += bytes;
if(!abbrevNum) { if(!abbrevNum) {
return; return;
} }
ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); ELFAbbrev *abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
for(int i = 0; i < abbrev->numAttrs; i++) { for(int i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data = elfReadAttribute(data, attr); data = elfReadAttribute(data, attr);
@ -1939,7 +1939,7 @@ void elfGetObjectAttributes(CompileUnit *unit, u32 offset, Object *o)
case DW_AT_external: case DW_AT_external:
o->external = attr->flag; o->external = attr->flag;
break; break;
case DW_AT_const_value: case DW_AT_const_value:
case DW_AT_abstract_origin: case DW_AT_abstract_origin:
case DW_AT_declaration: case DW_AT_declaration:
case DW_AT_artificial: 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); fprintf(stderr, "Unknown object attribute %02x\n", attr->name);
break; break;
} }
} }
} }
u8 *elfParseObject(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit, 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: case DW_AT_abstract_origin:
elfGetObjectAttributes(unit, attr->value, o); elfGetObjectAttributes(unit, attr->value, o);
break; break;
case DW_AT_const_value: case DW_AT_const_value:
case DW_AT_declaration: case DW_AT_declaration:
case DW_AT_artificial: case DW_AT_artificial:
break; break;
@ -2013,7 +2013,7 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
int bytes; int bytes;
u32 start = func->lowPC; u32 start = func->lowPC;
u32 end = func->highPC; u32 end = func->highPC;
for(int i = 0; i < abbrev->numAttrs; i++) { for(int i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data = elfReadAttribute(data, attr); data = elfReadAttribute(data, attr);
@ -2033,26 +2033,26 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
break; break;
} }
} }
if(abbrev->hasChildren) { if(abbrev->hasChildren) {
int nesting = 1; int nesting = 1;
while(nesting) { while(nesting) {
u32 abbrevNum = elfReadLEB128(data, &bytes); u32 abbrevNum = elfReadLEB128(data, &bytes);
data += bytes; data += bytes;
if(!abbrevNum) { if(!abbrevNum) {
nesting--; nesting--;
continue; continue;
} }
abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
switch(abbrev->tag) { switch(abbrev->tag) {
CASE_TYPE_TAG: // types only parsed when used CASE_TYPE_TAG: // types only parsed when used
case DW_TAG_label: // not needed case DW_TAG_label: // not needed
data = elfSkipData(data, abbrev, unit->abbrevs); data = elfSkipData(data, abbrev, unit->abbrevs);
break; break;
case DW_TAG_lexical_block: case DW_TAG_lexical_block:
data = elfParseBlock(data, abbrev, unit, func, lastVar); data = elfParseBlock(data, abbrev, unit, func, lastVar);
break; break;
@ -2081,7 +2081,7 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
(*lastVar)->next = o; (*lastVar)->next = o;
else else
func->variables = o; func->variables = o;
*lastVar = o; *lastVar = o;
} }
break; break;
case DW_TAG_inlined_subroutine: case DW_TAG_inlined_subroutine:
@ -2091,13 +2091,13 @@ u8 *elfParseBlock(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
default: default:
{ {
fprintf(stderr, "Unknown block TAG %02x\n", abbrev->tag); fprintf(stderr, "Unknown block TAG %02x\n", abbrev->tag);
data = elfSkipData(data, abbrev, unit->abbrevs); data = elfSkipData(data, abbrev, unit->abbrevs);
} }
break; break;
} }
} }
} }
return data; return data;
} }
void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func) void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func)
@ -2106,7 +2106,7 @@ void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func)
int bytes; int bytes;
u32 abbrevNum = elfReadLEB128(data, &bytes); u32 abbrevNum = elfReadLEB128(data, &bytes);
data += bytes; data += bytes;
if(!abbrevNum) { if(!abbrevNum) {
return; return;
} }
@ -2116,10 +2116,10 @@ void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func)
for(int i = 0; i < abbrev->numAttrs; i++) { for(int i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data = elfReadAttribute(data, attr); data = elfReadAttribute(data, attr);
switch(attr->name) { switch(attr->name) {
case DW_AT_sibling: case DW_AT_sibling:
break; break;
case DW_AT_name: case DW_AT_name:
if(func->name == NULL) if(func->name == NULL)
func->name = attr->string; func->name = attr->string;
@ -2166,7 +2166,7 @@ void elfGetFunctionAttributes(CompileUnit *unit, u32 offset, Function *func)
break; break;
default: default:
fprintf(stderr, "Unknown function attribute %02x\n", attr->name); 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); Function *func = (Function *)calloc(sizeof(Function), 1);
*f = func; *f = func;
int bytes; int bytes;
bool mangled = false; bool mangled = false;
bool declaration = false; bool declaration = false;
@ -2233,7 +2233,7 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
case DW_AT_user_2002: case DW_AT_user_2002:
case DW_AT_virtuality: case DW_AT_virtuality:
case DW_AT_containing_type: case DW_AT_containing_type:
case DW_AT_accessibility: case DW_AT_accessibility:
// todo; // todo;
break; break;
case DW_AT_vtable_elem_location: case DW_AT_vtable_elem_location:
@ -2263,7 +2263,7 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
data = elfSkipData(data, abbrev, unit->abbrevs); data = elfSkipData(data, abbrev, unit->abbrevs);
} }
} }
if(abbrev->hasChildren) { if(abbrev->hasChildren) {
int nesting = 1; int nesting = 1;
Object *lastParam = NULL; Object *lastParam = NULL;
@ -2272,14 +2272,14 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
while(nesting) { while(nesting) {
u32 abbrevNum = elfReadLEB128(data, &bytes); u32 abbrevNum = elfReadLEB128(data, &bytes);
data += bytes; data += bytes;
if(!abbrevNum) { if(!abbrevNum) {
nesting--; nesting--;
continue; continue;
} }
abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum); abbrev = elfGetAbbrev(unit->abbrevs, abbrevNum);
switch(abbrev->tag) { switch(abbrev->tag) {
CASE_TYPE_TAG: // no need to parse types. only parsed when used CASE_TYPE_TAG: // no need to parse types. only parsed when used
case DW_TAG_label: // not needed 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) if(abbrev->attrs[i].form == DW_FORM_block1)
free(abbrev->attrs[i].block); free(abbrev->attrs[i].block);
} }
if(abbrev->hasChildren) if(abbrev->hasChildren)
nesting++; nesting++;
} }
@ -2342,7 +2342,7 @@ u8 *elfParseFunction(u8 *data, ELFAbbrev *abbrev, CompileUnit *unit,
default: default:
{ {
fprintf(stderr, "Unknown function TAG %02x\n", abbrev->tag); fprintf(stderr, "Unknown function TAG %02x\n", abbrev->tag);
data = elfSkipData(data, abbrev, unit->abbrevs); data = elfSkipData(data, abbrev, unit->abbrevs);
} }
break; break;
} }
@ -2358,34 +2358,34 @@ u8 *elfParseUnknownData(u8 *data, ELFAbbrev *abbrev, ELFAbbrev **abbrevs)
// switch(abbrev->tag) { // switch(abbrev->tag) {
// default: // default:
fprintf(stderr, "Unknown TAG %02x\n", abbrev->tag); fprintf(stderr, "Unknown TAG %02x\n", abbrev->tag);
for(i = 0; i < abbrev->numAttrs; i++) { for(i = 0; i < abbrev->numAttrs; i++) {
data = elfReadAttribute(data, &abbrev->attrs[i]); data = elfReadAttribute(data, &abbrev->attrs[i]);
if(abbrev->attrs[i].form == DW_FORM_block1) if(abbrev->attrs[i].form == DW_FORM_block1)
free(abbrev->attrs[i].block); free(abbrev->attrs[i].block);
} }
if(abbrev->hasChildren) { if(abbrev->hasChildren) {
int nesting = 1; int nesting = 1;
while(nesting) { while(nesting) {
u32 abbrevNum = elfReadLEB128(data, &bytes); u32 abbrevNum = elfReadLEB128(data, &bytes);
data += bytes; data += bytes;
if(!abbrevNum) { if(!abbrevNum) {
nesting--; nesting--;
continue; continue;
} }
abbrev = elfGetAbbrev(abbrevs, abbrevNum); abbrev = elfGetAbbrev(abbrevs, abbrevNum);
fprintf(stderr, "Unknown TAG %02x\n", abbrev->tag); fprintf(stderr, "Unknown TAG %02x\n", abbrev->tag);
for(i = 0; i < abbrev->numAttrs; i++) { for(i = 0; i < abbrev->numAttrs; i++) {
data = elfReadAttribute(data, &abbrev->attrs[i]); data = elfReadAttribute(data, &abbrev->attrs[i]);
if(abbrev->attrs[i].form == DW_FORM_block1) if(abbrev->attrs[i].form == DW_FORM_block1)
free(abbrev->attrs[i].block); free(abbrev->attrs[i].block);
} }
if(abbrev->hasChildren) { if(abbrev->hasChildren) {
nesting++; nesting++;
} }
@ -2435,7 +2435,7 @@ u8 *elfParseCompileUnitChildren(u8 *data, CompileUnit *unit)
data = elfParseUnknownData(data, abbrev, unit->abbrevs); data = elfParseUnknownData(data, abbrev, unit->abbrevs);
break; break;
} }
abbrevNum = elfReadLEB128(data, &bytes); abbrevNum = elfReadLEB128(data, &bytes);
data += bytes; data += bytes;
} }
@ -2447,23 +2447,23 @@ CompileUnit *elfParseCompUnit(u8 *data, u8 *abbrevData)
{ {
int bytes; int bytes;
u8 *top = data; u8 *top = data;
u32 length = elfRead4Bytes(data); u32 length = elfRead4Bytes(data);
data += 4; data += 4;
u16 version = elfRead2Bytes(data); u16 version = elfRead2Bytes(data);
data += 2; data += 2;
u32 offset = elfRead4Bytes(data); u32 offset = elfRead4Bytes(data);
data += 4; data += 4;
u8 addrSize = *data++; u8 addrSize = *data++;
if(version != 2) { if(version != 2) {
fprintf(stderr, "Unsupported debugging information version %d\n", version); fprintf(stderr, "Unsupported debugging information version %d\n", version);
return NULL; return NULL;
} }
if(addrSize != 4) { if(addrSize != 4) {
fprintf(stderr, "Unsupported address size %d\n", addrSize); fprintf(stderr, "Unsupported address size %d\n", addrSize);
return NULL; return NULL;
@ -2483,9 +2483,9 @@ CompileUnit *elfParseCompUnit(u8 *data, u8 *abbrevData)
unit->next = NULL; unit->next = NULL;
elfCurrentUnit = unit; elfCurrentUnit = unit;
int i; int i;
for(i = 0; i < abbrev->numAttrs; i++) { for(i = 0; i < abbrev->numAttrs; i++) {
ELFAttr *attr = &abbrev->attrs[i]; ELFAttr *attr = &abbrev->attrs[i];
data = elfReadAttribute(data, attr); data = elfReadAttribute(data, attr);
@ -2540,7 +2540,7 @@ void elfParseAranges(u8 *data)
ARanges *ranges = (ARanges *)calloc(sizeof(ARanges), 4); ARanges *ranges = (ARanges *)calloc(sizeof(ARanges), 4);
int index = 0; int index = 0;
while(data < end) { while(data < end) {
u32 len = elfRead4Bytes(data); u32 len = elfRead4Bytes(data);
data += 4; data += 4;
@ -2583,7 +2583,7 @@ void elfReadSymtab(u8 *data)
int table = READ32LE(&sh->link); int table = READ32LE(&sh->link);
char *strtable = (char *)elfReadSection(data, elfGetSectionByNumber(table)); char *strtable = (char *)elfReadSection(data, elfGetSectionByNumber(table));
ELFSymbol *symtab = (ELFSymbol *)elfReadSection(data, sh); ELFSymbol *symtab = (ELFSymbol *)elfReadSection(data, sh);
int count = READ32LE(&sh->size) / sizeof(ELFSymbol); int count = READ32LE(&sh->size) / sizeof(ELFSymbol);
@ -2592,7 +2592,7 @@ void elfReadSymtab(u8 *data)
elfSymbols = (Symbol *)malloc(sizeof(Symbol)*count); elfSymbols = (Symbol *)malloc(sizeof(Symbol)*count);
int i; int i;
for(i = 0; i < count; i++) { for(i = 0; i < count; i++) {
ELFSymbol *s = &symtab[i]; ELFSymbol *s = &symtab[i];
int type = s->info & 15; int type = s->info & 15;
@ -2622,7 +2622,7 @@ void elfReadSymtab(u8 *data)
sym->size = READ32LE(&s->size); sym->size = READ32LE(&s->size);
elfSymbolsCount++; elfSymbolsCount++;
} }
} }
elfSymbolsStrTab = strtable; elfSymbolsStrTab = strtable;
// free(symtab); // free(symtab);
} }
@ -2631,7 +2631,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
{ {
int count = READ16LE(&eh->e_phnum); int count = READ16LE(&eh->e_phnum);
int i; int i;
if(READ32LE(&eh->e_entry) == 0x2000000) if(READ32LE(&eh->e_entry) == 0x2000000)
cpuIsMultiBoot = true; cpuIsMultiBoot = true;
@ -2655,7 +2655,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
data + READ32LE(&ph->offset), data + READ32LE(&ph->offset),
READ32LE(&ph->filesz)); READ32LE(&ph->filesz));
size += READ32LE(&ph->filesz); size += READ32LE(&ph->filesz);
} }
} else { } else {
if(READ32LE(&ph->paddr) >= 0x8000000 && if(READ32LE(&ph->paddr) >= 0x8000000 &&
READ32LE(&ph->paddr) <= 0x9ffffff) { READ32LE(&ph->paddr) <= 0x9ffffff) {
@ -2675,7 +2675,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
ELFSectionHeader **sh = (ELFSectionHeader **) ELFSectionHeader **sh = (ELFSectionHeader **)
malloc(sizeof(ELFSectionHeader *) * count); malloc(sizeof(ELFSectionHeader *) * count);
for(i = 0; i < count; i++) { for(i = 0; i < count; i++) {
sh[i] = (ELFSectionHeader *)p; sh[i] = (ELFSectionHeader *)p;
p += sizeof(ELFSectionHeader); p += sizeof(ELFSectionHeader);
@ -2687,7 +2687,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
stringTable = (char *)elfReadSection(data, stringTable = (char *)elfReadSection(data,
sh[READ16LE(&eh->e_shstrndx)]); sh[READ16LE(&eh->e_shstrndx)]);
} }
elfSectionHeaders = sh; elfSectionHeaders = sh;
elfSectionHeadersStringTable = stringTable; elfSectionHeadersStringTable = stringTable;
elfSectionHeadersCount = count; elfSectionHeadersCount = count;
@ -2705,7 +2705,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
READ32LE(&sh[i]->offset), READ32LE(&sh[i]->offset),
READ32LE(&sh[i]->size)); READ32LE(&sh[i]->size));
size += READ32LE(&sh[i]->size); size += READ32LE(&sh[i]->size);
} }
} else { } else {
if(READ32LE(&sh[i]->addr) >= 0x8000000 && if(READ32LE(&sh[i]->addr) >= 0x8000000 &&
READ32LE(&sh[i]->addr) <= 0x9ffffff) { READ32LE(&sh[i]->addr) <= 0x9ffffff) {
@ -2714,7 +2714,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
READ32LE(&sh[i]->size)); READ32LE(&sh[i]->size));
size += 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"); ELFSectionHeader *dbgHeader = elfGetSectionByName(".debug_info");
if(dbgHeader == NULL) { if(dbgHeader == NULL) {
fprintf(stderr, "Cannot find debug information\n"); fprintf(stderr, "Cannot find debug information\n");
goto end; goto end;
} }
ELFSectionHeader *h = elfGetSectionByName(".debug_abbrev"); 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"); fprintf(stderr, "Cannot find abbreviation table\n");
goto end; goto end;
} }
elfDebugInfo = (DebugInfo *)calloc(sizeof(DebugInfo), 1); elfDebugInfo = (DebugInfo *)calloc(sizeof(DebugInfo), 1);
u8 *abbrevdata = elfReadSection(data, h); u8 *abbrevdata = elfReadSection(data, h);
@ -2742,19 +2742,19 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
elfDebugStrings = NULL; elfDebugStrings = NULL;
else else
elfDebugStrings = (char *)elfReadSection(data, h); elfDebugStrings = (char *)elfReadSection(data, h);
u8 *debugdata = elfReadSection(data, dbgHeader); u8 *debugdata = elfReadSection(data, dbgHeader);
elfDebugInfo->debugdata = data; elfDebugInfo->debugdata = data;
elfDebugInfo->infodata = debugdata; elfDebugInfo->infodata = debugdata;
u32 total = READ32LE(&dbgHeader->size); u32 total = READ32LE(&dbgHeader->size);
u8 *end = debugdata + total; u8 *end = debugdata + total;
u8 *ddata = debugdata; u8 *ddata = debugdata;
CompileUnit *last = NULL; CompileUnit *last = NULL;
CompileUnit *unit = NULL; CompileUnit *unit = NULL;
while(ddata < end) { while(ddata < end) {
unit = elfParseCompUnit(ddata, abbrevdata); unit = elfParseCompUnit(ddata, abbrevdata);
unit->offset = (u32)(ddata-debugdata); unit->offset = (u32)(ddata-debugdata);
@ -2780,7 +2780,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
elfParseCFA(data); elfParseCFA(data);
elfReadSymtab(data); elfReadSymtab(data);
} }
end: end:
if(sh) { if(sh) {
free(sh); free(sh);
} }
@ -2788,7 +2788,7 @@ bool elfReadProgram(ELFHeader *eh, u8 *data, int& size, bool parseDebug)
elfSectionHeaders = NULL; elfSectionHeaders = NULL;
elfSectionHeadersStringTable = NULL; elfSectionHeadersStringTable = NULL;
elfSectionHeadersCount = 0; elfSectionHeadersCount = 0;
return true; return true;
} }
@ -2802,9 +2802,9 @@ bool elfRead(const char *name, int& siz, FILE *f)
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
fread(elfFileData, 1, size, f); fread(elfFileData, 1, size, f);
fclose(f); fclose(f);
ELFHeader *header = (ELFHeader *)elfFileData; ELFHeader *header = (ELFHeader *)elfFileData;
if(READ32LE(&header->magic) != 0x464C457F || if(READ32LE(&header->magic) != 0x464C457F ||
READ16LE(&header->e_machine) != 40 || READ16LE(&header->e_machine) != 40 ||
header->clazz != 1) { header->clazz != 1) {
@ -2819,7 +2819,7 @@ bool elfRead(const char *name, int& siz, FILE *f)
elfFileData = NULL; elfFileData = NULL;
return false; return false;
} }
return true; return true;
} }
@ -2857,7 +2857,7 @@ void elfCleanUp(ELFAbbrev **abbrevs)
free(abbrev->attrs); free(abbrev->attrs);
ELFAbbrev *next = abbrev->next; ELFAbbrev *next = abbrev->next;
free(abbrev); free(abbrev);
abbrev = next; abbrev = next;
} }
} }
@ -2875,7 +2875,7 @@ void elfCleanUp(Type *t)
free(o); free(o);
o = next; o = next;
} }
free(t->function); free(t->function);
} }
break; break;
case TYPE_array: case TYPE_array:
@ -2974,7 +2974,7 @@ void elfCleanUp()
free(elfFdes[i]); free(elfFdes[i]);
} }
free(elfFdes); free(elfFdes);
elfFdes = NULL; elfFdes = NULL;
elfFdeCount = 0; elfFdeCount = 0;
} }

View File

@ -206,7 +206,7 @@ struct Function {
struct LineInfoItem { struct LineInfoItem {
u32 address; u32 address;
char *file; char *file;
int line; int line;
}; };
@ -235,7 +235,7 @@ struct CompileUnit {
ELFAbbrev **abbrevs; ELFAbbrev **abbrevs;
ARanges *ranges; ARanges *ranges;
char *name; char *name;
char *compdir; char *compdir;
u32 lowPC; u32 lowPC;
u32 highPC; u32 highPC;
bool hasLineInfo; bool hasLineInfo;
@ -245,7 +245,7 @@ struct CompileUnit {
Function *lastFunction; Function *lastFunction;
Object *variables; Object *variables;
Type *types; Type *types;
CompileUnit *next; CompileUnit *next;
}; };
struct DebugInfo { struct DebugInfo {

View File

@ -662,7 +662,7 @@ YY_RULE_SETUP
#line 45 "expr.l" #line 45 "expr.l"
{ {
return TOKEN_DOT; return TOKEN_DOT;
} }
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP

View File

@ -14,7 +14,7 @@
#line 1 "expr.y" #line 1 "expr.y"
namespace std { namespace std {
#include <stdio.h> #include <stdio.h>
#include <memory.h> #include <memory.h>
#include <stdlib.h> #include <stdlib.h>
@ -22,16 +22,16 @@ namespace std {
} }
using namespace std; using namespace std;
#include "System.h" #include "System.h"
#include "elf.h" #include "elf.h"
#include "exprNode.h" #include "exprNode.h"
extern int yyerror(char *); extern int yyerror(char *);
extern int yylex(); extern int yylex();
extern char *yytext; extern char *yytext;
//#define YYERROR_VERBOSE 1 //#define YYERROR_VERBOSE 1
//#define YYDEBUG 1 //#define YYDEBUG 1

View File

@ -56,9 +56,9 @@ Node *exprNodeIdentifier()
Node *n = (Node *)calloc(1, sizeof(Node)); Node *n = (Node *)calloc(1, sizeof(Node));
n->name = strdup(yytext); n->name = strdup(yytext);
exprNodeClean(n->name); exprNodeClean(n->name);
exprNodeClean(n); exprNodeClean(n);
n->print = exprNodeIdentifierPrint; n->print = exprNodeIdentifierPrint;
n->resolve = exprNodeIdentifierResolve; n->resolve = exprNodeIdentifierResolve;
return n; return n;
@ -89,7 +89,7 @@ Node *exprNodeNumber()
exprNodeClean(n); exprNodeClean(n);
n->location = atoi(yytext); n->location = atoi(yytext);
n->type = &exprNodeType; n->type = &exprNodeType;
n->locType = LOCATION_value; n->locType = LOCATION_value;
n->print = exprNodeNumberPrint; n->print = exprNodeNumberPrint;
n->resolve = exprNodeNumberResolve; n->resolve = exprNodeNumberResolve;
return n; return n;
@ -109,9 +109,9 @@ Node *exprNodeStar(Node *exp)
{ {
Node *n = (Node *)calloc(1, sizeof(Node)); Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n); exprNodeClean(n);
n->expression = exp; n->expression = exp;
n->print = exprNodeStarPrint; n->print = exprNodeStarPrint;
n->resolve = exprNodeStarResolve; n->resolve = exprNodeStarResolve;
return n; return n;
@ -149,10 +149,10 @@ Node *exprNodeDot(Node *exp, Node *ident)
{ {
Node *n = (Node *)calloc(1, sizeof(Node)); Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n); exprNodeClean(n);
n->expression = exp; n->expression = exp;
n->name = ident->name; n->name = ident->name;
n->print = exprNodeDotPrint; n->print = exprNodeDotPrint;
n->resolve = exprNodeDotResolve; n->resolve = exprNodeDotResolve;
return n; return n;
@ -162,7 +162,7 @@ bool exprNodeDotResolve(Node *n, Function *f, CompileUnit *u)
{ {
if(n->expression->resolve(n->expression, f, u)) { if(n->expression->resolve(n->expression, f, u)) {
TypeEnum tt = n->expression->type->type; TypeEnum tt = n->expression->type->type;
if(tt == TYPE_struct || if(tt == TYPE_struct ||
tt == TYPE_union) { tt == TYPE_union) {
u32 loc = n->expression->location; u32 loc = n->expression->location;
@ -206,10 +206,10 @@ Node *exprNodeArrow(Node *exp, Node *ident)
{ {
Node *n = (Node *)calloc(1, sizeof(Node)); Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n); exprNodeClean(n);
n->expression = exp; n->expression = exp;
n->name = ident->name; n->name = ident->name;
n->print = exprNodeArrowPrint; n->print = exprNodeArrowPrint;
n->resolve = exprNodeArrowResolve; n->resolve = exprNodeArrowResolve;
return n; return n;
@ -224,7 +224,7 @@ bool exprNodeArrowResolve(Node *n, Function *f, CompileUnit *u)
return false; return false;
} }
tt = n->expression->type->pointer->type; tt = n->expression->type->pointer->type;
if(tt == TYPE_struct || if(tt == TYPE_struct ||
tt == TYPE_union) { tt == TYPE_union) {
u32 loc = debuggerReadMemory(n->expression->location); u32 loc = debuggerReadMemory(n->expression->location);
@ -268,9 +268,9 @@ Node *exprNodeAddr(Node *exp)
{ {
Node *n = (Node *)calloc(1, sizeof(Node)); Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n); exprNodeClean(n);
n->expression = exp; n->expression = exp;
n->print = exprNodeAddrPrint; n->print = exprNodeAddrPrint;
n->resolve = exprNodeAddrResolve; n->resolve = exprNodeAddrResolve;
return n; return n;
@ -303,9 +303,9 @@ Node *exprNodeSizeof(Node *exp)
{ {
Node *n = (Node *)calloc(1, sizeof(Node)); Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n); exprNodeClean(n);
n->expression = exp; n->expression = exp;
n->print = exprNodeSizeofPrint; n->print = exprNodeSizeofPrint;
n->resolve = exprNodeSizeofResolve; n->resolve = exprNodeSizeofResolve;
return n; return n;
@ -333,10 +333,10 @@ Node *exprNodeArray(Node *exp, Node *number)
{ {
Node *n = (Node *)calloc(1, sizeof(Node)); Node *n = (Node *)calloc(1, sizeof(Node));
exprNodeClean(n); exprNodeClean(n);
n->expression = exp; n->expression = exp;
n->value = number->location; n->value = number->location;
n->print = exprNodeArrayPrint; n->print = exprNodeArrayPrint;
n->resolve = exprNodeArrayResolve; n->resolve = exprNodeArrayResolve;
return n; return n;
@ -349,7 +349,7 @@ int exprNodeGetSize(Array *a, int index)
return a->type->size; return a->type->size;
} else { } else {
int size = a->bounds[a->maxBounds-1] * a->type->size; int size = a->bounds[a->maxBounds-1] * a->type->size;
for(int i = index; i < a->maxBounds-1; i++) { for(int i = index; i < a->maxBounds-1; i++) {
size *= a->bounds[i]; size *= a->bounds[i];
} }
@ -369,7 +369,7 @@ bool exprNodeArrayResolve(Node *n, Function *f, CompileUnit *u)
if(tt == TYPE_array) { if(tt == TYPE_array) {
Array *a = n->expression->type->array; Array *a = n->expression->type->array;
u32 loc = n->expression->location; u32 loc = n->expression->location;
Type *t = a->type; Type *t = a->type;
if(a->maxBounds > 1) { if(a->maxBounds > 1) {

File diff suppressed because it is too large Load Diff

View File

@ -69,9 +69,9 @@ void gbCheatsReadGame(gzFile gzFile, int version)
gbAddGgCheat(tmpCheat.cheatCode, tmpCheat.cheatDesc); gbAddGgCheat(tmpCheat.cheatCode, tmpCheat.cheatDesc);
} }
} }
int gbGsOn = utilReadInt(gzFile); int gbGsOn = utilReadInt(gzFile);
if(gbGsOn) { if(gbGsOn) {
int n = utilReadInt(gzFile); int n = utilReadInt(gzFile);
gbXxCheat tmpCheat; gbXxCheat tmpCheat;
@ -112,7 +112,7 @@ bool gbCheatsLoadCheatList(const char *file)
gbCheatNumber = 0; gbCheatNumber = 0;
gbCheatUpdateMap(); gbCheatUpdateMap();
int count = 0; int count = 0;
FILE *f = fopen(file, "rb"); FILE *f = fopen(file, "rb");
@ -126,7 +126,7 @@ bool gbCheatsLoadCheatList(const char *file)
fclose(f); fclose(f);
return false; return false;
} }
if(version != 1) { if(version != 1) {
systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_VERSION, systemMessage(MSG_UNSUPPORTED_CHEAT_LIST_VERSION,
N_("Unsupported cheat list version %d"), version); N_("Unsupported cheat list version %d"), version);
@ -146,12 +146,12 @@ bool gbCheatsLoadCheatList(const char *file)
fclose(f); fclose(f);
return false; return false;
} }
if(fread(&count, 1, sizeof(count), f) != sizeof(count)) { if(fread(&count, 1, sizeof(count), f) != sizeof(count)) {
fclose(f); fclose(f);
return false; return false;
} }
if(fread(gbCheatList, 1, sizeof(gbCheatList), f) != sizeof(gbCheatList)) { if(fread(gbCheatList, 1, sizeof(gbCheatList), f) != sizeof(gbCheatList)) {
fclose(f); fclose(f);
return false; return false;
@ -159,7 +159,7 @@ bool gbCheatsLoadCheatList(const char *file)
gbCheatNumber = count; gbCheatNumber = count;
gbCheatUpdateMap(); gbCheatUpdateMap();
return true; return true;
} }
@ -169,7 +169,7 @@ bool gbVerifyGsCode(const char *code)
if(len == 0) if(len == 0)
return true; return true;
if(len != 8) if(len != 8)
return false; return false;
@ -198,12 +198,12 @@ void gbAddGsCheat(const char *code, const char *desc)
N_("Invalid GameShark code: %s"), code); N_("Invalid GameShark code: %s"), code);
return; return;
} }
int i = gbCheatNumber; int i = gbCheatNumber;
strcpy(gbCheatList[i].cheatCode, code); strcpy(gbCheatList[i].cheatCode, code);
strcpy(gbCheatList[i].cheatDesc, desc); strcpy(gbCheatList[i].cheatDesc, desc);
gbCheatList[i].code = GBCHEAT_HEX_VALUE(code[0]) << 4 | gbCheatList[i].code = GBCHEAT_HEX_VALUE(code[0]) << 4 |
GBCHEAT_HEX_VALUE(code[1]); GBCHEAT_HEX_VALUE(code[1]);
@ -244,7 +244,7 @@ bool gbVerifyGgCode(const char *code)
if(len == 0) if(len == 0)
return true; return true;
if(!GBCHEAT_IS_HEX(code[0])) if(!GBCHEAT_IS_HEX(code[0]))
return false; return false;
if(!GBCHEAT_IS_HEX(code[1])) if(!GBCHEAT_IS_HEX(code[1]))
@ -296,7 +296,7 @@ bool gbVerifyGgCode(const char *code)
compare ^= 0x45; compare ^= 0x45;
int cloak = (GBCHEAT_HEX_VALUE(code[8])) ^ (GBCHEAT_HEX_VALUE(code[9])); int cloak = (GBCHEAT_HEX_VALUE(code[8])) ^ (GBCHEAT_HEX_VALUE(code[9]));
if(cloak >=1 && cloak <= 7) if(cloak >=1 && cloak <= 7)
return false; return false;
@ -316,27 +316,27 @@ void gbAddGgCheat(const char *code, const char *desc)
N_("Invalid GameGenie code: %s"), code); N_("Invalid GameGenie code: %s"), code);
return; return;
} }
int i = gbCheatNumber; int i = gbCheatNumber;
size_t len = strlen(code); size_t len = strlen(code);
strcpy(gbCheatList[i].cheatCode, code); strcpy(gbCheatList[i].cheatCode, code);
strcpy(gbCheatList[i].cheatDesc, desc); strcpy(gbCheatList[i].cheatDesc, desc);
gbCheatList[i].code = 0x101; gbCheatList[i].code = 0x101;
gbCheatList[i].value = (GBCHEAT_HEX_VALUE(code[0]) << 4) + gbCheatList[i].value = (GBCHEAT_HEX_VALUE(code[0]) << 4) +
GBCHEAT_HEX_VALUE(code[1]); GBCHEAT_HEX_VALUE(code[1]);
gbCheatList[i].address = (GBCHEAT_HEX_VALUE(code[2]) << 8) + gbCheatList[i].address = (GBCHEAT_HEX_VALUE(code[2]) << 8) +
(GBCHEAT_HEX_VALUE(code[4]) << 4) + (GBCHEAT_HEX_VALUE(code[4]) << 4) +
(GBCHEAT_HEX_VALUE(code[5])) + (GBCHEAT_HEX_VALUE(code[5])) +
((GBCHEAT_HEX_VALUE(code[6]) ^ 0x0f) << 12); ((GBCHEAT_HEX_VALUE(code[6]) ^ 0x0f) << 12);
gbCheatList[i].compare = 0; gbCheatList[i].compare = 0;
if(len != 7 && len != 8) { if(len != 7 && len != 8) {
int compare = (GBCHEAT_HEX_VALUE(code[8]) << 4) + int compare = (GBCHEAT_HEX_VALUE(code[8]) << 4) +
(GBCHEAT_HEX_VALUE(code[10])); (GBCHEAT_HEX_VALUE(code[10]));
compare = compare ^ 0xff; compare = compare ^ 0xff;
@ -351,9 +351,9 @@ void gbAddGgCheat(const char *code, const char *desc)
gbCheatList[i].enabled = true; gbCheatList[i].enabled = true;
gbCheatMap[gbCheatList[i].address] = true; gbCheatMap[gbCheatList[i].address] = true;
gbCheatNumber++; gbCheatNumber++;
} }
@ -364,12 +364,12 @@ void gbCheatRemove(int i)
N_("Invalid cheat to remove %d"), i); N_("Invalid cheat to remove %d"), i);
return; return;
} }
if((i+1) < gbCheatNumber) { if((i+1) < gbCheatNumber) {
memcpy(&gbCheatList[i], &gbCheatList[i+1], sizeof(gbCheat)* memcpy(&gbCheatList[i], &gbCheatList[i+1], sizeof(gbCheat)*
(gbCheatNumber-i-1)); (gbCheatNumber-i-1));
} }
gbCheatNumber--; gbCheatNumber--;
gbCheatUpdateMap(); gbCheatUpdateMap();
@ -404,12 +404,12 @@ void gbCheatDisable(int i)
bool gbCheatReadGSCodeFile(const char *fileName) bool gbCheatReadGSCodeFile(const char *fileName)
{ {
FILE *file = fopen(fileName, "rb"); FILE *file = fopen(fileName, "rb");
if(!file) { if(!file) {
systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), fileName); systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s"), fileName);
return false; return false;
} }
fseek(file, 0x18, SEEK_SET); fseek(file, 0x18, SEEK_SET);
int count = 0; int count = 0;
fread(&count, 1, 2, file); fread(&count, 1, 2, file);
@ -419,7 +419,7 @@ bool gbCheatReadGSCodeFile(const char *fileName)
char code[9]; char code[9];
int i; int i;
for(i = 0; i < count; i++) { for(i = 0; i < count; i++) {
fread(&dummy, 1, 2, file); fread(&dummy, 1, 2, file);
fread(desc, 1, 12, file); fread(desc, 1, 12, file);
desc[12] = 0; desc[12] = 0;
fread(code, 1, 8, file); fread(code, 1, 8, file);

View File

@ -17,10 +17,10 @@
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
case 0x00: case 0x00:
// NOP // NOP
break; break;
case 0x01: case 0x01:
// LD BC, NNNN // LD BC, NNNN
BC.B.B0=gbReadOpcode(PC.W++); BC.B.B0=gbReadOpcode(PC.W++);
BC.B.B1=gbReadOpcode(PC.W++); BC.B.B1=gbReadOpcode(PC.W++);
@ -33,14 +33,14 @@
// INC BC // INC BC
BC.W++; BC.W++;
break; break;
case 0x04: case 0x04:
// INC B // 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); AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B1]| (BC.B.B1&0x0F? 0:H_FLAG);
break; break;
case 0x05: case 0x05:
// DEC B // DEC B
BC.B.B1--; BC.B.B1--;
AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[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); ((BC.B.B1&0x0F)==0x0F? H_FLAG:0);
break; break;
@ -75,7 +75,7 @@
case 0x0b: case 0x0b:
// DEC BC // DEC BC
BC.W--; BC.W--;
break; break;
case 0x0c: case 0x0c:
// INC C // INC C
BC.B.B0++; BC.B.B0++;
@ -86,7 +86,7 @@
BC.B.B0--; BC.B.B0--;
AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[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); ((BC.B.B0&0x0F)==0x0F? H_FLAG:0);
break; break;
case 0x0e: case 0x0e:
// LD C, NN // LD C, NN
BC.B.B0=gbReadOpcode(PC.W++); BC.B.B0=gbReadOpcode(PC.W++);
@ -102,10 +102,10 @@
opcode = gbReadOpcode(PC.W++); opcode = gbReadOpcode(PC.W++);
if(gbCgbMode) { if(gbCgbMode) {
if(gbMemory[0xff4d] & 1) { if(gbMemory[0xff4d] & 1) {
gbSpeedSwitch(); gbSpeedSwitch();
//clockTicks += 228*144-(gbSpeed ? 62 : 63); //clockTicks += 228*144-(gbSpeed ? 62 : 63);
if(gbSpeed == 0) if(gbSpeed == 0)
gbMemory[0xff4d] = 0x00; gbMemory[0xff4d] = 0x00;
else else
@ -161,7 +161,7 @@
case 0x1a: case 0x1a:
// LD A,(DE) // LD A,(DE)
AF.B.B1=gbReadMemory(DE.W); AF.B.B1=gbReadMemory(DE.W);
break; break;
case 0x1b: case 0x1b:
// DEC DE // DEC DE
DE.W--; DE.W--;
@ -180,7 +180,7 @@
case 0x1e: case 0x1e:
// LD E,NN // LD E,NN
DE.B.B0=gbReadOpcode(PC.W++); DE.B.B0=gbReadOpcode(PC.W++);
break; break;
case 0x1f: case 0x1f:
// RRA // RRA
tempValue=AF.B.B1&0x01; tempValue=AF.B.B1&0x01;
@ -200,7 +200,7 @@
// LD HL,NNNN // LD HL,NNNN
HL.B.B0=gbReadOpcode(PC.W++); HL.B.B0=gbReadOpcode(PC.W++);
HL.B.B1=gbReadOpcode(PC.W++); HL.B.B1=gbReadOpcode(PC.W++);
break; break;
case 0x22: case 0x22:
// LDI (HL),A // LDI (HL),A
gbWriteMemory(HL.W++,AF.B.B1); gbWriteMemory(HL.W++,AF.B.B1);
@ -254,7 +254,7 @@
case 0x2b: case 0x2b:
// DEC HL // DEC HL
HL.W--; HL.W--;
break; break;
case 0x2c: case 0x2c:
// INC L // INC L
HL.B.B0++; HL.B.B0++;
@ -269,7 +269,7 @@
case 0x2e: case 0x2e:
// LD L,NN // LD L,NN
HL.B.B0=gbReadOpcode(PC.W++); HL.B.B0=gbReadOpcode(PC.W++);
break; break;
case 0x2f: case 0x2f:
// CPL // CPL
AF.B.B1 ^= 255; AF.B.B1 ^= 255;
@ -316,7 +316,7 @@
case 0x37: case 0x37:
// SCF // SCF
AF.B.B0 = AF.B.B0 & Z_FLAG | C_FLAG; AF.B.B0 = AF.B.B0 & Z_FLAG | C_FLAG;
break; break;
case 0x38: case 0x38:
// JR C,NN // JR C,NN
if(AF.B.B0&C_FLAG) { if(AF.B.B0&C_FLAG) {
@ -587,7 +587,7 @@ case 0x38:
} }
else else
{ {
// if (IE & IF) and interrupts are disabeld, // if (IE & IF) and interrupts are disabeld,
// Halt is cancelled. // Halt is cancelled.
if ((register_IE & register_IF & 0x1f) && !(IFF & 1)) if ((register_IE & register_IF & 0x1f) && !(IFF & 1))
{ {
@ -1309,7 +1309,7 @@ case 0x38:
case 0xe8: case 0xe8:
// ADD SP,NN // ADD SP,NN
offset = (s8)gbReadOpcode(PC.W++); offset = (s8)gbReadOpcode(PC.W++);
if(offset >= 0) { if(offset >= 0) {
tempRegister.W = SP.W + offset; tempRegister.W = SP.W + offset;
AF.B.B0 = (SP.W > tempRegister.W ? C_FLAG : 0) | AF.B.B0 = (SP.W > tempRegister.W ? C_FLAG : 0) |

View File

@ -160,7 +160,7 @@ int gbDis(char *buffer, u16 address)
u16 addr = address; u16 addr = address;
sprintf(p, "%04x ", address); sprintf(p, "%04x ", address);
p += 12; p += 12;
u8 opcode = GB_READ(address); u8 opcode = GB_READ(address);
address++; address++;
const char *mnen; const char *mnen;
@ -175,7 +175,7 @@ int gbDis(char *buffer, u16 address)
} }
while(op->value != (opcode & op->mask)) op++; while(op->value != (opcode & op->mask)) op++;
mnen = op->mnen; mnen = op->mnen;
u8 b0, b1; u8 b0, b1;
s8 disp; s8 disp;
int shift; int shift;

View File

@ -73,7 +73,7 @@ void gbRenderLine()
bank0 = &gbMemory[0x8000]; bank0 = &gbMemory[0x8000];
bank1 = NULL; bank1 = NULL;
} }
int tile_map = 0x1800; int tile_map = 0x1800;
if((register_LCDC & 8) != 0) if((register_LCDC & 8) != 0)
tile_map = 0x1c00; tile_map = 0x1c00;
@ -82,7 +82,7 @@ void gbRenderLine()
if((register_LCDC & 16) != 0) if((register_LCDC & 16) != 0)
tile_pattern = 0x0000; tile_pattern = 0x0000;
int x = 0; int x = 0;
int y = register_LY; int y = register_LY;
@ -96,7 +96,7 @@ void gbRenderLine()
sy+=y; sy+=y;
sy &= 255; sy &= 255;
int tx = sx >> 3; int tx = sx >> 3;
int ty = sy >> 3; int ty = sy >> 3;
@ -104,17 +104,17 @@ void gbRenderLine()
int by = sy & 7; int by = sy & 7;
int tile_map_line_y = tile_map + ty * 32; int tile_map_line_y = tile_map + ty * 32;
int tile_map_address = tile_map_line_y + tx; int tile_map_address = tile_map_line_y + tx;
u8 attrs = 0; u8 attrs = 0;
if(bank1 != NULL) if(bank1 != NULL)
attrs = bank1[tile_map_address]; attrs = bank1[tile_map_address];
u8 tile = bank0[tile_map_address]; u8 tile = bank0[tile_map_address];
tile_map_address++; tile_map_address++;
if(!(register_LCDC & 0x10)) if(!(register_LCDC & 0x10))
tile ^= 0x80; tile ^= 0x80;
@ -128,11 +128,11 @@ void gbRenderLine()
u8 tile_a = 0; u8 tile_a = 0;
u8 tile_b = 0; u8 tile_b = 0;
if(attrs & 0x40) { if(attrs & 0x40) {
tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2; tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2;
} }
if(attrs & 0x08) { if(attrs & 0x08) {
tile_a = bank1[tile_pattern_address++]; tile_a = bank1[tile_pattern_address++];
tile_b = bank1[tile_pattern_address]; tile_b = bank1[tile_pattern_address];
@ -140,34 +140,34 @@ void gbRenderLine()
tile_a = bank0[tile_pattern_address++]; tile_a = bank0[tile_pattern_address++];
tile_b = bank0[tile_pattern_address]; tile_b = bank0[tile_pattern_address];
} }
if(attrs & 0x20) { if(attrs & 0x20) {
tile_a = gbInvertTab[tile_a]; tile_a = gbInvertTab[tile_a];
tile_b = gbInvertTab[tile_b]; tile_b = gbInvertTab[tile_b];
} }
while(bx > 0) { while(bx > 0) {
u8 c = (tile_a & bx) ? 1 : 0; u8 c = (tile_a & bx) ? 1 : 0;
c += ((tile_b & bx) ? 2 : 0); c += ((tile_b & bx) ? 2 : 0);
gbLineBuffer[x] = c; // mark the gbLineBuffer color gbLineBuffer[x] = c; // mark the gbLineBuffer color
if(attrs & 0x80) if(attrs & 0x80)
gbLineBuffer[x] |= 0x300; gbLineBuffer[x] |= 0x300;
if(gbCgbMode) { if(gbCgbMode) {
c = c + (attrs & 7)*4; c = c + (attrs & 7)*4;
} else { } else {
c = (gbBgpLine[x+(gbSpeed ? 5 : 11)+SpritesTicks]>>(c<<1)) &3; c = (gbBgpLine[x+(gbSpeed ? 5 : 11)+SpritesTicks]>>(c<<1)) &3;
if(gbSgbMode && !gbCgbMode) { if(gbSgbMode && !gbCgbMode) {
int dx = x >> 3; int dx = x >> 3;
int dy = y >> 3; int dy = y >> 3;
int palette = gbSgbATF[dy * 20 + dx]; int palette = gbSgbATF[dy * 20 + dx];
if(c == 0) if(c == 0)
palette = 0; palette = 0;
c = c + 4*palette; c = c + 4*palette;
} }
} }
@ -178,9 +178,9 @@ void gbRenderLine()
break; break;
bx >>= 1; bx >>= 1;
} }
bx = 128; bx = 128;
SpritesTicks = gbSpritesTicks[x]*(gbSpeed ? 2 : 4); SpritesTicks = gbSpritesTicks[x]*(gbSpeed ? 2 : 4);
sx = gbSCXLine[x+(gbSpeed ? 0 : 4)+SpritesTicks]; sx = gbSCXLine[x+(gbSpeed ? 0 : 4)+SpritesTicks];
@ -188,7 +188,7 @@ void gbRenderLine()
sy = gbSCYLine[x+(gbSpeed ? 11 : 5)+SpritesTicks]; sy = gbSCYLine[x+(gbSpeed ? 11 : 5)+SpritesTicks];
tx = ((sx+x)>>3) & 0x1f; tx = ((sx+x)>>3) & 0x1f;
sy+=y; sy+=y;
@ -206,7 +206,7 @@ void gbRenderLine()
if(bank1) if(bank1)
attrs = bank1[tile_map_line_y + tx]; attrs = bank1[tile_map_line_y + tx];
tile = bank0[tile_map_line_y + tx]; tile = bank0[tile_map_line_y + tx];
if(!(register_LCDC & 0x10)) if(!(register_LCDC & 0x10))
@ -229,7 +229,7 @@ void gbRenderLine()
gbLineBuffer[i] = 0; gbLineBuffer[i] = 0;
} }
} }
// do the window display // do the window display
// LCDC.0 also enables/disables the window in !gbCgbMode ?!?! // LCDC.0 also enables/disables the window in !gbCgbMode ?!?!
// (tested on real hardware) // (tested on real hardware)
@ -249,7 +249,7 @@ void gbRenderLine()
} }
int wy = inUseRegister_WY; int wy = inUseRegister_WY;
if(y >= inUseRegister_WY) { if(y >= inUseRegister_WY) {
if (gbWindowLine == -1) if (gbWindowLine == -1)
@ -258,21 +258,21 @@ void gbRenderLine()
int wx = register_WX; int wx = register_WX;
int swx = 0; int swx = 0;
wx -= 7; wx -= 7;
if( wx <= 159 && gbWindowLine <= 143) { if( wx <= 159 && gbWindowLine <= 143) {
tile_map = 0x1800; tile_map = 0x1800;
if((register_LCDC & 0x40) != 0) if((register_LCDC & 0x40) != 0)
tile_map = 0x1c00; tile_map = 0x1c00;
tx = 0; tx = 0;
ty = gbWindowLine >> 3; ty = gbWindowLine >> 3;
bx = 128; bx = 128;
by = gbWindowLine & 7; by = gbWindowLine & 7;
// Tries to emulate the 'window scrolling bug' when wx == 0 (ie. wx-7 == -7). // Tries to emulate the 'window scrolling bug' when wx == 0 (ie. wx-7 == -7).
// Nothing close to perfect, but good enought for now... // Nothing close to perfect, but good enought for now...
if (wx == -7) if (wx == -7)
@ -281,7 +281,7 @@ void gbRenderLine()
bx >>= ((gbSCXLine[0]+((swx != 1) ? 1 : 0)) & 7); bx >>= ((gbSCXLine[0]+((swx != 1) ? 1 : 0)) & 7);
if (swx == 1) if (swx == 1)
swx = 2; swx = 2;
//bx >>= ((gbSCXLine[0]+(((swx>1) && (swx != 7)) ? 1 : 0)) & 7); //bx >>= ((gbSCXLine[0]+(((swx>1) && (swx != 7)) ? 1 : 0)) & 7);
if ((swx == 7)) if ((swx == 7))
@ -296,24 +296,24 @@ void gbRenderLine()
bx >>= (-wx); bx >>= (-wx);
wx = 0; wx = 0;
} }
tile_map_line_y = tile_map + ty * 32; tile_map_line_y = tile_map + ty * 32;
tile_map_address = tile_map_line_y + tx; tile_map_address = tile_map_line_y + tx;
x = wx; x = wx;
tile = bank0[tile_map_address]; tile = bank0[tile_map_address];
u8 attrs = 0; u8 attrs = 0;
if(bank1) if(bank1)
attrs = bank1[tile_map_address]; attrs = bank1[tile_map_address];
tile_map_address++; tile_map_address++;
if((register_LCDC & 16) == 0) { if((register_LCDC & 16) == 0) {
if(tile < 128) tile += 128; if(tile < 128) tile += 128;
else tile -= 128; else tile -= 128;
} }
tile_pattern_address = tile_pattern + tile * 16 + by*2; tile_pattern_address = tile_pattern + tile * 16 + by*2;
if (wx) if (wx)
@ -323,11 +323,11 @@ void gbRenderLine()
while(x < 160) { while(x < 160) {
u8 tile_a = 0; u8 tile_a = 0;
u8 tile_b = 0; u8 tile_b = 0;
if(attrs & 0x40) { if(attrs & 0x40) {
tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2; tile_pattern_address = tile_pattern + tile * 16 + (7-by)*2;
} }
if(attrs & 0x08) { if(attrs & 0x08) {
tile_a = bank1[tile_pattern_address++]; tile_a = bank1[tile_pattern_address++];
tile_b = bank1[tile_pattern_address]; tile_b = bank1[tile_pattern_address];
@ -335,12 +335,12 @@ void gbRenderLine()
tile_a = bank0[tile_pattern_address++]; tile_a = bank0[tile_pattern_address++];
tile_b = bank0[tile_pattern_address]; tile_b = bank0[tile_pattern_address];
} }
if(attrs & 0x20) { if(attrs & 0x20) {
tile_a = gbInvertTab[tile_a]; tile_a = gbInvertTab[tile_a];
tile_b = gbInvertTab[tile_b]; tile_b = gbInvertTab[tile_b];
} }
while(bx > 0) { while(bx > 0) {
u8 c = (tile_a & bx) != 0 ? 1 : 0; u8 c = (tile_a & bx) != 0 ? 1 : 0;
c += ((tile_b & bx) != 0 ? 2 : 0); c += ((tile_b & bx) != 0 ? 2 : 0);
@ -351,21 +351,21 @@ void gbRenderLine()
gbLineBuffer[x] = 0x300 + c; gbLineBuffer[x] = 0x300 + c;
else else
gbLineBuffer[x] = 0x100 + c; gbLineBuffer[x] = 0x100 + c;
if(gbCgbMode) { if(gbCgbMode) {
c = c + (attrs & 7) * 4; c = c + (attrs & 7) * 4;
} else { } 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) { if(gbSgbMode && !gbCgbMode) {
int dx = x >> 3; int dx = x >> 3;
int dy = y >> 3; int dy = y >> 3;
int palette = gbSgbATF[dy * 20 + dx]; int palette = gbSgbATF[dy * 20 + dx];
if(c == 0) if(c == 0)
palette = 0; palette = 0;
c = c + 4*palette; c = c + 4*palette;
} }
} }
gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c] & 0x7FFF] : gbLineMix[x] = gbColorOption ? gbColorFilter[gbPalette[c] & 0x7FFF] :
@ -383,8 +383,8 @@ void gbRenderLine()
tile = bank0[tile_map_line_y + tx]; tile = bank0[tile_map_line_y + tx];
if(bank1) if(bank1)
attrs = bank1[tile_map_line_y + tx]; attrs = bank1[tile_map_line_y + tx];
if((register_LCDC & 16) == 0) { if((register_LCDC & 16) == 0) {
if(tile < 128) tile += 128; if(tile < 128) tile += 128;
else tile -= 128; else tile -= 128;
} }
@ -436,7 +436,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
bank0 = &gbMemory[0x8000]; bank0 = &gbMemory[0x8000];
bank1 = NULL; bank1 = NULL;
} }
int init = 0x0000; int init = 0x0000;
for (int i = 0; i<4; i++) 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 flipx = (flags & 0x20);
int flipy = (flags & 0x40); int flipy = (flags & 0x40);
if((flags & 0x10)) if((flags & 0x10))
pal = gbObp1; pal = gbObp1;
@ -457,7 +457,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
} }
int prio = flags & 0x80; int prio = flags & 0x80;
int address = init + tile * 16 + 2*t; int address = init + tile * 16 + 2*t;
int a = 0; int a = 0;
int b = 0; int b = 0;
@ -469,7 +469,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
a = bank0[address++]; a = bank0[address++];
b = bank0[address++]; b = bank0[address++];
} }
for(int xx = 0; xx < 8; xx++) { for(int xx = 0; xx < 8; xx++) {
u8 mask = 1 << (7-xx); u8 mask = 1 << (7-xx);
u8 c = 0; u8 c = 0;
@ -477,7 +477,7 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
c++; c++;
if( (b & mask)) if( (b & mask))
c+=2; c+=2;
if(c==0) continue; if(c==0) continue;
int xxx = xx+x; int xxx = xx+x;
@ -516,8 +516,8 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
continue; continue;
} }
} }
} }
gbLineBuffer[xxx] = 0x200 + spriteNumber; gbLineBuffer[xxx] = 0x200 + spriteNumber;
@ -530,13 +530,13 @@ void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,
if(gbSgbMode && !gbCgbMode) { if(gbSgbMode && !gbCgbMode) {
int dx = xxx >> 3; int dx = xxx >> 3;
int dy = y >> 3; int dy = y >> 3;
int palette = gbSgbATF[dy * 20 + dx]; int palette = gbSgbATF[dy * 20 + dx];
if(c == 0) if(c == 0)
palette = 0; palette = 0;
c = c + 4*palette; c = c + 4*palette;
} else { } else {
c += 4; c += 4;
} }
@ -552,7 +552,7 @@ void gbDrawSprites(bool draw)
int x = 0; int x = 0;
int y = 0; int y = 0;
int count = 0; int count = 0;
int size = (register_LCDC & 4); int size = (register_LCDC & 4);
if (!draw) if (!draw)
@ -560,10 +560,10 @@ void gbDrawSprites(bool draw)
if(!(register_LCDC & 0x80)) if(!(register_LCDC & 0x80))
return; return;
if((register_LCDC & 2) && (layerSettings & 0x1000)) { if((register_LCDC & 2) && (layerSettings & 0x1000)) {
int yc = register_LY; int yc = register_LY;
int address = 0xfe00; int address = 0xfe00;
for(int i = 0; i < 40; i++) { for(int i = 0; i < 40; i++) {
y = gbMemory[address++]; y = gbMemory[address++];
@ -595,7 +595,7 @@ void gbDrawSprites(bool draw)
// sprite limit reached! // sprite limit reached!
if(count >= 10) if(count >= 10)
break; break;
} }
} }
return; return;
} }

View File

@ -190,7 +190,7 @@ void mapperMBC1RAM(u16 address, u8 value)
// MBC1 read RAM // MBC1 read RAM
u8 mapperMBC1ReadRAM(u16 address) u8 mapperMBC1ReadRAM(u16 address)
{ {
if(gbDataMBC1.mapperRAMEnable) if(gbDataMBC1.mapperRAMEnable)
return gbMemoryMap[address>>12][address & 0x0fff]; return gbMemoryMap[address>>12][address & 0x0fff];
@ -627,7 +627,7 @@ void mapperMBC5RAM(u16 address, u8 value)
// MBC5 read RAM // MBC5 read RAM
u8 mapperMBC5ReadRAM(u16 address) u8 mapperMBC5ReadRAM(u16 address)
{ {
if(gbDataMBC5.mapperRAMEnable) if(gbDataMBC5.mapperRAMEnable)
return gbMemoryMap[address>>12][address & 0x0fff]; return gbMemoryMap[address>>12][address & 0x0fff];
@ -790,10 +790,10 @@ void mapperMBC7RAM(u16 address, u8 value)
if(address == 0xa080) { if(address == 0xa080) {
// special processing needed // special processing needed
int oldCs = gbDataMBC7.cs,oldSk=gbDataMBC7.sk; int oldCs = gbDataMBC7.cs,oldSk=gbDataMBC7.sk;
gbDataMBC7.cs=value>>7; gbDataMBC7.cs=value>>7;
gbDataMBC7.sk=(value>>6)&1; gbDataMBC7.sk=(value>>6)&1;
if(!oldCs && gbDataMBC7.cs) { if(!oldCs && gbDataMBC7.cs) {
if(gbDataMBC7.state==5) { if(gbDataMBC7.state==5) {
if(gbDataMBC7.writeEnable) { if(gbDataMBC7.writeEnable) {
@ -808,7 +808,7 @@ void mapperMBC7RAM(u16 address, u8 value)
gbDataMBC7.state=0; gbDataMBC7.state=0;
} }
} }
if(!oldSk && gbDataMBC7.sk) { if(!oldSk && gbDataMBC7.sk) {
if(gbDataMBC7.idle) { if(gbDataMBC7.idle) {
if(value & 0x02) { if(value & 0x02) {
@ -855,7 +855,7 @@ void mapperMBC7RAM(u16 address, u8 value)
gbDataMBC7.buffer <<= 1; gbDataMBC7.buffer <<= 1;
gbDataMBC7.buffer |= (value&0x02)?1:0; gbDataMBC7.buffer |= (value&0x02)?1:0;
gbDataMBC7.count++; gbDataMBC7.count++;
switch(gbDataMBC7.code) { switch(gbDataMBC7.code) {
case 0: case 0:
if(gbDataMBC7.count==16) { if(gbDataMBC7.count==16) {
@ -897,7 +897,7 @@ void mapperMBC7RAM(u16 address, u8 value)
gbDataMBC7.state=4; gbDataMBC7.state=4;
gbDataMBC7.count=0; gbDataMBC7.count=0;
gbDataMBC7.buffer = (gbMemory[0xa000+gbDataMBC7.address*2]<<8)| gbDataMBC7.buffer = (gbMemory[0xa000+gbDataMBC7.address*2]<<8)|
(gbMemory[0xa000+gbDataMBC7.address*2+1]); (gbMemory[0xa000+gbDataMBC7.address*2+1]);
} }
break; break;
case 3: case 3:
@ -913,9 +913,9 @@ void mapperMBC7RAM(u16 address, u8 value)
} }
} }
} }
if (oldSk && !gbDataMBC7.sk) { if (oldSk && !gbDataMBC7.sk) {
if (gbDataMBC7.state==4) { if (gbDataMBC7.state==4) {
gbDataMBC7.value = (gbDataMBC7.buffer & 0x8000)?1:0; gbDataMBC7.value = (gbDataMBC7.buffer & 0x8000)?1:0;
gbDataMBC7.buffer <<= 1; gbDataMBC7.buffer <<= 1;
gbDataMBC7.count++; gbDataMBC7.count++;
@ -1446,7 +1446,7 @@ void mapperTAMA5RAM(u16 address, u8 value)
{ {
gbDataTAMA5.mapperHours = (data/16)*10 + data%16; gbDataTAMA5.mapperHours = (data/16)*10 + data%16;
} }
else else
{ {
gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = data; gbTAMA5ram[gbDataTAMA5.mapperRamByteSelect] = data;
} }
@ -1457,7 +1457,7 @@ void mapperTAMA5RAM(u16 address, u8 value)
case 1: // 'Commands' Register case 1: // 'Commands' Register
{ {
gbMemoryMap[0xa][1] = gbDataTAMA5.mapperCommandNumber = value; gbMemoryMap[0xa][1] = gbDataTAMA5.mapperCommandNumber = value;
// This should be only a 'is the flashrom ready ?' command. // This should be only a 'is the flashrom ready ?' command.
// However as I couldn't find any 'copy' command // However as I couldn't find any 'copy' command
// (that seems to be needed for the saving system to work) // (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; systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
} }
} }
} }
} }
} }

View File

@ -78,7 +78,7 @@ void gbPrinterShowData()
pal[3].g = 0; pal[3].g = 0;
pal[3].b = 0; pal[3].b = 0;
set_palette(pal); set_palette(pal);
acquire_screen(); acquire_screen();
u8 *data = gbPrinterData; u8 *data = gbPrinterData;
for(int y = 0; y < 0x12; y++) { for(int y = 0; y < 0x12; y++) {
for(int x = 0; x < 0x14; x++) { for(int x = 0; x < 0x14; x++) {
@ -100,7 +100,7 @@ void gbPrinterShowData()
release_screen(); release_screen();
while(!keypressed()) { while(!keypressed()) {
} }
*/ */
} }
void gbPrinterReceiveData() void gbPrinterReceiveData()
@ -165,12 +165,12 @@ u8 gbPrinterSend(u8 b)
gbPrinterPacket[gbPrinterCount++] = b; gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++; gbPrinterState++;
} else { } else {
// todo: handle failure // todo: handle failure
gbPrinterReset(); gbPrinterReset();
} }
break; break;
case 1: case 1:
// receiving preamble // receiving preamble
if(b == 0x33) { if(b == 0x33) {
gbPrinterPacket[gbPrinterCount++] = b; gbPrinterPacket[gbPrinterCount++] = b;
gbPrinterState++; gbPrinterState++;

View File

@ -91,12 +91,12 @@ void gbSgbReset()
memset(gbSgbPacket, 0, 16 * 7); memset(gbSgbPacket, 0, 16 * 7);
memset(gbSgbBorderChar, 0, 32*256); memset(gbSgbBorderChar, 0, 32*256);
memset(gbSgbBorder, 0, 2048); memset(gbSgbBorder, 0, 2048);
int i; int i;
for(i = 1; i < 2048; i+=2) { for(i = 1; i < 2048; i+=2) {
gbSgbBorder[i] = 1 << 2; gbSgbBorder[i] = 1 << 2;
} }
for(i = 0; i < 32; i++) { for(i = 0; i < 32; i++) {
gbPalette[i*4] = (0x1f) | (0x1f << 5) | (0x1f << 10); gbPalette[i*4] = (0x1f) | (0x1f << 5) | (0x1f << 10);
gbPalette[i*4+1] = (0x15) | (0x15 << 5) | (0x15 << 10); gbPalette[i*4+1] = (0x15) | (0x15 << 5) | (0x15 << 10);
@ -123,7 +123,7 @@ void gbSgbShutdown()
if(gbSgbBorder != NULL) { if(gbSgbBorder != NULL) {
free(gbSgbBorder); free(gbSgbBorder);
gbSgbBorder = NULL; gbSgbBorder = NULL;
} }
} }
void gbSgbFillScreen(u16 color) void gbSgbFillScreen(u16 color)
@ -178,7 +178,7 @@ void gbSgbRenderScreenToBuffer()
u16 patternAddress = 0x8800; u16 patternAddress = 0x8800;
int flag = 1; int flag = 1;
if(register_LCDC & 0x10) { if(register_LCDC & 0x10) {
patternAddress = 0x8000; patternAddress = 0x8000;
flag = 0; 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; u16 *dest = (u16*)pix + ((y+1) * (256+2)) + x;
u8 *dest8 = (u8*)pix + ((y*256)+x)*3; u8 *dest8 = (u8*)pix + ((y*256)+x)*3;
u32 *dest32 = (u32*)pix + ((y+1)*257) + x; u32 *dest32 = (u32*)pix + ((y+1)*257) + x;
u8 *tileAddress = &gbSgbBorderChar[tile * 32]; u8 *tileAddress = &gbSgbBorderChar[tile * 32];
u8 *tileAddress2 = &gbSgbBorderChar[tile * 32 + 16]; u8 *tileAddress2 = &gbSgbBorderChar[tile * 32 + 16];
@ -221,10 +221,10 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
palette += 4; palette += 4;
palette *= 16; palette *= 16;
u8 xx = 0; u8 xx = 0;
u8 yy = 0; u8 yy = 0;
int flipX = attr & 0x40; int flipX = attr & 0x40;
int flipY = attr & 0x80; int flipY = attr & 0x80;
@ -234,9 +234,9 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
u8 b = *tileAddress++; u8 b = *tileAddress++;
u8 c = *tileAddress2++; u8 c = *tileAddress2++;
u8 d = *tileAddress2++; u8 d = *tileAddress2++;
while(mask > 0) { while(mask > 0) {
u8 color = 0; u8 color = 0;
if(a & mask) if(a & mask)
color++; color++;
@ -249,7 +249,7 @@ void gbSgbDrawBorderTile(int x, int y, int tile, int attr)
u8 xxx = xx; u8 xxx = xx;
u8 yyy = yy; u8 yyy = yy;
if(flipX) if(flipX)
xxx = 7 - xx; xxx = 7 - xx;
if(flipY) if(flipY)
@ -290,12 +290,12 @@ void gbSgbRenderBorder()
{ {
if(gbBorderOn) { if(gbBorderOn) {
u8 *fromAddress = gbSgbBorder; u8 *fromAddress = gbSgbBorder;
for(u8 y = 0; y < 28; y++) { for(u8 y = 0; y < 28; y++) {
for(u8 x = 0; x< 32; x++) { for(u8 x = 0; x< 32; x++) {
u8 tile = *fromAddress++; u8 tile = *fromAddress++;
u8 attr = *fromAddress++; u8 attr = *fromAddress++;
gbSgbDrawBorderTile(x*8,y*8,tile,attr); gbSgbDrawBorderTile(x*8,y*8,tile,attr);
} }
} }
@ -307,9 +307,9 @@ void gbSgbPicture()
gbSgbRenderScreenToBuffer(); gbSgbRenderScreenToBuffer();
memcpy(gbSgbBorder, gbSgbScreenBuffer, 2048); memcpy(gbSgbBorder, gbSgbScreenBuffer, 2048);
u16 *paletteAddr = (u16 *)&gbSgbScreenBuffer[2048]; u16 *paletteAddr = (u16 *)&gbSgbScreenBuffer[2048];
for(int i = 64; i < 128; i++) { for(int i = 64; i < 128; i++) {
gbPalette[i] = READ16LE(paletteAddr++); gbPalette[i] = READ16LE(paletteAddr++);
} }
@ -321,9 +321,9 @@ void gbSgbPicture()
systemGbBorderOn(); systemGbBorderOn();
} }
if(gbBorderOn && !gbSgbMask) if(gbBorderOn && !gbSgbMask)
gbSgbRenderBorder(); gbSgbRenderBorder();
if(gbSgbMode && gbCgbMode && gbSgbCGBSupport > 4) { if(gbSgbMode && gbCgbMode && gbSgbCGBSupport > 4) {
gbSgbCGBSupport = 0; gbSgbCGBSupport = 0;
gbSgbMode = 0; gbSgbMode = 0;
@ -340,15 +340,15 @@ void gbSgbSetPalette(int a,int b,u16 *p)
{ {
u16 bit00 = READ16LE(p++); u16 bit00 = READ16LE(p++);
int i; int i;
for(i = 1; i < 4; i++) { for(i = 1; i < 4; i++) {
gbPalette[a*4+i] = READ16LE(p++); gbPalette[a*4+i] = READ16LE(p++);
} }
for(i = 1; i < 4; i++) { for(i = 1; i < 4; i++) {
gbPalette[b*4+i] = READ16LE(p++); gbPalette[b*4+i] = READ16LE(p++);
} }
gbPalette[0] = gbPalette[4] = gbPalette[8] = gbPalette[12] = bit00; gbPalette[0] = gbPalette[4] = gbPalette[8] = gbPalette[12] = bit00;
if(gbBorderOn && !gbSgbMask) if(gbBorderOn && !gbSgbMask)
gbSgbRenderBorder(); gbSgbRenderBorder();
@ -357,9 +357,9 @@ void gbSgbSetPalette(int a,int b,u16 *p)
void gbSgbScpPalette() void gbSgbScpPalette()
{ {
gbSgbRenderScreenToBuffer(); gbSgbRenderScreenToBuffer();
u16 *fromAddress = (u16 *)gbSgbScreenBuffer; u16 *fromAddress = (u16 *)gbSgbScreenBuffer;
for(int i = 0; i < 512*4; i++) { for(int i = 0; i < 512*4; i++) {
gbSgbSCPPalette[i] = READ16LE(fromAddress++); gbSgbSCPPalette[i] = READ16LE(fromAddress++);
} }
@ -399,7 +399,7 @@ void gbSgbSetPalette()
if(atf & 0x80) { if(atf & 0x80) {
gbSgbSetATF(atf & 0x3f); gbSgbSetATF(atf & 0x3f);
} }
if(atf & 0x40) { if(atf & 0x40) {
gbSgbMask = 0; gbSgbMask = 0;
if(gbBorderOn) if(gbBorderOn)
@ -418,7 +418,7 @@ void gbSgbAttributeBlock()
nDataSet = 1; nDataSet = 1;
while(nDataSet) { while(nDataSet) {
u8 controlCode = (*fromAddress++) & 7; u8 controlCode = (*fromAddress++) & 7;
u8 paletteDesignation = (*fromAddress++) & 0x3f; u8 paletteDesignation = (*fromAddress++) & 0x3f;
u8 startH = (*fromAddress++) & 0x1f; u8 startH = (*fromAddress++) & 0x1f;
u8 startV = (*fromAddress++) & 0x1f; u8 startV = (*fromAddress++) & 0x1f;
@ -426,7 +426,7 @@ void gbSgbAttributeBlock()
u8 endV = (*fromAddress++) & 0x1f; u8 endV = (*fromAddress++) & 0x1f;
u8 * toAddress = gbSgbATF; u8 * toAddress = gbSgbATF;
for(u8 y = 0; y < 18; y++) { for(u8 y = 0; y < 18; y++) {
for(u8 x = 0; x < 20; x++) { for(u8 x = 0; x < 20; x++) {
if(x < startH || y < startV || if(x < startH || y < startV ||
@ -444,7 +444,7 @@ void gbSgbAttributeBlock()
if(controlCode & 0x02) if(controlCode & 0x02)
*toAddress = (paletteDesignation>>2) & 0x03; *toAddress = (paletteDesignation>>2) & 0x03;
else if(controlCode == 0x01) else if(controlCode == 0x01)
*toAddress = paletteDesignation & 0x03; *toAddress = paletteDesignation & 0x03;
} }
toAddress++; toAddress++;
} }
@ -461,9 +461,9 @@ void gbSgbSetColumnPalette(u8 col, u8 p)
col = 19; col = 19;
p &= 3; p &= 3;
u8 *toAddress = &gbSgbATF[col]; u8 *toAddress = &gbSgbATF[col];
for(u8 y = 0; y < 18; y++) { for(u8 y = 0; y < 18; y++) {
*toAddress = p; *toAddress = p;
toAddress += 20; toAddress += 20;
@ -478,9 +478,9 @@ void gbSgbSetRowPalette(u8 row, u8 p)
row = 17; row = 17;
p &= 3; p &= 3;
u8 *toAddress = &gbSgbATF[row*20]; u8 *toAddress = &gbSgbATF[row*20];
for(u8 x = 0; x < 20; x++) { for(u8 x = 0; x < 20; x++) {
*toAddress++ = p; *toAddress++ = p;
} }
@ -516,7 +516,7 @@ void gbSgbAttributeDivide()
else if ( i > coord) else if ( i > coord)
gbSgbSetColumnPalette(i, colorBR); gbSgbSetColumnPalette(i, colorBR);
else else
gbSgbSetColumnPalette(i, colorOL); gbSgbSetColumnPalette(i, colorOL);
} }
} }
} }
@ -561,7 +561,7 @@ void gbSgbAttributeCharacter()
u8 s = 6; u8 s = 6;
u8 *fromAddress = &gbSgbPacket[6]; u8 *fromAddress = &gbSgbPacket[6];
u8 v = *fromAddress++; u8 v = *fromAddress++;
if(style) { if(style) {
while(nDataSet) { while(nDataSet) {
u8 p = (v >> s) & 3; u8 p = (v >> s) & 3;
@ -593,14 +593,14 @@ void gbSgbAttributeCharacter()
if(startV == 18) if(startV == 18)
break; break;
} }
if(s) if(s)
s -= 2; s -= 2;
else { else {
s = 6; s = 6;
v = *fromAddress++; v = *fromAddress++;
nDataSet--; nDataSet--;
} }
} }
} }
} }
@ -608,7 +608,7 @@ void gbSgbAttributeCharacter()
void gbSgbSetATFList() void gbSgbSetATFList()
{ {
gbSgbRenderScreenToBuffer(); gbSgbRenderScreenToBuffer();
u8 *fromAddress = gbSgbScreenBuffer; u8 *fromAddress = gbSgbScreenBuffer;
u8 *toAddress = gbSgbATFList; u8 *toAddress = gbSgbATFList;
@ -631,7 +631,7 @@ void gbSgbMaskEnable()
int gbSgbMaskFlag = gbSgbPacket[1] & 3; int gbSgbMaskFlag = gbSgbPacket[1] & 3;
gbSgbMask = gbSgbMaskFlag; gbSgbMask = gbSgbMaskFlag;
switch(gbSgbMaskFlag) { switch(gbSgbMaskFlag) {
case 1: case 1:
break; break;
@ -652,14 +652,14 @@ void gbSgbMaskEnable()
void gbSgbChrTransfer() void gbSgbChrTransfer()
{ {
gbSgbRenderScreenToBuffer(); gbSgbRenderScreenToBuffer();
int address = (gbSgbPacket[1] & 1) * (128*32); int address = (gbSgbPacket[1] & 1) * (128*32);
if(gbSgbPacket[1] & 1) if(gbSgbPacket[1] & 1)
gbSgbCGBSupport |= 2; gbSgbCGBSupport |= 2;
else else
gbSgbCGBSupport |= 1; gbSgbCGBSupport |= 1;
memcpy(&gbSgbBorderChar[address], gbSgbScreenBuffer, 128 * 32); memcpy(&gbSgbBorderChar[address], gbSgbScreenBuffer, 128 * 32);
if(gbBorderAutomatic && !gbBorderOn && gbSgbCGBSupport > 4) { if(gbBorderAutomatic && !gbBorderOn && gbSgbCGBSupport > 4) {
@ -676,7 +676,7 @@ void gbSgbChrTransfer()
gbSgbMask = 0; gbSgbMask = 0;
gbSgbRenderBorder(); gbSgbRenderBorder();
gbReset(); gbReset();
} }
if(gbSgbCGBSupport > 4) if(gbSgbCGBSupport > 4)
gbSgbCGBSupport = 0; gbSgbCGBSupport = 0;
@ -787,13 +787,13 @@ void gbSgbDoBitTransfer(u8 value)
gbSgbReadingController &= 3; gbSgbReadingController &= 3;
} }
} }
gbSgbPacketTimeout = 0; gbSgbPacketTimeout = 0;
} else { } else {
if(value == 0x10) if(value == 0x10)
gbSgbReadingController |= 0x2; gbSgbReadingController |= 0x2;
else if(value == 0x20) else if(value == 0x20)
gbSgbReadingController |= 0x01; gbSgbReadingController |= 0x01;
gbSgbPacketTimeout = 0; gbSgbPacketTimeout = 0;
} }
gbSgbPacketTimeout = 0; gbSgbPacketTimeout = 0;
break; break;
@ -887,7 +887,7 @@ void gbSgbSaveGame(gzFile gzFile)
utilGzWrite(gzFile, gbSgbBorder, 2048); utilGzWrite(gzFile, gbSgbBorder, 2048);
utilGzWrite(gzFile, gbSgbBorderChar, 32*256); utilGzWrite(gzFile, gbSgbBorderChar, 32*256);
utilGzWrite(gzFile, gbSgbPacket, 16*7); utilGzWrite(gzFile, gbSgbPacket, 16*7);
utilGzWrite(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16)); utilGzWrite(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16));
@ -908,7 +908,7 @@ void gbSgbReadGame(gzFile gzFile, int version)
utilGzRead(gzFile, gbSgbBorder, 2048); utilGzRead(gzFile, gbSgbBorder, 2048);
utilGzRead(gzFile, gbSgbBorderChar, 32*256); utilGzRead(gzFile, gbSgbBorderChar, 32*256);
} }
utilGzRead(gzFile, gbSgbPacket, 16*7); utilGzRead(gzFile, gbSgbPacket, 16*7);
utilGzRead(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16)); utilGzRead(gzFile, gbSgbSCPPalette, 4 * 512 * sizeof(u16));

View File

@ -137,7 +137,7 @@ bool gbDigitalSound = false;
void gbSoundEvent(register u16 address, register int data) void gbSoundEvent(register u16 address, register int data)
{ {
int freq = 0; int freq = 0;
gbMemory[address] = data; gbMemory[address] = data;
#ifndef FINAL_VERSION #ifndef FINAL_VERSION
@ -195,7 +195,7 @@ void gbSoundEvent(register u16 address, register int data)
sound1SweepSteps = gbMemory[NR10] & 7; sound1SweepSteps = gbMemory[NR10] & 7;
sound1SweepUpDown = gbMemory[NR10] & 0x08; sound1SweepUpDown = gbMemory[NR10] & 0x08;
sound1SweepStep = 0; sound1SweepStep = 0;
sound1Index = 0; sound1Index = 0;
sound1On = 1; sound1On = 1;
} }
@ -238,7 +238,7 @@ void gbSoundEvent(register u16 address, register int data)
sound2EnvelopeUpDown = gbMemory[NR22] & 0x08; sound2EnvelopeUpDown = gbMemory[NR22] & 0x08;
sound2ATL = sound2ATLreload; sound2ATL = sound2ATLreload;
sound2EnvelopeATLReload = sound2EnvelopeATL = 689 * (gbMemory[NR22] & 7); sound2EnvelopeATLReload = sound2EnvelopeATL = 689 * (gbMemory[NR22] & 7);
sound2Index = 0; sound2Index = 0;
sound2On = 1; sound2On = 1;
} }
@ -297,13 +297,13 @@ void gbSoundEvent(register u16 address, register int data)
sound4NSteps = data & 0x08; sound4NSteps = data & 0x08;
sound4Skip = (freq << 8) / NOISE_MAGIC; sound4Skip = (freq << 8) / NOISE_MAGIC;
sound4Clock = data >> 4; sound4Clock = data >> 4;
freq = freq / soundShiftClock[sound4Clock]; freq = freq / soundShiftClock[sound4Clock];
sound4ShiftSkip = (freq << 8) / NOISE_MAGIC; sound4ShiftSkip = (freq << 8) / NOISE_MAGIC;
break; break;
case NR44: case NR44:
gbMemory[address] = data | 0xbf; gbMemory[address] = data | 0xbf;
@ -316,10 +316,10 @@ void gbSoundEvent(register u16 address, register int data)
sound4EnvelopeATLReload = sound4EnvelopeATL = 689 * (gbMemory[NR42] & 7); sound4EnvelopeATLReload = sound4EnvelopeATL = 689 * (gbMemory[NR42] & 7);
sound4On = 1; sound4On = 1;
sound4Index = 0; sound4Index = 0;
sound4ShiftIndex = 0; sound4ShiftIndex = 0;
if(sound4NSteps) if(sound4NSteps)
sound4ShiftRight = 0x7fff; sound4ShiftRight = 0x7fff;
else else
@ -366,7 +366,7 @@ void gbSoundEvent(register u16 address, register int data)
int freq = 0; int freq = 0;
int value = 0; int value = 0;
if(sound1On && (sound1ATL || !sound1Continue)) { if(sound1On && (sound1ATL || !sound1Continue)) {
sound1Index += soundQuality*sound1Skip; sound1Index += soundQuality*sound1Skip;
sound1Index &= 0x1fffffff; sound1Index &= 0x1fffffff;
@ -376,20 +376,20 @@ void gbSoundEvent(register u16 address, register int data)
soundBuffer[0][soundIndex] = value; soundBuffer[0][soundIndex] = value;
if(sound1On) { if(sound1On) {
if(sound1ATL) { if(sound1ATL) {
sound1ATL-=soundQuality; sound1ATL-=soundQuality;
if(sound1ATL <=0 && sound1Continue) { if(sound1ATL <=0 && sound1Continue) {
gbMemory[NR52] &= 0xfe; gbMemory[NR52] &= 0xfe;
sound1On = 0; sound1On = 0;
} }
} }
if(sound1EnvelopeATL) { if(sound1EnvelopeATL) {
sound1EnvelopeATL-=soundQuality; sound1EnvelopeATL-=soundQuality;
if(sound1EnvelopeATL<=0) { if(sound1EnvelopeATL<=0) {
if(sound1EnvelopeUpDown) { if(sound1EnvelopeUpDown) {
if(sound1EnvelopeVolume < 15) if(sound1EnvelopeVolume < 15)
@ -398,22 +398,22 @@ void gbSoundEvent(register u16 address, register int data)
if(sound1EnvelopeVolume) if(sound1EnvelopeVolume)
sound1EnvelopeVolume--; sound1EnvelopeVolume--;
} }
sound1EnvelopeATL += sound1EnvelopeATLReload; sound1EnvelopeATL += sound1EnvelopeATLReload;
} }
} }
if(sound1SweepATL) { if(sound1SweepATL) {
sound1SweepATL-=soundQuality; sound1SweepATL-=soundQuality;
if(sound1SweepATL<=0) { if(sound1SweepATL<=0) {
freq = (((int)(freq1high & 7)) << 8) | freq1low; freq = (((int)(freq1high & 7)) << 8) | freq1low;
int updown = 1; int updown = 1;
if(sound1SweepUpDown) if(sound1SweepUpDown)
updown = -1; updown = -1;
int newfreq = 0; int newfreq = 0;
if(sound1SweepSteps) { if(sound1SweepSteps) {
newfreq = freq + updown * freq / (1 << sound1SweepSteps); newfreq = freq + updown * freq / (1 << sound1SweepSteps);
@ -421,7 +421,7 @@ void gbSoundEvent(register u16 address, register int data)
newfreq = 0; newfreq = 0;
} else } else
newfreq = freq; newfreq = freq;
if(newfreq < 0) { if(newfreq < 0) {
sound1SweepATL += sound1SweepATLReload; sound1SweepATL += sound1SweepATLReload;
} else if(newfreq > 2047) { } else if(newfreq > 2047) {
@ -431,7 +431,7 @@ void gbSoundEvent(register u16 address, register int data)
} else { } else {
sound1SweepATL += sound1SweepATLReload; sound1SweepATL += sound1SweepATLReload;
sound1Skip = SOUND_MAGIC/(2048 - newfreq); sound1Skip = SOUND_MAGIC/(2048 - newfreq);
freq1low = newfreq & 0xff; freq1low = newfreq & 0xff;
freq1high = (freq1high & 0xf8) |((newfreq >> 8) & 7); freq1high = (freq1high & 0xf8) |((newfreq >> 8) & 7);
} }
@ -446,29 +446,29 @@ void gbSoundChannel2()
int vol = sound2EnvelopeVolume; int vol = sound2EnvelopeVolume;
int value = 0; int value = 0;
if(sound2On && (sound2ATL || !sound2Continue)) { if(sound2On && (sound2ATL || !sound2Continue)) {
sound2Index += soundQuality*sound2Skip; sound2Index += soundQuality*sound2Skip;
sound2Index &= 0x1fffffff; sound2Index &= 0x1fffffff;
value = ((s8)sound2Wave[sound2Index>>24]) * vol; value = ((s8)sound2Wave[sound2Index>>24]) * vol;
} }
soundBuffer[1][soundIndex] = value; soundBuffer[1][soundIndex] = value;
if(sound2On) { if(sound2On) {
if(sound2ATL) { if(sound2ATL) {
sound2ATL-=soundQuality; sound2ATL-=soundQuality;
if(sound2ATL <= 0 && sound2Continue) { if(sound2ATL <= 0 && sound2Continue) {
gbMemory[NR52] &= 0xfd; gbMemory[NR52] &= 0xfd;
sound2On = 0; sound2On = 0;
} }
} }
if(sound2EnvelopeATL) { if(sound2EnvelopeATL) {
sound2EnvelopeATL-=soundQuality; sound2EnvelopeATL-=soundQuality;
if(sound2EnvelopeATL <= 0) { if(sound2EnvelopeATL <= 0) {
if(sound2EnvelopeUpDown) { if(sound2EnvelopeUpDown) {
if(sound2EnvelopeVolume < 15) if(sound2EnvelopeVolume < 15)
@ -481,21 +481,21 @@ void gbSoundChannel2()
} }
} }
} }
} }
void gbSoundChannel3() void gbSoundChannel3()
{ {
int value = 0; int value = 0;
if(sound3On && (sound3ATL || !sound3Continue)) { if(sound3On && (sound3ATL || !sound3Continue)) {
value = sound3Last; value = sound3Last;
sound3Index += soundQuality*sound3Skip; sound3Index += soundQuality*sound3Skip;
sound3Index &= 0x1fffffff; sound3Index &= 0x1fffffff;
value = gbMemory[0xff30 + (sound3Index>>25)]; value = gbMemory[0xff30 + (sound3Index>>25)];
if( (sound3Index & 0x01000000)) { if( (sound3Index & 0x01000000)) {
value &= 0x0f; value &= 0x0f;
} else { } else {
@ -503,7 +503,7 @@ void gbSoundChannel3()
} }
value -= 8; value -= 8;
switch(sound3OutputLevel) { switch(sound3OutputLevel) {
case 0: case 0:
value = 0; value = 0;
@ -519,13 +519,13 @@ void gbSoundChannel3()
} }
sound3Last = value; sound3Last = value;
} }
soundBuffer[2][soundIndex] = value; soundBuffer[2][soundIndex] = value;
if(sound3On) { if(sound3On) {
if(sound3ATL) { if(sound3ATL) {
sound3ATL-=soundQuality; sound3ATL-=soundQuality;
if(sound3ATL <= 0 && sound3Continue) { if(sound3ATL <= 0 && sound3Continue) {
gbMemory[NR52] &= 0xfb; gbMemory[NR52] &= 0xfb;
sound3On = 0; sound3On = 0;
@ -558,34 +558,34 @@ void gbSoundChannel4()
(sound4ShiftRight << 13)) & 0x4000) | (sound4ShiftRight << 13)) & 0x4000) |
(sound4ShiftRight >> 1); (sound4ShiftRight >> 1);
sound4ShiftIndex -= 0x200000; sound4ShiftIndex -= 0x200000;
} }
} }
sound4Index &= 0x1fffff; sound4Index &= 0x1fffff;
sound4ShiftIndex &= 0x1fffff; sound4ShiftIndex &= 0x1fffff;
value = ((sound4ShiftRight & 1)*2-1) * vol; value = ((sound4ShiftRight & 1)*2-1) * vol;
} else { } else {
value = 0; value = 0;
} }
} }
soundBuffer[3][soundIndex] = value; soundBuffer[3][soundIndex] = value;
if(sound4On) { if(sound4On) {
if(sound4ATL) { if(sound4ATL) {
sound4ATL-=soundQuality; sound4ATL-=soundQuality;
if(sound4ATL <= 0 && sound4Continue) { if(sound4ATL <= 0 && sound4Continue) {
gbMemory[NR52] &= 0xf7; gbMemory[NR52] &= 0xf7;
sound4On = 0; sound4On = 0;
} }
} }
if(sound4EnvelopeATL) { if(sound4EnvelopeATL) {
sound4EnvelopeATL-=soundQuality; sound4EnvelopeATL-=soundQuality;
if(sound4EnvelopeATL <= 0) { if(sound4EnvelopeATL <= 0) {
if(sound4EnvelopeUpDown) { if(sound4EnvelopeUpDown) {
if(sound4EnvelopeVolume < 15) if(sound4EnvelopeVolume < 15)
@ -621,7 +621,7 @@ void gbSoundMix()
res *= soundLevel1*256; res *= soundLevel1*256;
else else
res *= soundLevel1*60; res *= soundLevel1*60;
if(soundEcho) { if(soundEcho) {
res *= 2; res *= 2;
res += soundFilter[soundEchoIndex]; res += soundFilter[soundEchoIndex];
@ -653,7 +653,7 @@ void gbSoundMix()
res >>= 1; res >>= 1;
break; break;
} }
if(res > 32767) if(res > 32767)
res = 32767; res = 32767;
if(res < -32768) if(res < -32768)
@ -663,7 +663,7 @@ void gbSoundMix()
soundFinalWave[++soundBufferIndex] = res; soundFinalWave[++soundBufferIndex] = res;
else else
soundFinalWave[soundBufferIndex++] = res; soundFinalWave[soundBufferIndex++] = res;
res = 0; res = 0;
if(soundBalance & 1) { if(soundBalance & 1) {
@ -683,7 +683,7 @@ void gbSoundMix()
res *= soundLevel2*256; res *= soundLevel2*256;
else else
res *= soundLevel2*60; res *= soundLevel2*60;
if(soundEcho) { if(soundEcho) {
res *= 2; res *= 2;
res += soundFilter[soundEchoIndex]; res += soundFilter[soundEchoIndex];
@ -691,7 +691,7 @@ void gbSoundMix()
soundFilter[soundEchoIndex++] = res; soundFilter[soundEchoIndex++] = res;
if(soundEchoIndex >= 4000) if(soundEchoIndex >= 4000)
soundEchoIndex = 0; soundEchoIndex = 0;
} }
if(soundLowPass) { if(soundLowPass) {
@ -699,7 +699,7 @@ void gbSoundMix()
soundRight[3] = soundRight[2]; soundRight[3] = soundRight[2];
soundRight[2] = soundRight[1]; soundRight[2] = soundRight[1];
soundRight[1] = soundRight[0]; soundRight[1] = soundRight[0];
soundRight[0] = res; soundRight[0] = res;
res = (soundRight[4] + 2*soundRight[3] + 8*soundRight[2] + 2*soundRight[1] + res = (soundRight[4] + 2*soundRight[3] + 8*soundRight[2] + 2*soundRight[1] +
soundRight[0])/14; soundRight[0])/14;
} }
@ -718,7 +718,7 @@ void gbSoundMix()
res >>= 1; res >>= 1;
break; break;
} }
if(res > 32767) if(res > 32767)
res = 32767; res = 32767;
if(res < -32768) if(res < -32768)
@ -738,21 +738,21 @@ void gbSoundTick()
gbSoundChannel2(); gbSoundChannel2();
gbSoundChannel3(); gbSoundChannel3();
gbSoundChannel4(); gbSoundChannel4();
gbSoundMix(); gbSoundMix();
} else { } else {
soundFinalWave[soundBufferIndex++] = 0; soundFinalWave[soundBufferIndex++] = 0;
soundFinalWave[soundBufferIndex++] = 0; soundFinalWave[soundBufferIndex++] = 0;
} }
soundIndex++; soundIndex++;
if(2*soundBufferIndex >= soundBufferLen) { if(2*soundBufferIndex >= soundBufferLen) {
if(systemSoundOn) { if(systemSoundOn) {
if(soundPaused) { if(soundPaused) {
soundResume(); soundResume();
} }
systemWriteDataToSoundBuffer(); systemWriteDataToSoundBuffer();
} }
soundIndex = 0; soundIndex = 0;
@ -765,7 +765,7 @@ void gbSoundReset()
{ {
soundPaused = 1; soundPaused = 1;
soundPlay = 0; soundPlay = 0;
SOUND_CLOCK_TICKS = soundQuality * 24; SOUND_CLOCK_TICKS = soundQuality * 24;
soundTicks = SOUND_CLOCK_TICKS; soundTicks = SOUND_CLOCK_TICKS;
soundNextPosition = 0; soundNextPosition = 0;
soundMasterOn = 1; soundMasterOn = 1;
@ -774,7 +774,7 @@ void gbSoundReset()
soundLevel1 = 7; soundLevel1 = 7;
soundLevel2 = 7; soundLevel2 = 7;
soundVIN = 0; soundVIN = 0;
sound1On = 0; sound1On = 0;
sound1ATL = 0; sound1ATL = 0;
sound1Skip = 0; sound1Skip = 0;
@ -790,7 +790,7 @@ void gbSoundReset()
sound1SweepUpDown = 0; sound1SweepUpDown = 0;
sound1SweepStep = 0; sound1SweepStep = 0;
sound1Wave = soundWavePattern[2]; sound1Wave = soundWavePattern[2];
sound2On = 0; sound2On = 0;
sound2ATL = 0; sound2ATL = 0;
sound2Skip = 0; sound2Skip = 0;
@ -801,14 +801,14 @@ void gbSoundReset()
sound2EnvelopeUpDown = 0; sound2EnvelopeUpDown = 0;
sound2EnvelopeATLReload = 0; sound2EnvelopeATLReload = 0;
sound2Wave = soundWavePattern[2]; sound2Wave = soundWavePattern[2];
sound3On = 0; sound3On = 0;
sound3ATL = 0; sound3ATL = 0;
sound3Skip = 0; sound3Skip = 0;
sound3Index = 0; sound3Index = 0;
sound3Continue = 0; sound3Continue = 0;
sound3OutputLevel = 0; sound3OutputLevel = 0;
sound4On = 0; sound4On = 0;
sound4Clock = 0; sound4Clock = 0;
sound4ATL = 0; sound4ATL = 0;
@ -837,10 +837,10 @@ void gbSoundReset()
gbSoundEvent(0xff17, 0x00); gbSoundEvent(0xff17, 0x00);
gbSoundEvent(0xff19, 0xbf); gbSoundEvent(0xff19, 0xbf);
gbSoundEvent(0xff1a, 0x7f); gbSoundEvent(0xff1a, 0x7f);
gbSoundEvent(0xff1b, 0xff); gbSoundEvent(0xff1b, 0xff);
gbSoundEvent(0xff1c, 0xbf); gbSoundEvent(0xff1c, 0xbf);
gbSoundEvent(0xff1e, 0xbf); gbSoundEvent(0xff1e, 0xbf);
gbSoundEvent(0xff20, 0xff); gbSoundEvent(0xff20, 0xff);
gbSoundEvent(0xff21, 0x00); gbSoundEvent(0xff21, 0x00);
@ -864,7 +864,7 @@ void gbSoundReset()
sound2On = 0; sound2On = 0;
sound3On = 0; sound3On = 0;
sound4On = 0; sound4On = 0;
int addr = 0xff30; int addr = 0xff30;
while(addr < 0xff40) { while(addr < 0xff40) {
@ -1016,7 +1016,7 @@ void gbSoundReadGame(int version,gzFile gzFile)
} }
soundBufferIndex = soundIndex * 2; soundBufferIndex = soundIndex * 2;
utilGzRead(gzFile, soundBuffer, 4*735); utilGzRead(gzFile, soundBuffer, 4*735);
utilGzRead(gzFile, soundFinalWave, 2*735); utilGzRead(gzFile, soundFinalWave, 2*735);
@ -1028,7 +1028,7 @@ void gbSoundReadGame(int version,gzFile gzFile)
soundQuality = -1; soundQuality = -1;
gbSoundSetQuality(1); gbSoundSetQuality(1);
} }
sound1Wave = soundWavePattern[gbMemory[NR11] >> 6]; sound1Wave = soundWavePattern[gbMemory[NR11] >> 6];
sound2Wave = soundWavePattern[gbMemory[NR21] >> 6]; sound2Wave = soundWavePattern[gbMemory[NR21] >> 6];
} }

View File

@ -1,227 +1,227 @@
#include "gbafilter.h" #include "gbafilter.h"
#include <math.h> #include <math.h>
extern int systemColorDepth; extern int systemColorDepth;
extern int systemRedShift; extern int systemRedShift;
extern int systemGreenShift; extern int systemGreenShift;
extern int systemBlueShift; extern int systemBlueShift;
extern u16 systemColorMap16[0x10000]; extern u16 systemColorMap16[0x10000];
extern u32 systemColorMap32[0x10000]; extern u32 systemColorMap32[0x10000];
static const unsigned char curve[32] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x10, 0x12, static const unsigned char curve[32] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x10, 0x12,
0x14, 0x16, 0x18, 0x1c, 0x20, 0x28, 0x30, 0x38, 0x14, 0x16, 0x18, 0x1c, 0x20, 0x28, 0x30, 0x38,
0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x80, 0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x80,
0x88, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0}; 0x88, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0};
// output R G B // output R G B
static const unsigned char influence[3 * 3] = { 16, 4, 4, // red static const unsigned char influence[3 * 3] = { 16, 4, 4, // red
8, 16, 8, // green 8, 16, 8, // green
0, 8, 16};// blue 0, 8, 16};// blue
inline void swap(short & a, short & b) inline void swap(short & a, short & b)
{ {
short temp = a; short temp = a;
a = b; a = b;
b = temp; b = temp;
} }
void gbafilter_pal(u16 * buf, int count) void gbafilter_pal(u16 * buf, int count)
{ {
short temp[3 * 3], s; short temp[3 * 3], s;
unsigned pix; unsigned pix;
u8 red, green, blue; u8 red, green, blue;
while (count--) while (count--)
{ {
pix = *buf; pix = *buf;
s = curve[(pix >> systemGreenShift) & 0x1f]; s = curve[(pix >> systemGreenShift) & 0x1f];
temp[3] = s * influence[3]; temp[3] = s * influence[3];
temp[4] = s * influence[4]; temp[4] = s * influence[4];
temp[5] = s * influence[5]; temp[5] = s * influence[5];
s = curve[(pix >> systemRedShift) & 0x1f]; s = curve[(pix >> systemRedShift) & 0x1f];
temp[0] = s * influence[0]; temp[0] = s * influence[0];
temp[1] = s * influence[1]; temp[1] = s * influence[1];
temp[2] = s * influence[2]; temp[2] = s * influence[2];
s = curve[(pix >> systemBlueShift) & 0x1f]; s = curve[(pix >> systemBlueShift) & 0x1f];
temp[6] = s * influence[6]; temp[6] = s * influence[6];
temp[7] = s * influence[7]; temp[7] = s * influence[7];
temp[8] = s * influence[8]; temp[8] = s * influence[8];
if (temp[0] < temp[3]) swap(temp[0], temp[3]); if (temp[0] < temp[3]) swap(temp[0], temp[3]);
if (temp[0] < temp[6]) swap(temp[0], temp[6]); if (temp[0] < temp[6]) swap(temp[0], temp[6]);
if (temp[3] < temp[6]) swap(temp[3], temp[6]); if (temp[3] < temp[6]) swap(temp[3], temp[6]);
temp[3] <<= 1; temp[3] <<= 1;
temp[0] <<= 2; temp[0] <<= 2;
temp[0] += temp[3] + temp[6]; temp[0] += temp[3] + temp[6];
red = ((int(temp[0]) * 160) >> 17) + 4; red = ((int(temp[0]) * 160) >> 17) + 4;
if (red > 31) red = 31; if (red > 31) red = 31;
if (temp[2] < temp[5]) swap(temp[2], temp[5]); if (temp[2] < temp[5]) swap(temp[2], temp[5]);
if (temp[2] < temp[8]) swap(temp[2], temp[8]); if (temp[2] < temp[8]) swap(temp[2], temp[8]);
if (temp[5] < temp[8]) swap(temp[5], temp[8]); if (temp[5] < temp[8]) swap(temp[5], temp[8]);
temp[5] <<= 1; temp[5] <<= 1;
temp[2] <<= 2; temp[2] <<= 2;
temp[2] += temp[5] + temp[8]; temp[2] += temp[5] + temp[8];
blue = ((int(temp[2]) * 160) >> 17) + 4; blue = ((int(temp[2]) * 160) >> 17) + 4;
if (blue > 31) blue = 31; if (blue > 31) blue = 31;
if (temp[1] < temp[4]) swap(temp[1], temp[4]); if (temp[1] < temp[4]) swap(temp[1], temp[4]);
if (temp[1] < temp[7]) swap(temp[1], temp[7]); if (temp[1] < temp[7]) swap(temp[1], temp[7]);
if (temp[4] < temp[7]) swap(temp[4], temp[7]); if (temp[4] < temp[7]) swap(temp[4], temp[7]);
temp[4] <<= 1; temp[4] <<= 1;
temp[1] <<= 2; temp[1] <<= 2;
temp[1] += temp[4] + temp[7]; temp[1] += temp[4] + temp[7];
green = ((int(temp[1]) * 160) >> 17) + 4; green = ((int(temp[1]) * 160) >> 17) + 4;
if (green > 31) green = 31; if (green > 31) green = 31;
pix = red << systemRedShift; pix = red << systemRedShift;
pix += green << systemGreenShift; pix += green << systemGreenShift;
pix += blue << systemBlueShift; pix += blue << systemBlueShift;
*buf++ = pix; *buf++ = pix;
} }
} }
void gbafilter_pal32(u32 * buf, int count) void gbafilter_pal32(u32 * buf, int count)
{ {
short temp[3 * 3], s; short temp[3 * 3], s;
unsigned pix; unsigned pix;
u8 red, green, blue; u8 red, green, blue;
while (count--) while (count--)
{ {
pix = *buf; pix = *buf;
s = curve[(pix >> systemGreenShift) & 0x1f]; s = curve[(pix >> systemGreenShift) & 0x1f];
temp[3] = s * influence[3]; temp[3] = s * influence[3];
temp[4] = s * influence[4]; temp[4] = s * influence[4];
temp[5] = s * influence[5]; temp[5] = s * influence[5];
s = curve[(pix >> systemRedShift) & 0x1f]; s = curve[(pix >> systemRedShift) & 0x1f];
temp[0] = s * influence[0]; temp[0] = s * influence[0];
temp[1] = s * influence[1]; temp[1] = s * influence[1];
temp[2] = s * influence[2]; temp[2] = s * influence[2];
s = curve[(pix >> systemBlueShift) & 0x1f]; s = curve[(pix >> systemBlueShift) & 0x1f];
temp[6] = s * influence[6]; temp[6] = s * influence[6];
temp[7] = s * influence[7]; temp[7] = s * influence[7];
temp[8] = s * influence[8]; temp[8] = s * influence[8];
if (temp[0] < temp[3]) swap(temp[0], temp[3]); if (temp[0] < temp[3]) swap(temp[0], temp[3]);
if (temp[0] < temp[6]) swap(temp[0], temp[6]); if (temp[0] < temp[6]) swap(temp[0], temp[6]);
if (temp[3] < temp[6]) swap(temp[3], temp[6]); if (temp[3] < temp[6]) swap(temp[3], temp[6]);
temp[3] <<= 1; temp[3] <<= 1;
temp[0] <<= 2; temp[0] <<= 2;
temp[0] += temp[3] + temp[6]; temp[0] += temp[3] + temp[6];
//red = ((int(temp[0]) * 160) >> 17) + 4; //red = ((int(temp[0]) * 160) >> 17) + 4;
red = ((int(temp[0]) * 160) >> 14) + 32; red = ((int(temp[0]) * 160) >> 14) + 32;
if (temp[2] < temp[5]) swap(temp[2], temp[5]); if (temp[2] < temp[5]) swap(temp[2], temp[5]);
if (temp[2] < temp[8]) swap(temp[2], temp[8]); if (temp[2] < temp[8]) swap(temp[2], temp[8]);
if (temp[5] < temp[8]) swap(temp[5], temp[8]); if (temp[5] < temp[8]) swap(temp[5], temp[8]);
temp[5] <<= 1; temp[5] <<= 1;
temp[2] <<= 2; temp[2] <<= 2;
temp[2] += temp[5] + temp[8]; temp[2] += temp[5] + temp[8];
//blue = ((int(temp[2]) * 160) >> 17) + 4; //blue = ((int(temp[2]) * 160) >> 17) + 4;
blue = ((int(temp[2]) * 160) >> 14) + 32; blue = ((int(temp[2]) * 160) >> 14) + 32;
if (temp[1] < temp[4]) swap(temp[1], temp[4]); if (temp[1] < temp[4]) swap(temp[1], temp[4]);
if (temp[1] < temp[7]) swap(temp[1], temp[7]); if (temp[1] < temp[7]) swap(temp[1], temp[7]);
if (temp[4] < temp[7]) swap(temp[4], temp[7]); if (temp[4] < temp[7]) swap(temp[4], temp[7]);
temp[4] <<= 1; temp[4] <<= 1;
temp[1] <<= 2; temp[1] <<= 2;
temp[1] += temp[4] + temp[7]; temp[1] += temp[4] + temp[7];
//green = ((int(temp[1]) * 160) >> 17) + 4; //green = ((int(temp[1]) * 160) >> 17) + 4;
green = ((int(temp[1]) * 160) >> 14) + 32; green = ((int(temp[1]) * 160) >> 14) + 32;
//pix = red << redshift; //pix = red << redshift;
//pix += green << greenshift; //pix += green << greenshift;
//pix += blue << blueshift; //pix += blue << blueshift;
pix = red << (systemRedShift - 3); pix = red << (systemRedShift - 3);
pix += green << (systemGreenShift - 3); pix += green << (systemGreenShift - 3);
pix += blue << (systemBlueShift - 3); pix += blue << (systemBlueShift - 3);
*buf++ = pix; *buf++ = pix;
} }
} }
// for palette mode to work with the three spoony filters in 32bpp depth // for palette mode to work with the three spoony filters in 32bpp depth
void gbafilter_pad(u8 * buf, int count) void gbafilter_pad(u8 * buf, int count)
{ {
union union
{ {
struct struct
{ {
u8 r; u8 r;
u8 g; u8 g;
u8 b; u8 b;
u8 a; u8 a;
} part; } part;
unsigned whole; unsigned whole;
} }
mask; mask;
mask.whole = 0x1f << systemRedShift; mask.whole = 0x1f << systemRedShift;
mask.whole += 0x1f << systemGreenShift; mask.whole += 0x1f << systemGreenShift;
mask.whole += 0x1f << systemBlueShift; mask.whole += 0x1f << systemBlueShift;
switch (systemColorDepth) switch (systemColorDepth)
{ {
case 24: case 24:
while (count--) while (count--)
{ {
*buf++ &= mask.part.r; *buf++ &= mask.part.r;
*buf++ &= mask.part.g; *buf++ &= mask.part.g;
*buf++ &= mask.part.b; *buf++ &= mask.part.b;
} }
break; break;
case 32: case 32:
while (count--) while (count--)
{ {
*((u32*)buf) &= mask.whole; *((u32*)buf) &= mask.whole;
buf += 4; buf += 4;
} }
} }
} }
/* /*
void UpdateSystemColorMaps(int lcd) void UpdateSystemColorMaps(int lcd)
{ {
switch(systemColorDepth) { switch(systemColorDepth) {
case 16: case 16:
{ {
for(int i = 0; i < 0x10000; i++) { for(int i = 0; i < 0x10000; i++) {
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
(((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift); (((i & 0x7c00) >> 10) << systemBlueShift);
} }
if (lcd == 1) gbafilter_pal(systemColorMap16, 0x10000); if (lcd == 1) gbafilter_pal(systemColorMap16, 0x10000);
} }
break; break;
case 24: case 24:
case 32: case 32:
{ {
for(int i = 0; i < 0x10000; i++) { for(int i = 0; i < 0x10000; i++) {
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
(((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift); (((i & 0x7c00) >> 10) << systemBlueShift);
} }
if (lcd == 1) gbafilter_pal32(systemColorMap32, 0x10000); if (lcd == 1) gbafilter_pal32(systemColorMap32, 0x10000);
} }
break; break;
} }
} }
*/ */

View File

@ -1,5 +1,5 @@
#include "System.h" #include "System.h"
void gbafilter_pal(u16 * buf, int count); void gbafilter_pal(u16 * buf, int count);
void gbafilter_pal32(u32 * buf, int count); void gbafilter_pal32(u32 * buf, int count);
void gbafilter_pad(u8 * buf, int count); void gbafilter_pad(u8 * buf, int count);

View File

@ -489,15 +489,15 @@ void hq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
{ {
u16 *dst0 = (u16 *)dstPtr; u16 *dst0 = (u16 *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1); u16 *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr; u16 *src0 = (u16 *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1); u16 *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1); u16 *src2 = src1 + (srcPitch >> 1);
hq2x_16_def(dst0, dst1, src0, src0, src1, width); hq2x_16_def(dst0, dst1, src0, src0, src1, width);
int count = height; int count = height;
count -= 2; count -= 2;
while(count) { while(count) {
dst0 += dstPitch; dst0 += dstPitch;
@ -518,14 +518,14 @@ void hq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
{ {
u32 *dst0 = (u32 *)dstPtr; u32 *dst0 = (u32 *)dstPtr;
u32 *dst1 = dst0 + (dstPitch >> 2); u32 *dst1 = dst0 + (dstPitch >> 2);
u32 *src0 = (u32 *)srcPtr; u32 *src0 = (u32 *)srcPtr;
u32 *src1 = src0 + (srcPitch >> 2); u32 *src1 = src0 + (srcPitch >> 2);
u32 *src2 = src1 + (srcPitch >> 2); u32 *src2 = src1 + (srcPitch >> 2);
hq2x_32_def(dst0, dst1, src0, src0, src1, width); hq2x_32_def(dst0, dst1, src0, src0, src1, width);
int count = height; int count = height;
count -= 2; count -= 2;
while(count) { while(count) {
dst0 += dstPitch >> 1; dst0 += dstPitch >> 1;
@ -546,15 +546,15 @@ void lq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
{ {
u16 *dst0 = (u16 *)dstPtr; u16 *dst0 = (u16 *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1); u16 *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr; u16 *src0 = (u16 *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1); u16 *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1); u16 *src2 = src1 + (srcPitch >> 1);
lq2x_16_def(dst0, dst1, src0, src0, src1, width); lq2x_16_def(dst0, dst1, src0, src0, src1, width);
int count = height; int count = height;
count -= 2; count -= 2;
while(count) { while(count) {
dst0 += dstPitch; dst0 += dstPitch;
@ -575,14 +575,14 @@ void lq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
{ {
u32 *dst0 = (u32 *)dstPtr; u32 *dst0 = (u32 *)dstPtr;
u32 *dst1 = dst0 + (dstPitch >> 2); u32 *dst1 = dst0 + (dstPitch >> 2);
u32 *src0 = (u32 *)srcPtr; u32 *src0 = (u32 *)srcPtr;
u32 *src1 = src0 + (srcPitch >> 2); u32 *src1 = src0 + (srcPitch >> 2);
u32 *src2 = src1 + (srcPitch >> 2); u32 *src2 = src1 + (srcPitch >> 2);
lq2x_32_def(dst0, dst1, src0, src0, src1, width); lq2x_32_def(dst0, dst1, src0, src0, src1, width);
int count = height; int count = height;
count -= 2; count -= 2;
while(count) { while(count) {
dst0 += dstPitch >> 1; dst0 += dstPitch >> 1;

File diff suppressed because it is too large Load Diff

View File

@ -1,146 +1,146 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA development team // Copyright (C) 2005 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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 // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Util.h" #include "Util.h"
#define __STDC_CONSTANT_MACROS #define __STDC_CONSTANT_MACROS
#include <stdint.h> #include <stdint.h>
extern "C" extern "C"
{ {
void hq3x_16(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t); 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 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_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); void hq4x_32(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
unsigned int LUT16to32[65536]; unsigned int LUT16to32[65536];
unsigned int RGBtoYUV[65536]; unsigned int RGBtoYUV[65536];
} }
void InitLUTs(void) void InitLUTs(void)
{ {
int i, j, k, r, g, b, Y, u, v; int i, j, k, r, g, b, Y, u, v;
for (i=0; i<65536; i++) for (i=0; i<65536; i++)
LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3);
for (i=0; i<32; i++) for (i=0; i<32; i++)
for (j=0; j<64; j++) for (j=0; j<64; j++)
for (k=0; k<32; k++) for (k=0; k<32; k++)
{ {
r = i << 3; r = i << 3;
g = j << 2; g = j << 2;
b = k << 3; b = k << 3;
Y = (r + g + b) >> 2; Y = (r + g + b) >> 2;
u = 128 + ((r - b) >> 2); u = 128 + ((r - b) >> 2);
v = 128 + ((-r + 2*g -b)>>3); v = 128 + ((-r + 2*g -b)>>3);
RGBtoYUV[ (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v; RGBtoYUV[ (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v;
} }
} }
int hq3xinited=0; int hq3xinited=0;
extern int realsystemRedShift, realsystemBlueShift; extern int realsystemRedShift, realsystemBlueShift;
void hq3x32(unsigned char * pIn, unsigned int srcPitch, void hq3x32(unsigned char * pIn, unsigned int srcPitch,
unsigned char *, unsigned char *,
unsigned char * pOut, unsigned int dstPitch, unsigned char * pOut, unsigned int dstPitch,
int Xres, int Yres) int Xres, int Yres)
{ {
// NOTICE! This driver wants 16 bit, not 32 bit input! // NOTICE! This driver wants 16 bit, not 32 bit input!
if (!hq3xinited) if (!hq3xinited)
{ {
InitLUTs(); InitLUTs();
hq3xinited=1; hq3xinited=1;
} }
hq3x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2) ); hq3x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2) );
if (realsystemRedShift == 3) if (realsystemRedShift == 3)
{ // damn you opengl... { // damn you opengl...
int offset = (dstPitch - (Xres *12)) / 4; int offset = (dstPitch - (Xres *12)) / 4;
unsigned int *p = (unsigned int *)pOut; unsigned int *p = (unsigned int *)pOut;
Yres *= 3; Yres *= 3;
while(Yres--) while(Yres--)
{ {
for(int i=0;i<Xres*3;i++) for(int i=0;i<Xres*3;i++)
{ {
*p = (*p & 0xFF0000) >> 16 | *p = (*p & 0xFF0000) >> 16 |
(*p & 0x0000FF) << 16 | (*p & 0x0000FF) << 16 |
(*p & 0x00FF00); (*p & 0x00FF00);
p++; p++;
} }
p += offset; p += offset;
} }
} }
} }
void hq3x16(unsigned char * pIn, unsigned int srcPitch, void hq3x16(unsigned char * pIn, unsigned int srcPitch,
unsigned char *, unsigned char *,
unsigned char * pOut, unsigned int dstPitch, unsigned char * pOut, unsigned int dstPitch,
int Xres, int Yres) int Xres, int Yres)
{ {
if (!hq3xinited) if (!hq3xinited)
{ {
InitLUTs(); InitLUTs();
hq3xinited=1; hq3xinited=1;
} }
hq3x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2)); hq3x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
} }
void hq4x16(unsigned char * pIn, unsigned int srcPitch, void hq4x16(unsigned char * pIn, unsigned int srcPitch,
unsigned char *, unsigned char *,
unsigned char * pOut, unsigned int dstPitch, unsigned char * pOut, unsigned int dstPitch,
int Xres, int Yres) int Xres, int Yres)
{ {
if (!hq3xinited) if (!hq3xinited)
{ {
InitLUTs(); InitLUTs();
hq3xinited=1; hq3xinited=1;
} }
hq4x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2)); hq4x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
} }
void hq4x32(unsigned char * pIn, unsigned int srcPitch, void hq4x32(unsigned char * pIn, unsigned int srcPitch,
unsigned char *, unsigned char *,
unsigned char * pOut, unsigned int dstPitch, unsigned char * pOut, unsigned int dstPitch,
int Xres, int Yres) int Xres, int Yres)
{ {
// NOTICE! This driver wants 16 bit, not 32 bit input! // NOTICE! This driver wants 16 bit, not 32 bit input!
if (!hq3xinited) if (!hq3xinited)
{ {
InitLUTs(); InitLUTs();
hq3xinited=1; hq3xinited=1;
} }
hq4x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2)); hq4x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
if (realsystemRedShift == 3) if (realsystemRedShift == 3)
{ // damn you opengl... { // damn you opengl...
int offset = (dstPitch - (Xres *16)) / 4; int offset = (dstPitch - (Xres *16)) / 4;
unsigned int *p = (unsigned int *)pOut; unsigned int *p = (unsigned int *)pOut;
Yres *= 4; Yres *= 4;
while(Yres--) while(Yres--)
{ {
for(int i=0;i<Xres*4;i++) for(int i=0;i<Xres*4;i++)
{ {
*p = (*p & 0xFF0000) >> 16 | *p = (*p & 0xFF0000) >> 16 |
(*p & 0x0000FF) << 16 | (*p & 0x0000FF) << 16 |
(*p & 0x00FF00); (*p & 0x00FF00);
p++; p++;
} }
p += offset; p += offset;
} }
} }
} }

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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) void Interp4(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3)
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
#ifdef MMX #ifdef MMX
__asm __asm
{ {
mov eax, pc mov eax, pc
@ -290,7 +290,7 @@ bool Diff(unsigned int c1, unsigned int c2)
pcmpgtd mm4, trV pcmpgtd mm4, trV
por mm2, mm3 por mm2, mm3
por mm2, mm4 por mm2, mm4
movd retval, mm2 movd retval, mm2
EMMS EMMS

View File

@ -1,90 +1,90 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA development team // Copyright (C) 2005 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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 // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SIZE_PIXEL 4 // 32bit = 4 bytes #define SIZE_PIXEL 4 // 32bit = 4 bytes
#define abs32(value) (value & 0x7FFFFFFF) #define abs32(value) (value & 0x7FFFFFFF)
#define PIXEL00_1M Interp1( pOut, c[5], c[1] ); #define PIXEL00_1M Interp1( pOut, c[5], c[1] );
#define PIXEL00_1U Interp1( pOut, c[5], c[2] ); #define PIXEL00_1U Interp1( pOut, c[5], c[2] );
#define PIXEL00_1L Interp1( pOut, c[5], c[4] ); #define PIXEL00_1L Interp1( pOut, c[5], c[4] );
#define PIXEL00_2 Interp2( pOut, c[5], c[4], c[2] ); #define PIXEL00_2 Interp2( pOut, c[5], c[4], c[2] );
#define PIXEL00_4 Interp4( 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_5 Interp5( pOut, c[4], c[2] );
#define PIXEL00_C *((unsigned int*)(pOut)) = c[5]; #define PIXEL00_C *((unsigned int*)(pOut)) = c[5];
#define PIXEL01_1 Interp1( pOut+SIZE_PIXEL, c[5], c[2] ); #define PIXEL01_1 Interp1( pOut+SIZE_PIXEL, c[5], c[2] );
#define PIXEL01_3 Interp3( 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_6 Interp1( pOut+SIZE_PIXEL, c[2], c[5] );
#define PIXEL01_C *((unsigned int*)(pOut+4)) = 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_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_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_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_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_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_5 Interp5( pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6] );
#define PIXEL02_C *((unsigned int*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; #define PIXEL02_C *((unsigned int*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
#define PIXEL10_1 Interp1( pOut+dstPitch, c[5], c[4] ); #define PIXEL10_1 Interp1( pOut+dstPitch, c[5], c[4] );
#define PIXEL10_3 Interp3( 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_6 Interp1( pOut+dstPitch, c[4], c[5] );
#define PIXEL10_C *((unsigned int*)(pOut+dstPitch)) = c[5]; #define PIXEL10_C *((unsigned int*)(pOut+dstPitch)) = c[5];
#define PIXEL11 *((unsigned int*)(pOut+dstPitch+SIZE_PIXEL)) = 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_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_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_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 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_1M Interp1( pOut+dstPitch+dstPitch, c[5], c[7] );
#define PIXEL20_1D Interp1( pOut+dstPitch+dstPitch, c[5], c[8] ); #define PIXEL20_1D Interp1( pOut+dstPitch+dstPitch, c[5], c[8] );
#define PIXEL20_1L Interp1( pOut+dstPitch+dstPitch, c[5], c[4] ); #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_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_4 Interp4( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
#define PIXEL20_5 Interp5( pOut+dstPitch+dstPitch, 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 PIXEL20_C *((unsigned int*)(pOut+dstPitch+dstPitch)) = c[5];
#define PIXEL21_1 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] ); #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_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_6 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5] );
#define PIXEL21_C *((unsigned int*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = 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_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_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_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_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_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_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]; #define PIXEL22_C *((unsigned int*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
const int Ymask = 0x00FF0000; const int Ymask = 0x00FF0000;
const int Umask = 0x0000FF00; const int Umask = 0x0000FF00;
const int Vmask = 0x000000FF; const int Vmask = 0x000000FF;
const int trY = 0x00300000; const int trY = 0x00300000;
const int trU = 0x00000700; const int trU = 0x00000700;
const int trV = 0x00000006; const int trV = 0x00000006;
void Interp1(unsigned char * pc, unsigned int c1, unsigned int c2); 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 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 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 Interp4(unsigned char * pc, unsigned int c1, unsigned int c2, unsigned int c3);
void Interp5(unsigned char * pc, unsigned int c1, unsigned int c2); void Interp5(unsigned char * pc, unsigned int c1, unsigned int c2);
bool Diff(unsigned int c1, unsigned int c2); bool Diff(unsigned int c1, unsigned int c2);
unsigned int RGBtoYUV(unsigned int c); unsigned int RGBtoYUV(unsigned int c);

View File

@ -65,9 +65,9 @@ static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
u16 *src1 = (u16 *)frm1; u16 *src1 = (u16 *)frm1;
u16 *src2 = (u16 *)frm2; u16 *src2 = (u16 *)frm2;
u16 *src3 = (u16 *)frm3; u16 *src3 = (u16 *)frm3;
int count = width >> 2; int count = width >> 2;
for(int i = 0; i < height; i++) { for(int i = 0; i < height; i++) {
#ifdef __GNUC__ #ifdef __GNUC__
asm volatile ( asm volatile (
@ -97,15 +97,15 @@ static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
"paddw %%mm2, %%mm1\n" // E+F "paddw %%mm2, %%mm1\n" // E+F
"pand %%mm4, %%mm1\n" // (E+F) & res "pand %%mm4, %%mm1\n" // (E+F) & res
"pandn %%mm0, %%mm4\n" // color& !res "pandn %%mm0, %%mm4\n" // color& !res
"por %%mm1, %%mm4\n" "por %%mm1, %%mm4\n"
"movq %%mm4, 0(%0)\n" // src0 = res "movq %%mm4, 0(%0)\n" // src0 = res
"addl $8, %0\n" "addl $8, %0\n"
"addl $8, %1\n" "addl $8, %1\n"
"addl $8, %2\n" "addl $8, %2\n"
"addl $8, %3\n" "addl $8, %3\n"
"decl %4\n" "decl %4\n"
"jnz 0b\n" "jnz 0b\n"
"pop %4\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 mm1, qword ptr [ebx]; // src1
movq mm2, qword ptr [ecx]; // src2 movq mm2, qword ptr [ecx]; // src2
movq mm3, qword ptr [edx]; // src3 movq mm3, qword ptr [edx]; // src3
movq qword ptr [edx], mm0; // src3 = src0 movq qword ptr [edx], mm0; // src3 = src0
movq mm4, mm0; movq mm4, mm0;
movq mm5, mm1; movq mm5, mm1;
pcmpeqw mm5, mm2; // src1 == src2 (A) 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 paddw mm1, mm2; // E+F
pand mm1, mm4; // (E+F) & res pand mm1, mm4; // (E+F) & res
pandn mm4, mm0; // color & !res pandn mm4, mm0; // color & !res
por mm4, mm1; por mm4, mm1;
movq qword ptr [eax], mm4; // src0 = res movq qword ptr [eax], mm4; // src0 = res
add eax, 8; add eax, 8;
add ebx, 8; add ebx, 8;
add ecx, 8; add ecx, 8;
@ -168,12 +168,12 @@ static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
src2+=2; src2+=2;
src3+=2; src3+=2;
} }
/* Swap buffers around */ /* Swap buffers around */
u8 *temp = frm1; u8 *temp = frm1;
frm1 = frm3; frm1 = frm3;
frm3 = frm2; frm3 = frm2;
frm2 = temp; frm2 = temp;
} }
#endif #endif
@ -190,7 +190,7 @@ void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int height)
#endif #endif
u16 colorMask = ~RGB_LOW_BITS_MASK; u16 colorMask = ~RGB_LOW_BITS_MASK;
u16 *src0 = (u16 *)srcPtr; u16 *src0 = (u16 *)srcPtr;
u16 *src1 = (u16 *)frm1; u16 *src1 = (u16 *)frm1;
u16 *src2 = (u16 *)frm2; 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 */ src3[pos] = color; /* oldest buffer now holds newest frame */
pos++; pos++;
} }
/* Swap buffers around */ /* Swap buffers around */
u8 *temp = frm1; u8 *temp = frm1;
frm1 = frm3; frm1 = frm3;
@ -228,9 +228,9 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
u32 *src3 = (u32 *)frm3; u32 *src3 = (u32 *)frm3;
int count = width >> 1; int count = width >> 1;
for(int i = 0; i < height; i++) { for(int i = 0; i < height; i++) {
#ifdef __GNUC__ #ifdef __GNUC__
asm volatile ( asm volatile (
"push %4\n" "push %4\n"
"movq 0(%5), %%mm7\n" // colorMask "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 "paddd %%mm2, %%mm1\n" // E+F
"pand %%mm4, %%mm1\n" // (E+F) & res "pand %%mm4, %%mm1\n" // (E+F) & res
"pandn %%mm0, %%mm4\n" // color& !res "pandn %%mm0, %%mm4\n" // color& !res
"por %%mm1, %%mm4\n" "por %%mm1, %%mm4\n"
"movq %%mm4, 0(%0)\n" // src0 = res "movq %%mm4, 0(%0)\n" // src0 = res
"addl $8, %0\n" "addl $8, %0\n"
"addl $8, %1\n" "addl $8, %1\n"
"addl $8, %2\n" "addl $8, %2\n"
"addl $8, %3\n" "addl $8, %3\n"
"decl %4\n" "decl %4\n"
"jnz 0b\n" "jnz 0b\n"
"pop %4\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 mm1, qword ptr [ebx]; // src1
movq mm2, qword ptr [ecx]; // src2 movq mm2, qword ptr [ecx]; // src2
movq mm3, qword ptr [edx]; // src3 movq mm3, qword ptr [edx]; // src3
movq qword ptr [edx], mm0; // src3 = src0 movq qword ptr [edx], mm0; // src3 = src0
movq mm4, mm0; movq mm4, mm0;
movq mm5, mm1; movq mm5, mm1;
pcmpeqd mm5, mm2; // src1 == src2 (A) 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 paddd mm1, mm2; // E+F
pand mm1, mm4; // (E+F) & res pand mm1, mm4; // (E+F) & res
pandn mm4, mm0; // color & !res pandn mm4, mm0; // color & !res
por mm4, mm1; por mm4, mm1;
movq qword ptr [eax], mm4; // src0 = res movq qword ptr [eax], mm4; // src0 = res
add eax, 8; add eax, 8;
add ebx, 8; add ebx, 8;
add ecx, 8; add ecx, 8;
@ -324,7 +324,7 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
emms; emms;
} }
#endif #endif
src0++; src0++;
src1++; src1++;
src2++; src2++;
@ -334,7 +334,7 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
u8 *temp = frm1; u8 *temp = frm1;
frm1 = frm3; frm1 = frm3;
frm3 = frm2; frm3 = frm2;
frm2 = temp; frm2 = temp;
} }
#endif #endif
@ -349,7 +349,7 @@ void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int height)
return; return;
} }
#endif #endif
u32 *src0 = (u32 *)srcPtr; u32 *src0 = (u32 *)srcPtr;
u32 *src1 = (u32 *)frm1; u32 *src1 = (u32 *)frm1;
u32 *src2 = (u32 *)frm2; 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 */ src3[pos] = color; /* oldest buffer now holds newest frame */
pos++; pos++;
} }
/* Swap buffers around */ /* Swap buffers around */
u8 *temp = frm1; u8 *temp = frm1;
frm1 = frm3; frm1 = frm3;
@ -387,9 +387,9 @@ static void MotionBlurIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int height)
u16 *src1 = (u16 *)frm1; u16 *src1 = (u16 *)frm1;
int count = width >> 2; int count = width >> 2;
for(int i = 0; i < height; i++) { for(int i = 0; i < height; i++) {
#ifdef __GNUC__ #ifdef __GNUC__
asm volatile ( asm volatile (
"push %2\n" "push %2\n"
"movq 0(%3), %%mm7\n" // colorMask "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 "paddw %%mm1, %%mm0\n" // E+F
"movq %%mm0, 0(%0)\n" // src0 = res "movq %%mm0, 0(%0)\n" // src0 = res
"addl $8, %0\n" "addl $8, %0\n"
"addl $8, %1\n" "addl $8, %1\n"
"decl %2\n" "decl %2\n"
"jnz 0b\n" "jnz 0b\n"
"pop %2\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 paddw mm0, mm1; // E+F
movq qword ptr [eax], mm0; // src0 = res movq qword ptr [eax], mm0; // src0 = res
add eax, 8; add eax, 8;
add ebx, 8; add ebx, 8;
@ -461,9 +461,9 @@ void MotionBlurIB(u8 *srcPtr, u32 srcPitch, int width, int height)
return; return;
} }
#endif #endif
u16 colorMask = ~RGB_LOW_BITS_MASK; u16 colorMask = ~RGB_LOW_BITS_MASK;
u16 *src0 = (u16 *)srcPtr; u16 *src0 = (u16 *)srcPtr;
u16 *src1 = (u16 *)frm1; 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 *src0 = (u32 *)srcPtr;
u32 *src1 = (u32 *)frm1; u32 *src1 = (u32 *)frm1;
int count = width >> 1; int count = width >> 1;
for(int i = 0; i < height; i++) { for(int i = 0; i < height; i++) {
#ifdef __GNUC__ #ifdef __GNUC__
asm volatile ( asm volatile (
"push %2\n" "push %2\n"
"movq 0(%3), %%mm7\n" // colorMask "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 "paddd %%mm1, %%mm0\n" // E+F
"movq %%mm0, 0(%0)\n" // src0 = res "movq %%mm0, 0(%0)\n" // src0 = res
"addl $8, %0\n" "addl $8, %0\n"
"addl $8, %1\n" "addl $8, %1\n"
"decl %2\n" "decl %2\n"
"jnz 0b\n" "jnz 0b\n"
"pop %2\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 paddd mm0, mm1; // E+F
movq qword ptr [eax], mm0; // src0 = res movq qword ptr [eax], mm0; // src0 = res
add eax, 8; add eax, 8;
add ebx, 8; add ebx, 8;
@ -561,7 +561,7 @@ void MotionBlurIB32(u8 *srcPtr, u32 srcPitch, int width, int height)
return; return;
} }
#endif #endif
u32 *src0 = (u32 *)srcPtr; u32 *src0 = (u32 *)srcPtr;
u32 *src1 = (u32 *)frm1; u32 *src1 = (u32 *)frm1;

View File

@ -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 */ c[i] = sin(2.0*temp*frq)/temp; /* Analog sinc function, cutoff = frq */
} }
/* /*
* Calculate and Apply Kaiser window to ideal lowpass filter. * Calculate and Apply Kaiser window to ideal lowpass filter.
* Note: last window value is IBeta which is NOT zero. * Note: last window value is IBeta which is NOT zero.
* You're supposed to really truncate the window here, not ramp * 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); IBeta = 1.0/Izero(Beta);
inm1 = 1.0/((double)(N-1)); inm1 = 1.0/((double)(N-1));
@ -125,7 +125,7 @@ float lrsFilterUp(float Imp[], /* impulse response */
float v, t; float v, t;
Ph *= Npc; /* Npc is number of values per 1/delta in impulse response */ Ph *= Npc; /* Npc is number of values per 1/delta in impulse response */
v = 0.0; /* The output value */ v = 0.0; /* The output value */
Hp = &Imp[(int)Ph]; Hp = &Imp[(int)Ph];
End = &Imp[Nwing]; End = &Imp[Nwing];
@ -153,8 +153,8 @@ float lrsFilterUp(float Imp[], /* impulse response */
v += t; /* The filter output */ v += t; /* The filter output */
Hp += Npc; /* Filter coeff step */ Hp += Npc; /* Filter coeff step */
Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */ Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */
} }
else else
while (Hp < End) { while (Hp < End) {
t = *Hp; /* Get filter coeff */ t = *Hp; /* Get filter coeff */
t *= *Xp; /* Mult coeff by input sample */ t *= *Xp; /* Mult coeff by input sample */
@ -162,7 +162,7 @@ float lrsFilterUp(float Imp[], /* impulse response */
Hp += Npc; /* Filter coeff step */ Hp += Npc; /* Filter coeff step */
Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */ Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */
} }
return v; return v;
} }
@ -179,7 +179,7 @@ float lrsFilterUD(float Imp[], /* impulse response */
float *Hp, *Hdp, *End; float *Hp, *Hdp, *End;
float v, t; float v, t;
double Ho; double Ho;
v = 0.0; /* The output value */ v = 0.0; /* The output value */
Ho = Ph*dhb; Ho = Ph*dhb;
End = &Imp[Nwing]; End = &Imp[Nwing];
@ -202,7 +202,7 @@ float lrsFilterUD(float Imp[], /* impulse response */
Ho += dhb; /* IR step */ Ho += dhb; /* IR step */
Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */ Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */
} }
else else
while ((Hp = &Imp[(int)Ho]) < End) { while ((Hp = &Imp[(int)Ho]) < End) {
t = *Hp; /* Get IR sample */ t = *Hp; /* Get IR sample */
t *= *Xp; /* Mult coeff by input sample */ t *= *Xp; /* Mult coeff by input sample */

View File

@ -73,7 +73,7 @@ void *resample_dup(const void * handle)
memcpy(hp->Y, cpy->Y, hp->YSize * sizeof(float)); memcpy(hp->Y, cpy->Y, hp->YSize * sizeof(float));
hp->Yp = cpy->Yp; hp->Yp = cpy->Yp;
hp->Time = cpy->Time; hp->Time = cpy->Time;
return (void *)hp; return (void *)hp;
} }
@ -100,7 +100,7 @@ void *resample_open(int highQuality, double minFactor, double maxFactor)
hp->minFactor = minFactor; hp->minFactor = minFactor;
hp->maxFactor = maxFactor; hp->maxFactor = maxFactor;
if (highQuality) if (highQuality)
hp->Nmult = 35; hp->Nmult = 35;
else 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->X = (float *)malloc((hp->XSize + hp->Xoff) * sizeof(float));
hp->Xp = hp->Xoff; hp->Xp = hp->Xoff;
hp->Xread = hp->Xoff; hp->Xread = hp->Xoff;
/* Need Xoff zeros at begining of X buffer */ /* Need Xoff zeros at begining of X buffer */
for(i=0; i<hp->Xoff; i++) for(i=0; i<hp->Xoff; i++)
hp->X[i]=0; hp->X[i]=0;
@ -157,7 +157,7 @@ void *resample_open(int highQuality, double minFactor, double maxFactor)
hp->Yp = 0; hp->Yp = 0;
hp->Time = (double)hp->Xoff; /* Current-time pointer for converter */ hp->Time = (double)hp->Xoff; /* Current-time pointer for converter */
return (void *)hp; return (void *)hp;
} }
@ -280,7 +280,7 @@ int resample_process(void *handle,
#ifdef DEBUG #ifdef DEBUG
printf("Nout: %d\n", Nout); printf("Nout: %d\n", Nout);
#endif #endif
hp->Time -= Nx; /* Move converter Nx samples back in time */ hp->Time -= Nx; /* Move converter Nx samples back in time */
hp->Xp += Nx; /* Advance by number of samples processed */ 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->Xread = Nreuse; /* Pos in input buff to read new data into */
hp->Xp = hp->Xoff; hp->Xp = hp->Xoff;
/* Check to see if output buff overflowed (shouldn't happen!) */ /* Check to see if output buff overflowed (shouldn't happen!) */
if (Nout > hp->YSize) { if (Nout > hp->YSize) {
#ifdef DEBUG #ifdef DEBUG

View File

@ -40,13 +40,13 @@ int lrsSrcUp(float X[],
{ {
float *Xp, *Ystart; float *Xp, *Ystart;
float v; float v;
double CurrentTime = *TimePtr; double CurrentTime = *TimePtr;
double dt; /* Step through input signal */ double dt; /* Step through input signal */
double endTime; /* When Time reaches EndTime, return to user */ double endTime; /* When Time reaches EndTime, return to user */
dt = 1.0/factor; /* Output sampling period */ dt = 1.0/factor; /* Output sampling period */
Ystart = Y; Ystart = Y;
endTime = CurrentTime + Nx; endTime = CurrentTime + Nx;
while (CurrentTime < endTime) while (CurrentTime < endTime)
@ -59,7 +59,7 @@ int lrsSrcUp(float X[],
v = lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp, v = lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp,
LeftPhase, -1); LeftPhase, -1);
/* Perform right-wing inner product */ /* Perform right-wing inner product */
v += lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp+1, v += lrsFilterUp(Imp, ImpD, Nwing, Interp, Xp+1,
RightPhase, 1); RightPhase, 1);
v *= LpScl; /* Normalize for unity filter gain */ v *= LpScl; /* Normalize for unity filter gain */
@ -92,11 +92,11 @@ int lrsSrcUD(float X[],
double dh; /* Step through filter impulse response */ double dh; /* Step through filter impulse response */
double dt; /* Step through input signal */ double dt; /* Step through input signal */
double endTime; /* When Time reaches EndTime, return to user */ double endTime; /* When Time reaches EndTime, return to user */
dt = 1.0/factor; /* Output sampling period */ dt = 1.0/factor; /* Output sampling period */
dh = MIN(Npc, factor*Npc); /* Filter sampling period */ dh = MIN(Npc, factor*Npc); /* Filter sampling period */
Ystart = Y; Ystart = Y;
endTime = CurrentTime + Nx; endTime = CurrentTime + Nx;
while (CurrentTime < endTime) while (CurrentTime < endTime)
@ -109,12 +109,12 @@ int lrsSrcUD(float X[],
v = lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp, v = lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp,
LeftPhase, -1, dh); LeftPhase, -1, dh);
/* Perform right-wing inner product */ /* Perform right-wing inner product */
v += lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp+1, v += lrsFilterUD(Imp, ImpD, Nwing, Interp, Xp+1,
RightPhase, 1, dh); RightPhase, 1, dh);
v *= LpScl; /* Normalize for unity filter gain */ v *= LpScl; /* Normalize for unity filter gain */
*Y++ = v; /* Deposit output */ *Y++ = v; /* Deposit output */
CurrentTime += dt; /* Move to next sample by time increment */ CurrentTime += dt; /* Move to next sample by time increment */
} }

View File

@ -105,7 +105,7 @@ int main(int argc, char **argv)
dstinfo.format = formatinfo.format | dstinfo.format = formatinfo.format |
(srcinfo.format & SF_FORMAT_SUBMASK); (srcinfo.format & SF_FORMAT_SUBMASK);
break; break;
} }
} }
} }

View File

@ -79,7 +79,7 @@ void runtest(int srclen, double freq, double factor,
printf(" Expected ~%d, got %d samples out\n", printf(" Expected ~%d, got %d samples out\n",
expectedlen, out); expectedlen, out);
} }
sum = 0.0; sum = 0.0;
sumsq = 0.0; sumsq = 0.0;
errcount = 0.0; errcount = 0.0;

View File

@ -1,141 +1,141 @@
case 0 : case 0 :
case 2 : case 2 :
case 4 : case 4 :
case 6 : case 6 :
case 8 : case 8 :
case 12 : case 12 :
case 16 : case 16 :
case 20 : case 20 :
case 24 : case 24 :
case 28 : case 28 :
case 32 : case 32 :
case 34 : case 34 :
case 36 : case 36 :
case 38 : case 38 :
case 40 : case 40 :
case 44 : case 44 :
case 48 : case 48 :
case 52 : case 52 :
case 56 : case 56 :
case 60 : case 60 :
case 64 : case 64 :
case 66 : case 66 :
case 68 : case 68 :
case 70 : case 70 :
case 96 : case 96 :
case 98 : case 98 :
case 100 : case 100 :
case 102 : case 102 :
case 128 : case 128 :
case 130 : case 130 :
case 132 : case 132 :
case 134 : case 134 :
case 136 : case 136 :
case 140 : case 140 :
case 144 : case 144 :
case 148 : case 148 :
case 152 : case 152 :
case 156 : case 156 :
case 160 : case 160 :
case 162 : case 162 :
case 164 : case 164 :
case 166 : case 166 :
case 168 : case 168 :
case 172 : case 172 :
case 176 : case 176 :
case 180 : case 180 :
case 184 : case 184 :
case 188 : case 188 :
case 192 : case 192 :
case 194 : case 194 :
case 196 : case 196 :
case 198 : case 198 :
case 224 : case 224 :
case 226 : case 226 :
case 228 : case 228 :
case 230 : case 230 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
P2 = IC(0); P2 = IC(0);
P3 = IC(0); P3 = IC(0);
} break; } break;
case 1 : case 1 :
case 5 : case 5 :
case 9 : case 9 :
case 13 : case 13 :
case 17 : case 17 :
case 21 : case 21 :
case 25 : case 25 :
case 29 : case 29 :
case 33 : case 33 :
case 37 : case 37 :
case 41 : case 41 :
case 45 : case 45 :
case 49 : case 49 :
case 53 : case 53 :
case 57 : case 57 :
case 61 : case 61 :
case 65 : case 65 :
case 69 : case 69 :
case 97 : case 97 :
case 101 : case 101 :
case 129 : case 129 :
case 133 : case 133 :
case 137 : case 137 :
case 141 : case 141 :
case 145 : case 145 :
case 149 : case 149 :
case 153 : case 153 :
case 157 : case 157 :
case 161 : case 161 :
case 165 : case 165 :
case 169 : case 169 :
case 173 : case 173 :
case 177 : case 177 :
case 181 : case 181 :
case 185 : case 185 :
case 189 : case 189 :
case 193 : case 193 :
case 197 : case 197 :
case 225 : case 225 :
case 229 : case 229 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
P2 = IC(1); P2 = IC(1);
P3 = IC(1); P3 = IC(1);
} break; } break;
case 3 : case 3 :
case 35 : case 35 :
case 67 : case 67 :
case 99 : case 99 :
case 131 : case 131 :
case 163 : case 163 :
case 195 : case 195 :
case 227 : case 227 :
{ {
P0 = IC(2); P0 = IC(2);
P1 = IC(2); P1 = IC(2);
P2 = IC(2); P2 = IC(2);
P3 = IC(2); P3 = IC(2);
} break; } break;
case 7 : case 7 :
case 39 : case 39 :
case 71 : case 71 :
case 103 : case 103 :
case 135 : case 135 :
case 167 : case 167 :
case 199 : case 199 :
case 231 : case 231 :
{ {
P0 = IC(3); P0 = IC(3);
P1 = IC(3); P1 = IC(3);
P2 = IC(3); P2 = IC(3);
P3 = IC(3); P3 = IC(3);
} break; } break;
case 10 : case 10 :
case 138 : case 138 :
{ {
P1 = IC(0); P1 = IC(0);
P2 = IC(0); P2 = IC(0);
@ -146,12 +146,12 @@ case 138 :
P0 = I211(0, 1, 3); P0 = I211(0, 1, 3);
} }
} break; } break;
case 11 : case 11 :
case 27 : case 27 :
case 75 : case 75 :
case 139 : case 139 :
case 155 : case 155 :
case 203 : case 203 :
{ {
P1 = IC(2); P1 = IC(2);
P2 = IC(2); P2 = IC(2);
@ -162,8 +162,8 @@ case 203 :
P0 = I211(2, 1, 3); P0 = I211(2, 1, 3);
} }
} break; } break;
case 14 : case 14 :
case 142 : case 142 :
{ {
P2 = IC(0); P2 = IC(0);
P3 = IC(0); P3 = IC(0);
@ -175,9 +175,9 @@ case 142 :
P1 = I31(0, 1); P1 = I31(0, 1);
} }
} break; } break;
case 15 : case 15 :
case 143 : case 143 :
case 207 : case 207 :
{ {
P2 = IC(4); P2 = IC(4);
P3 = IC(4); P3 = IC(4);
@ -189,14 +189,14 @@ case 207 :
P1 = I31(4, 1); P1 = I31(4, 1);
} }
} break; } break;
case 18 : case 18 :
case 22 : case 22 :
case 30 : case 30 :
case 50 : case 50 :
case 54 : case 54 :
case 62 : case 62 :
case 86 : case 86 :
case 118 : case 118 :
{ {
P0 = IC(0); P0 = IC(0);
P2 = IC(0); P2 = IC(0);
@ -207,8 +207,8 @@ case 118 :
P1 = I211(0, 1, 5); P1 = I211(0, 1, 5);
} }
} break; } break;
case 19 : case 19 :
case 51 : case 51 :
{ {
P2 = IC(2); P2 = IC(2);
P3 = IC(2); P3 = IC(2);
@ -220,9 +220,9 @@ case 51 :
P1 = I332(1, 5, 2); P1 = I332(1, 5, 2);
} }
} break; } break;
case 23 : case 23 :
case 55 : case 55 :
case 119 : case 119 :
{ {
P2 = IC(3); P2 = IC(3);
P3 = IC(3); P3 = IC(3);
@ -234,7 +234,7 @@ case 119 :
P1 = I332(1, 5, 3); P1 = I332(1, 5, 3);
} }
} break; } break;
case 26 : case 26 :
{ {
P2 = IC(0); P2 = IC(0);
P3 = IC(0); P3 = IC(0);
@ -249,8 +249,8 @@ case 26 :
P1 = I211(0, 1, 5); P1 = I211(0, 1, 5);
} }
} break; } break;
case 31 : case 31 :
case 95 : case 95 :
{ {
P2 = IC(4); P2 = IC(4);
P3 = IC(4); P3 = IC(4);
@ -265,8 +265,8 @@ case 95 :
P1 = I211(4, 1, 5); P1 = I211(4, 1, 5);
} }
} break; } break;
case 42 : case 42 :
case 170 : case 170 :
{ {
P1 = IC(0); P1 = IC(0);
P3 = IC(0); P3 = IC(0);
@ -278,9 +278,9 @@ case 170 :
P2 = I31(0, 3); P2 = I31(0, 3);
} }
} break; } break;
case 43 : case 43 :
case 171 : case 171 :
case 187 : case 187 :
{ {
P1 = IC(2); P1 = IC(2);
P3 = IC(2); P3 = IC(2);
@ -292,8 +292,8 @@ case 187 :
P2 = I31(2, 3); P2 = I31(2, 3);
} }
} break; } break;
case 46 : case 46 :
case 174 : case 174 :
{ {
P1 = IC(0); P1 = IC(0);
P2 = IC(0); P2 = IC(0);
@ -304,8 +304,8 @@ case 174 :
P0 = I611(0, 1, 3); P0 = I611(0, 1, 3);
} }
} break; } break;
case 47 : case 47 :
case 175 : case 175 :
{ {
P1 = IC(4); P1 = IC(4);
P2 = IC(4); P2 = IC(4);
@ -316,9 +316,9 @@ case 175 :
P0 = I1411(4, 1, 3); P0 = I1411(4, 1, 3);
} }
} break; } break;
case 58 : case 58 :
case 154 : case 154 :
case 186 : case 186 :
{ {
P2 = IC(0); P2 = IC(0);
P3 = IC(0); P3 = IC(0);
@ -333,7 +333,7 @@ case 186 :
P1 = I611(0, 1, 5); P1 = I611(0, 1, 5);
} }
} break; } break;
case 59 : case 59 :
{ {
P2 = IC(2); P2 = IC(2);
P3 = IC(2); P3 = IC(2);
@ -348,7 +348,7 @@ case 59 :
P1 = I611(2, 1, 5); P1 = I611(2, 1, 5);
} }
} break; } break;
case 63 : case 63 :
{ {
P2 = IC(4); P2 = IC(4);
P3 = IC(4); P3 = IC(4);
@ -363,14 +363,14 @@ case 63 :
P1 = I211(4, 1, 5); P1 = I211(4, 1, 5);
} }
} break; } break;
case 72 : case 72 :
case 76 : case 76 :
case 104 : case 104 :
case 106 : case 106 :
case 108 : case 108 :
case 110 : case 110 :
case 120 : case 120 :
case 124 : case 124 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
@ -381,11 +381,11 @@ case 124 :
P2 = I211(0, 3, 7); P2 = I211(0, 3, 7);
} }
} break; } break;
case 73 : case 73 :
case 77 : case 77 :
case 105 : case 105 :
case 109 : case 109 :
case 125 : case 125 :
{ {
P1 = IC(1); P1 = IC(1);
P3 = IC(1); P3 = IC(1);
@ -397,7 +397,7 @@ case 125 :
P2 = I332(3, 7, 1); P2 = I332(3, 7, 1);
} }
} break; } break;
case 74 : case 74 :
{ {
P1 = IC(0); P1 = IC(0);
P3 = IC(0); P3 = IC(0);
@ -412,9 +412,9 @@ case 74 :
P0 = I211(0, 1, 3); P0 = I211(0, 1, 3);
} }
} break; } break;
case 78 : case 78 :
case 202 : case 202 :
case 206 : case 206 :
{ {
P1 = IC(0); P1 = IC(0);
P3 = IC(0); P3 = IC(0);
@ -429,7 +429,7 @@ case 206 :
P0 = I611(0, 1, 3); P0 = I611(0, 1, 3);
} }
} break; } break;
case 79 : case 79 :
{ {
P1 = IC(4); P1 = IC(4);
P3 = IC(4); P3 = IC(4);
@ -444,10 +444,10 @@ case 79 :
P0 = I211(4, 1, 3); P0 = I211(4, 1, 3);
} }
} break; } break;
case 80 : case 80 :
case 208 : case 208 :
case 210 : case 210 :
case 216 : case 216 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
@ -458,9 +458,9 @@ case 216 :
P3 = I211(0, 5, 7); P3 = I211(0, 5, 7);
} }
} break; } break;
case 81 : case 81 :
case 209 : case 209 :
case 217 : case 217 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
@ -471,9 +471,9 @@ case 217 :
P3 = I211(1, 5, 7); P3 = I211(1, 5, 7);
} }
} break; } break;
case 82 : case 82 :
case 214 : case 214 :
case 222 : case 222 :
{ {
P0 = IC(0); P0 = IC(0);
P2 = IC(0); P2 = IC(0);
@ -488,8 +488,8 @@ case 222 :
P1 = I211(0, 1, 5); P1 = I211(0, 1, 5);
} }
} break; } break;
case 83 : case 83 :
case 115 : case 115 :
{ {
P0 = IC(2); P0 = IC(2);
P2 = IC(2); P2 = IC(2);
@ -504,8 +504,8 @@ case 115 :
P1 = I611(2, 1, 5); P1 = I611(2, 1, 5);
} }
} break; } break;
case 84 : case 84 :
case 212 : case 212 :
{ {
P0 = IC(0); P0 = IC(0);
P2 = IC(0); P2 = IC(0);
@ -517,9 +517,9 @@ case 212 :
P3 = I332(5, 7, 0); P3 = I332(5, 7, 0);
} }
} break; } break;
case 85 : case 85 :
case 213 : case 213 :
case 221 : case 221 :
{ {
P0 = IC(1); P0 = IC(1);
P2 = IC(1); P2 = IC(1);
@ -531,7 +531,7 @@ case 221 :
P3 = I332(5, 7, 1); P3 = I332(5, 7, 1);
} }
} break; } break;
case 87 : case 87 :
{ {
P0 = IC(3); P0 = IC(3);
P2 = IC(3); P2 = IC(3);
@ -546,9 +546,9 @@ case 87 :
P1 = I211(3, 1, 5); P1 = I211(3, 1, 5);
} }
} break; } break;
case 88 : case 88 :
case 248 : case 248 :
case 250 : case 250 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
@ -563,8 +563,8 @@ case 250 :
P3 = I211(0, 5, 7); P3 = I211(0, 5, 7);
} }
} break; } break;
case 89 : case 89 :
case 93 : case 93 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
@ -579,7 +579,7 @@ case 93 :
P3 = I611(1, 5, 7); P3 = I611(1, 5, 7);
} }
} break; } break;
case 90 : case 90 :
{ {
if (MDL) { if (MDL) {
P2 = IC(0); P2 = IC(0);
@ -602,7 +602,7 @@ case 90 :
P1 = I611(0, 1, 5); P1 = I611(0, 1, 5);
} }
} break; } break;
case 91 : case 91 :
{ {
if (MDL) { if (MDL) {
P2 = IC(2); P2 = IC(2);
@ -625,7 +625,7 @@ case 91 :
P1 = I611(2, 1, 5); P1 = I611(2, 1, 5);
} }
} break; } break;
case 92 : case 92 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
@ -640,7 +640,7 @@ case 92 :
P3 = I611(0, 5, 7); P3 = I611(0, 5, 7);
} }
} break; } break;
case 94 : case 94 :
{ {
if (MDL) { if (MDL) {
P2 = IC(0); P2 = IC(0);
@ -663,8 +663,8 @@ case 94 :
P1 = I211(0, 1, 5); P1 = I211(0, 1, 5);
} }
} break; } break;
case 107 : case 107 :
case 123 : case 123 :
{ {
P1 = IC(2); P1 = IC(2);
P3 = IC(2); P3 = IC(2);
@ -679,7 +679,7 @@ case 123 :
P0 = I211(2, 1, 3); P0 = I211(2, 1, 3);
} }
} break; } break;
case 111 : case 111 :
{ {
P1 = IC(4); P1 = IC(4);
P3 = IC(4); P3 = IC(4);
@ -694,8 +694,8 @@ case 111 :
P0 = I1411(4, 1, 3); P0 = I1411(4, 1, 3);
} }
} break; } break;
case 112 : case 112 :
case 240 : case 240 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
@ -707,8 +707,8 @@ case 240 :
P3 = I332(5, 7, 0); P3 = I332(5, 7, 0);
} }
} break; } break;
case 113 : case 113 :
case 241 : case 241 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
@ -720,7 +720,7 @@ case 241 :
P3 = I332(5, 7, 1); P3 = I332(5, 7, 1);
} }
} break; } break;
case 114 : case 114 :
{ {
P0 = IC(0); P0 = IC(0);
P2 = IC(0); P2 = IC(0);
@ -735,7 +735,7 @@ case 114 :
P1 = I611(0, 1, 5); P1 = I611(0, 1, 5);
} }
} break; } break;
case 116 : case 116 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
@ -746,7 +746,7 @@ case 116 :
P3 = I611(0, 5, 7); P3 = I611(0, 5, 7);
} }
} break; } break;
case 117 : case 117 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
@ -757,7 +757,7 @@ case 117 :
P3 = I611(1, 5, 7); P3 = I611(1, 5, 7);
} }
} break; } break;
case 121 : case 121 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
@ -772,7 +772,7 @@ case 121 :
P3 = I611(1, 5, 7); P3 = I611(1, 5, 7);
} }
} break; } break;
case 122 : case 122 :
{ {
if (MDL) { if (MDL) {
P2 = IC(0); P2 = IC(0);
@ -795,7 +795,7 @@ case 122 :
P1 = I611(0, 1, 5); P1 = I611(0, 1, 5);
} }
} break; } break;
case 126 : case 126 :
{ {
P0 = IC(0); P0 = IC(0);
P3 = IC(0); P3 = IC(0);
@ -810,7 +810,7 @@ case 126 :
P1 = I211(0, 1, 5); P1 = I211(0, 1, 5);
} }
} break; } break;
case 127 : case 127 :
{ {
P3 = IC(4); P3 = IC(4);
if (MDL) { if (MDL) {
@ -829,11 +829,11 @@ case 127 :
P1 = I211(4, 1, 5); P1 = I211(4, 1, 5);
} }
} break; } break;
case 146 : case 146 :
case 150 : case 150 :
case 178 : case 178 :
case 182 : case 182 :
case 190 : case 190 :
{ {
P0 = IC(0); P0 = IC(0);
P2 = IC(0); P2 = IC(0);
@ -845,8 +845,8 @@ case 190 :
P3 = I31(0, 5); P3 = I31(0, 5);
} }
} break; } break;
case 147 : case 147 :
case 179 : case 179 :
{ {
P0 = IC(2); P0 = IC(2);
P2 = IC(2); P2 = IC(2);
@ -857,8 +857,8 @@ case 179 :
P1 = I611(2, 1, 5); P1 = I611(2, 1, 5);
} }
} break; } break;
case 151 : case 151 :
case 183 : case 183 :
{ {
P0 = IC(3); P0 = IC(3);
P2 = IC(3); P2 = IC(3);
@ -869,7 +869,7 @@ case 183 :
P1 = I1411(3, 1, 5); P1 = I1411(3, 1, 5);
} }
} break; } break;
case 158 : case 158 :
{ {
P2 = IC(0); P2 = IC(0);
P3 = IC(0); P3 = IC(0);
@ -884,7 +884,7 @@ case 158 :
P1 = I211(0, 1, 5); P1 = I211(0, 1, 5);
} }
} break; } break;
case 159 : case 159 :
{ {
P2 = IC(4); P2 = IC(4);
P3 = IC(4); P3 = IC(4);
@ -899,7 +899,7 @@ case 159 :
P1 = I1411(4, 1, 5); P1 = I1411(4, 1, 5);
} }
} break; } break;
case 191 : case 191 :
{ {
P2 = IC(4); P2 = IC(4);
P3 = IC(4); P3 = IC(4);
@ -914,11 +914,11 @@ case 191 :
P1 = I1411(4, 1, 5); P1 = I1411(4, 1, 5);
} }
} break; } break;
case 200 : case 200 :
case 204 : case 204 :
case 232 : case 232 :
case 236 : case 236 :
case 238 : case 238 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
@ -930,8 +930,8 @@ case 238 :
P3 = I31(0, 7); P3 = I31(0, 7);
} }
} break; } break;
case 201 : case 201 :
case 205 : case 205 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
@ -942,7 +942,7 @@ case 205 :
P2 = I611(1, 3, 7); P2 = I611(1, 3, 7);
} }
} break; } break;
case 211 : case 211 :
{ {
P0 = IC(2); P0 = IC(2);
P1 = IC(2); P1 = IC(2);
@ -953,7 +953,7 @@ case 211 :
P3 = I211(2, 5, 7); P3 = I211(2, 5, 7);
} }
} break; } break;
case 215 : case 215 :
{ {
P0 = IC(3); P0 = IC(3);
P2 = IC(3); P2 = IC(3);
@ -968,7 +968,7 @@ case 215 :
P1 = I1411(3, 1, 5); P1 = I1411(3, 1, 5);
} }
} break; } break;
case 218 : case 218 :
{ {
if (MDL) { if (MDL) {
P2 = IC(0); P2 = IC(0);
@ -991,7 +991,7 @@ case 218 :
P1 = I611(0, 1, 5); P1 = I611(0, 1, 5);
} }
} break; } break;
case 219 : case 219 :
{ {
P1 = IC(2); P1 = IC(2);
P2 = IC(2); P2 = IC(2);
@ -1006,7 +1006,7 @@ case 219 :
P0 = I211(2, 1, 3); P0 = I211(2, 1, 3);
} }
} break; } break;
case 220 : case 220 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
@ -1021,7 +1021,7 @@ case 220 :
P3 = I211(0, 5, 7); P3 = I211(0, 5, 7);
} }
} break; } break;
case 223 : case 223 :
{ {
P2 = IC(4); P2 = IC(4);
if (MDR) { if (MDR) {
@ -1040,8 +1040,8 @@ case 223 :
P1 = I1411(4, 1, 5); P1 = I1411(4, 1, 5);
} }
} break; } break;
case 233 : case 233 :
case 237 : case 237 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
@ -1052,7 +1052,7 @@ case 237 :
P2 = I1411(1, 3, 7); P2 = I1411(1, 3, 7);
} }
} break; } break;
case 234 : case 234 :
{ {
P1 = IC(0); P1 = IC(0);
P3 = IC(0); P3 = IC(0);
@ -1067,7 +1067,7 @@ case 234 :
P0 = I611(0, 1, 3); P0 = I611(0, 1, 3);
} }
} break; } break;
case 235 : case 235 :
{ {
P1 = IC(2); P1 = IC(2);
P3 = IC(2); P3 = IC(2);
@ -1082,7 +1082,7 @@ case 235 :
P0 = I211(2, 1, 3); P0 = I211(2, 1, 3);
} }
} break; } break;
case 239 : case 239 :
{ {
P1 = IC(4); P1 = IC(4);
P3 = IC(4); P3 = IC(4);
@ -1097,7 +1097,7 @@ case 239 :
P0 = I1411(4, 1, 3); P0 = I1411(4, 1, 3);
} }
} break; } break;
case 242 : case 242 :
{ {
P0 = IC(0); P0 = IC(0);
P2 = IC(0); P2 = IC(0);
@ -1112,7 +1112,7 @@ case 242 :
P1 = I611(0, 1, 5); P1 = I611(0, 1, 5);
} }
} break; } break;
case 243 : case 243 :
{ {
P0 = IC(2); P0 = IC(2);
P1 = IC(2); P1 = IC(2);
@ -1124,7 +1124,7 @@ case 243 :
P3 = I332(5, 7, 2); P3 = I332(5, 7, 2);
} }
} break; } break;
case 244 : case 244 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
@ -1135,7 +1135,7 @@ case 244 :
P3 = I1411(0, 5, 7); P3 = I1411(0, 5, 7);
} }
} break; } break;
case 245 : case 245 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
@ -1146,7 +1146,7 @@ case 245 :
P3 = I1411(1, 5, 7); P3 = I1411(1, 5, 7);
} }
} break; } break;
case 246 : case 246 :
{ {
P0 = IC(0); P0 = IC(0);
P2 = IC(0); P2 = IC(0);
@ -1161,7 +1161,7 @@ case 246 :
P1 = I211(0, 1, 5); P1 = I211(0, 1, 5);
} }
} break; } break;
case 247 : case 247 :
{ {
P0 = IC(3); P0 = IC(3);
P2 = IC(3); P2 = IC(3);
@ -1176,7 +1176,7 @@ case 247 :
P1 = I1411(3, 1, 5); P1 = I1411(3, 1, 5);
} }
} break; } break;
case 249 : case 249 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
@ -1191,7 +1191,7 @@ case 249 :
P3 = I211(1, 5, 7); P3 = I211(1, 5, 7);
} }
} break; } break;
case 251 : case 251 :
{ {
P1 = IC(2); P1 = IC(2);
if (MDL) { if (MDL) {
@ -1210,7 +1210,7 @@ case 251 :
P0 = I211(2, 1, 3); P0 = I211(2, 1, 3);
} }
} break; } break;
case 252 : case 252 :
{ {
P0 = IC(0); P0 = IC(0);
P1 = IC(0); P1 = IC(0);
@ -1225,7 +1225,7 @@ case 252 :
P3 = I1411(0, 5, 7); P3 = I1411(0, 5, 7);
} }
} break; } break;
case 253 : case 253 :
{ {
P0 = IC(1); P0 = IC(1);
P1 = IC(1); P1 = IC(1);
@ -1240,7 +1240,7 @@ case 253 :
P3 = I1411(1, 5, 7); P3 = I1411(1, 5, 7);
} }
} break; } break;
case 254 : case 254 :
{ {
P0 = IC(0); P0 = IC(0);
if (MDL) { if (MDL) {
@ -1259,7 +1259,7 @@ case 254 :
P1 = I211(0, 1, 5); P1 = I211(0, 1, 5);
} }
} break; } break;
case 255 : case 255 :
{ {
if (MDL) { if (MDL) {
P2 = IC(4); P2 = IC(4);

View File

@ -118,7 +118,7 @@ local MEMFILE *memOpen(char *memory, int available, char mode)
memory[3] = ' '; memory[3] = ' ';
*((int *)(memory+4)) = 0; *((int *)(memory+4)) = 0;
} else { } else {
if(memory[0] != 'V' || memory[1] != 'B' || memory[2] != 'A' || if(memory[0] != 'V' || memory[1] != 'B' || memory[2] != 'A' ||
memory[3] != ' ') { memory[3] != ' ') {
free(f); free(f);
return NULL; return NULL;
@ -130,11 +130,11 @@ local MEMFILE *memOpen(char *memory, int available, char mode)
return f; 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) MEMFILE *file)
{ {
size_t total = size*count; size_t total = size*count;
if(file->mode != 'w') { if(file->mode != 'w') {
file->error = 1; file->error = 1;
return 0; return 0;
@ -149,11 +149,11 @@ local size_t memWrite(const void *buffer, size_t size, size_t count,
return total; 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) MEMFILE *file)
{ {
size_t total = size*count; size_t total = size*count;
if(file->mode != 'r') { if(file->mode != 'r') {
file->error = 1; file->error = 1;
return 0; return 0;
@ -211,7 +211,7 @@ local int memPrintf(MEMFILE *f, const char *format, ...)
char buffer[80]; char buffer[80];
va_list list; va_list list;
int len; int len;
va_start(list, format); va_start(list, format);
len = vsprintf(buffer, format, list); len = vsprintf(buffer, format, list);
va_end(list); va_end(list);
@ -272,7 +272,7 @@ local gzFile gz_open (memory, available, mode)
} }
} while (*p++ && m != fmode + sizeof(fmode)); } while (*p++ && m != fmode + sizeof(fmode));
if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
if (s->mode == 'w') { if (s->mode == 'w') {
#ifdef NO_DEFLATE #ifdef NO_DEFLATE
err = Z_STREAM_ERROR; err = Z_STREAM_ERROR;
@ -324,7 +324,7 @@ local gzFile gz_open (memory, available, mode)
check_header(s); /* skip the .gz header */ check_header(s); /* skip the .gz header */
s->startpos = (memTell(s->file) - s->stream.avail_in); s->startpos = (memTell(s->file) - s->stream.avail_in);
} }
return (gzFile)s; 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; 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 /* 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); 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; 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; 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; mem_stream *s = (mem_stream*)file;
if (s == NULL) return Z_STREAM_ERROR; if (s == NULL) return Z_STREAM_ERROR;
return memTell(s->file); return memTell(s->file);
} }

View File

@ -9,7 +9,7 @@
* Adapted from original gzio.c from zlib library by Forgotten * 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> # include <zutil.h>
#else #else
#include <zlib.h> #include <zlib.h>

View File

@ -26,9 +26,9 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *nextLine, *finish; u8 *nextLine, *finish;
u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16)); u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
u32 lowPixelMask = RGB_LOW_BITS_MASK; u32 lowPixelMask = RGB_LOW_BITS_MASK;
nextLine = dstPtr + dstPitch; nextLine = dstPtr + dstPitch;
do { do {
u32 *bP = (u32 *) srcPtr; u32 *bP = (u32 *) srcPtr;
u32 *xP = (u32 *) deltaPtr; u32 *xP = (u32 *) deltaPtr;
@ -38,11 +38,11 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u32 nextPixel; u32 nextPixel;
u32 currentDelta; u32 currentDelta;
u32 nextDelta; u32 nextDelta;
finish = (u8 *) bP + ((width+2) << 1); finish = (u8 *) bP + ((width+2) << 1);
nextPixel = *bP++; nextPixel = *bP++;
nextDelta = *xP++; nextDelta = *xP++;
do { do {
currentPixel = nextPixel; currentPixel = nextPixel;
currentDelta = nextDelta; currentDelta = nextDelta;
@ -51,7 +51,7 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
if(currentPixel != currentDelta) { if(currentPixel != currentDelta) {
u32 colorA, product, colorB; u32 colorA, product, colorB;
*(xP - 2) = currentPixel; *(xP - 2) = currentPixel;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
colorA = currentPixel >> 16; colorA = currentPixel >> 16;
@ -64,7 +64,7 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
product = ((((colorA & colorMask) >> 1) + product = ((((colorA & colorMask) >> 1) +
((colorB & colorMask) >> 1) + ((colorB & colorMask) >> 1) +
(colorA & colorB & lowPixelMask))); (colorA & colorB & lowPixelMask)));
*(dP) = product | product << 16; *(dP) = product | product << 16;
*(nL) = product | product << 16; *(nL) = product | product << 16;
@ -78,21 +78,21 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
product = ((((colorA & colorMask) >> 1) + product = ((((colorA & colorMask) >> 1) +
((colorB & colorMask) >> 1) + ((colorB & colorMask) >> 1) +
(colorA & colorB & lowPixelMask))); (colorA & colorB & lowPixelMask)));
*(dP + 1) = product | product << 16; *(dP + 1) = product | product << 16;
*(nL + 1) = product | product << 16; *(nL + 1) = product | product << 16;
} else { } else {
u32 colorA, product; u32 colorA, product;
*(xP - 2) = currentPixel; *(xP - 2) = currentPixel;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
colorA = currentPixel >> 16; colorA = currentPixel >> 16;
#else #else
colorA = currentPixel & 0xffff; colorA = currentPixel & 0xffff;
#endif #endif
product = colorA; product = colorA;
*(dP) = product | product << 16; *(dP) = product | product << 16;
*(nL) = product | product << 16; *(nL) = product | product << 16;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
@ -101,15 +101,15 @@ void MotionBlur(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
colorA = currentPixel >> 16; colorA = currentPixel >> 16;
#endif #endif
product = colorA; product = colorA;
*(dP + 1) = product | product << 16; *(dP + 1) = product | product << 16;
*(nL + 1) = product | product << 16; *(nL + 1) = product | product << 16;
} }
dP += 2; dP += 2;
nL += 2; nL += 2;
} while ((u8 *) bP < finish); } while ((u8 *) bP < finish);
deltaPtr += srcPitch; deltaPtr += srcPitch;
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
@ -124,9 +124,9 @@ void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *nextLine, *finish; u8 *nextLine, *finish;
u32 colorMask = ~RGB_LOW_BITS_MASK; u32 colorMask = ~RGB_LOW_BITS_MASK;
u32 lowPixelMask = RGB_LOW_BITS_MASK; u32 lowPixelMask = RGB_LOW_BITS_MASK;
nextLine = dstPtr + dstPitch; nextLine = dstPtr + dstPitch;
do { do {
u32 *bP = (u32 *) srcPtr; u32 *bP = (u32 *) srcPtr;
u32 *xP = (u32 *) deltaPtr; u32 *xP = (u32 *) deltaPtr;
@ -136,11 +136,11 @@ void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u32 nextPixel; u32 nextPixel;
u32 currentDelta; u32 currentDelta;
u32 nextDelta; u32 nextDelta;
finish = (u8 *) bP + ((width+1) << 2); finish = (u8 *) bP + ((width+1) << 2);
nextPixel = *bP++; nextPixel = *bP++;
nextDelta = *xP++; nextDelta = *xP++;
do { do {
currentPixel = nextPixel; currentPixel = nextPixel;
currentDelta = nextDelta; currentDelta = nextDelta;
@ -152,11 +152,11 @@ void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
*(xP - 2) = currentPixel; *(xP - 2) = currentPixel;
colorA = currentPixel; colorA = currentPixel;
colorB = currentDelta; colorB = currentDelta;
product = ((((colorA & colorMask) >> 1) + product = ((((colorA & colorMask) >> 1) +
((colorB & colorMask) >> 1) + ((colorB & colorMask) >> 1) +
(colorA & colorB & lowPixelMask))); (colorA & colorB & lowPixelMask)));
*(dP) = product; *(dP) = product;
*(dP+1) = product; *(dP+1) = product;
*(nL) = product; *(nL) = product;
@ -166,11 +166,11 @@ void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
colorA = nextPixel; colorA = nextPixel;
colorB = nextDelta; colorB = nextDelta;
product = ((((colorA & colorMask) >> 1) + product = ((((colorA & colorMask) >> 1) +
((colorB & colorMask) >> 1) + ((colorB & colorMask) >> 1) +
(colorA & colorB & lowPixelMask))); (colorA & colorB & lowPixelMask)));
*(dP + 2) = product; *(dP + 2) = product;
*(dP + 3) = product; *(dP + 3) = product;
*(nL + 2) = product; *(nL + 2) = product;
@ -178,11 +178,11 @@ void MotionBlur32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
nextPixel = *bP++; nextPixel = *bP++;
nextDelta = *xP++; nextDelta = *xP++;
dP += 4; dP += 4;
nL += 4; nL += 4;
} while ((u8 *) bP < finish); } while ((u8 *) bP < finish);
deltaPtr += srcPitch; deltaPtr += srcPitch;
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;

View File

@ -25,9 +25,9 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
{ {
u8 *nextLine, *finish; u8 *nextLine, *finish;
u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16)); u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
nextLine = dstPtr + dstPitch; nextLine = dstPtr + dstPitch;
do { do {
u32 *bP = (u32 *) srcPtr; u32 *bP = (u32 *) srcPtr;
u32 *xP = (u32 *) deltaPtr; u32 *xP = (u32 *) deltaPtr;
@ -37,20 +37,20 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u32 nextPixel; u32 nextPixel;
u32 currentDelta; u32 currentDelta;
u32 nextDelta; u32 nextDelta;
finish = (u8 *) bP + ((width+2) << 1); finish = (u8 *) bP + ((width+2) << 1);
nextPixel = *bP++; nextPixel = *bP++;
nextDelta = *xP++; nextDelta = *xP++;
do { do {
currentPixel = nextPixel; currentPixel = nextPixel;
currentDelta = nextDelta; currentDelta = nextDelta;
nextPixel = *bP++; nextPixel = *bP++;
nextDelta = *xP++; nextDelta = *xP++;
if ((nextPixel != nextDelta) || (currentPixel != currentDelta)) { if ((nextPixel != nextDelta) || (currentPixel != currentDelta)) {
u32 colorA, colorB, product; u32 colorA, colorB, product;
*(xP - 2) = currentPixel; *(xP - 2) = currentPixel;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
colorA = currentPixel >> 16; colorA = currentPixel >> 16;
@ -60,7 +60,7 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
colorB = currentPixel >> 16; colorB = currentPixel >> 16;
#endif #endif
product = (((colorA & colorMask) >> 1) & colorMask) >> 1; product = (((colorA & colorMask) >> 1) & colorMask) >> 1;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
*(nL) = (product << 16) | (product); *(nL) = (product << 16) | (product);
*(dP) = (colorA << 16) | product; *(dP) = (colorA << 16) | product;
@ -68,7 +68,7 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
*(nL) = product | (product << 16); *(nL) = product | (product << 16);
*(dP) = colorA | (product << 16); *(dP) = colorA | (product << 16);
#endif #endif
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
colorA = nextPixel >> 16; colorA = nextPixel >> 16;
#else #else
@ -83,11 +83,11 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
*(dP + 1) = (colorB) | (product << 16); *(dP + 1) = (colorB) | (product << 16);
#endif #endif
} }
dP += 2; dP += 2;
nL += 2; nL += 2;
} while ((u8 *) bP < finish); } while ((u8 *) bP < finish);
deltaPtr += srcPitch; deltaPtr += srcPitch;
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
@ -101,9 +101,9 @@ void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
{ {
u8 *nextLine, *finish; u8 *nextLine, *finish;
u32 colorMask = ~RGB_LOW_BITS_MASK; u32 colorMask = ~RGB_LOW_BITS_MASK;
nextLine = dstPtr + dstPitch; nextLine = dstPtr + dstPitch;
do { do {
u32 *bP = (u32 *) srcPtr; u32 *bP = (u32 *) srcPtr;
// u32 *xP = (u32 *) deltaPtr; // u32 *xP = (u32 *) deltaPtr;
@ -111,16 +111,16 @@ void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u32 *nL = (u32 *) nextLine; u32 *nL = (u32 *) nextLine;
u32 currentPixel; u32 currentPixel;
u32 nextPixel; u32 nextPixel;
finish = (u8 *) bP + ((width+1) << 2); finish = (u8 *) bP + ((width+1) << 2);
nextPixel = *bP++; nextPixel = *bP++;
do { do {
currentPixel = nextPixel; currentPixel = nextPixel;
nextPixel = *bP++; nextPixel = *bP++;
u32 colorA, colorB, product; u32 colorA, colorB, product;
colorA = currentPixel; colorA = currentPixel;
colorB = nextPixel; colorB = nextPixel;
@ -137,11 +137,11 @@ void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
*(nL + 3) = product; *(nL + 3) = product;
*(dP + 2) = colorB; *(dP + 2) = colorB;
*(dP + 3) = product; *(dP + 3) = product;
dP += 4; dP += 4;
nL += 4; nL += 4;
} while ((u8 *) bP < finish); } while ((u8 *) bP < finish);
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
nextLine += dstPitch << 1; nextLine += dstPitch << 1;

View File

@ -11,7 +11,7 @@
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 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 * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software

View File

@ -11,7 +11,7 @@
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 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 * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software

View File

@ -91,22 +91,22 @@ bool remoteTcpInit()
int error = WSAStartup(MAKEWORD(1,1),&wsaData); int error = WSAStartup(MAKEWORD(1,1),&wsaData);
#endif // _WIN32 #endif // _WIN32
SOCKET s = socket(PF_INET, SOCK_STREAM, 0); SOCKET s = socket(PF_INET, SOCK_STREAM, 0);
remoteListenSocket = s; remoteListenSocket = s;
if(s < 0) { if(s < 0) {
fprintf(stderr,"Error opening socket\n"); fprintf(stderr,"Error opening socket\n");
exit(-1); exit(-1);
} }
int tmp = 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]; // char hostname[256];
// gethostname(hostname, 256); // gethostname(hostname, 256);
// hostent *ent = gethostbyname(hostname); // hostent *ent = gethostbyname(hostname);
// unsigned long a = *((unsigned long *)ent->h_addr); // unsigned long a = *((unsigned long *)ent->h_addr);
sockaddr_in addr; sockaddr_in addr;
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(remotePort); addr.sin_port = htons(remotePort);
@ -122,10 +122,10 @@ bool remoteTcpInit()
fprintf(stderr,"Error binding \n"); fprintf(stderr,"Error binding \n");
exit(-1); exit(-1);
} }
fprintf(stderr,"Listening for a connection at port %d\n", fprintf(stderr,"Listening for a connection at port %d\n",
ntohs(addr.sin_port)); ntohs(addr.sin_port));
if(listen(s, 1)) { if(listen(s, 1)) {
fprintf(stderr, "Error listening\n"); fprintf(stderr, "Error listening\n");
exit(-1); exit(-1);
@ -133,7 +133,7 @@ bool remoteTcpInit()
socklen_t len = sizeof(addr); socklen_t len = sizeof(addr);
#ifdef _WIN32 #ifdef _WIN32
int flag = 0; int flag = 0;
ioctlsocket(s, FIONBIO, (unsigned long *)&flag); ioctlsocket(s, FIONBIO, (unsigned long *)&flag);
#endif // _WIN32 #endif // _WIN32
SOCKET s2 = accept(s, (sockaddr *)&addr, &len); SOCKET s2 = accept(s, (sockaddr *)&addr, &len);
@ -166,10 +166,10 @@ void remoteTcpCleanUp()
remoteSocket = -1; remoteSocket = -1;
} }
if(remoteListenSocket > 0) { if(remoteListenSocket > 0) {
fprintf(stderr, "Closing listen socket\n"); fprintf(stderr, "Closing listen socket\n");
close(remoteListenSocket); close(remoteListenSocket);
remoteListenSocket = -1; remoteListenSocket = -1;
} }
} }
int remotePipeSend(char *data, int len) int remotePipeSend(char *data, int len)
@ -192,7 +192,7 @@ bool remotePipeInit()
fprintf(stderr, "ACK not received\n"); fprintf(stderr, "ACK not received\n");
exit(-1); exit(-1);
} }
return true; return true;
} }
@ -216,7 +216,7 @@ void remoteSetProtocol(int p)
remoteSendFnc = remotePipeSend; remoteSendFnc = remotePipeSend;
remoteRecvFnc = remotePipeRecv; remoteRecvFnc = remotePipeRecv;
remoteInitFnc = remotePipeInit; remoteInitFnc = remotePipeInit;
remoteCleanUpFnc = remotePipeCleanUp; remoteCleanUpFnc = remotePipeCleanUp;
} }
} }
@ -228,7 +228,7 @@ void remoteInit()
void remotePutPacket(const char *packet) void remotePutPacket(const char *packet)
{ {
const char *hex = "0123456789abcdef"; const char *hex = "0123456789abcdef";
char buffer[1024]; char buffer[1024];
size_t count = strlen(packet); size_t count = strlen(packet);
@ -237,7 +237,7 @@ void remotePutPacket(const char *packet)
char *p = buffer; char *p = buffer;
*p++ = '$'; *p++ = '$';
for(size_t i = 0 ;i < count; i++) { for(size_t i = 0 ;i < count; i++) {
csum += packet[i]; csum += packet[i];
*p++ = packet[i]; *p++ = packet[i];
@ -283,7 +283,7 @@ void remoteOutput(char *s, u32 addr)
char *d = buffer; char *d = buffer;
*d++ = 'O'; *d++ = 'O';
if(s) { if(s) {
char c = *s++; char c = *s++;
while(c) { while(c) {
@ -339,10 +339,10 @@ void remoteSendStatus()
(v >> 8) & 255, (v >> 8) & 255,
(v >> 16) & 255, (v >> 16) & 255,
(v >> 24) & 255); (v >> 24) & 255);
s += 12; s += 12;
*s = 0; *s = 0;
// printf("Sending %s\n", buffer); // printf("Sending %s\n", buffer);
remotePutPacket(buffer); remotePutPacket(buffer);
} }
void remoteBinaryWrite(char *p) void remoteBinaryWrite(char *p)
@ -368,8 +368,8 @@ void remoteBinaryWrite(char *p)
break; break;
} }
} }
// printf("ROM is %08x\n", debuggerReadMemory(0x8000254)); // printf("ROM is %08x\n", debuggerReadMemory(0x8000254));
remotePutPacket("OK"); remotePutPacket("OK");
} }
void remoteMemoryWrite(char *p) void remoteMemoryWrite(char *p)
@ -397,7 +397,7 @@ void remoteMemoryWrite(char *p)
address++; address++;
} }
// printf("ROM is %08x\n", debuggerReadMemory(0x8000254)); // printf("ROM is %08x\n", debuggerReadMemory(0x8000254));
remotePutPacket("OK"); remotePutPacket("OK");
} }
void remoteMemoryRead(char *p) void remoteMemoryRead(char *p)
@ -409,7 +409,7 @@ void remoteMemoryRead(char *p)
char buffer[1024]; char buffer[1024];
char *s = buffer; char *s = buffer;
for(int i = 0; i < count; i++) { for(int i = 0; i < count; i++) {
u8 b = debuggerReadByte(address); u8 b = debuggerReadByte(address);
sprintf(s, "%02x", b); sprintf(s, "%02x", b);
@ -452,14 +452,14 @@ void remoteWriteWatch(char *p, bool active)
remotePutPacket("E01"); remotePutPacket("E01");
return; return;
} }
if(address > 0x203ffff && address < 0x3000000) { if(address > 0x203ffff && address < 0x3000000) {
remotePutPacket("E01"); remotePutPacket("E01");
return; return;
} }
u32 final = address + count; u32 final = address + count;
if(address < 0x2040000 && final > 0x2040000) { if(address < 0x2040000 && final > 0x2040000) {
remotePutPacket("E01"); remotePutPacket("E01");
return; return;
@ -474,8 +474,8 @@ void remoteWriteWatch(char *p, bool active)
else else
freezeInternalRAM[address & 0x7fff] = active; freezeInternalRAM[address & 0x7fff] = active;
address++; address++;
} }
remotePutPacket("OK"); remotePutPacket("OK");
} }
@ -531,9 +531,9 @@ void remoteWriteRegister(char *p)
u32 v = 0; u32 v = 0;
u8 data[4] = {0,0,0,0}; u8 data[4] = {0,0,0,0};
int i = 0; int i = 0;
while(c != '#') { while(c != '#') {
u8 b = 0; u8 b = 0;
if(c <= '9') if(c <= '9')
@ -574,11 +574,11 @@ void remoteStubMain()
remoteSendStatus(); remoteSendStatus();
remoteResumed = false; remoteResumed = false;
} }
while(1) { while(1) {
char buffer[1024]; char buffer[1024];
int res = remoteRecvFnc(buffer, 1024); int res = remoteRecvFnc(buffer, 1024);
if(res == -1) { if(res == -1) {
fprintf(stderr, "GDB connection lost\n"); fprintf(stderr, "GDB connection lost\n");
#ifdef SDL #ifdef SDL
@ -675,13 +675,13 @@ void remoteStubMain()
break; break;
default: default:
{ {
*(strchr(p, '#') + 3) = 0; *(strchr(p, '#') + 3) = 0;
fprintf(stderr, "Unknown packet %s\n", --p); fprintf(stderr, "Unknown packet %s\n", --p);
remotePutPacket(""); remotePutPacket("");
} }
break; break;
} }
} }
} }
void remoteStubSignal(int sig, int number) void remoteStubSignal(int sig, int number)

View File

@ -24,24 +24,24 @@ void Scanlines (u8 *srcPtr, u32 srcPitch, u8 *,
u8 *dstPtr, u32 dstPitch, int width, int height) u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
u8 *nextLine, *finish; u8 *nextLine, *finish;
nextLine = dstPtr + dstPitch; nextLine = dstPtr + dstPitch;
do { do {
u32 *bP = (u32 *) srcPtr; u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr; u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine; u32 *nL = (u32 *) nextLine;
u32 currentPixel; u32 currentPixel;
u32 nextPixel; u32 nextPixel;
finish = (u8 *) bP + ((width+2) << 1); finish = (u8 *) bP + ((width+2) << 1);
nextPixel = *bP++; nextPixel = *bP++;
do { do {
currentPixel = nextPixel; currentPixel = nextPixel;
nextPixel = *bP++; nextPixel = *bP++;
u32 colorA, colorB; u32 colorA, colorB;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
colorA = currentPixel >> 16; colorA = currentPixel >> 16;
colorB = currentPixel & 0xffff; colorB = currentPixel & 0xffff;
@ -61,11 +61,11 @@ void Scanlines (u8 *srcPtr, u32 srcPitch, u8 *,
*(dP + 1) = colorB | (colorB << 16); *(dP + 1) = colorB | (colorB << 16);
*(nL + 1) = 0; *(nL + 1) = 0;
dP += 2; dP += 2;
nL += 2; nL += 2;
} while ((u8 *) bP < finish); } while ((u8 *) bP < finish);
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
nextLine += 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 *dstPtr, u32 dstPitch, int width, int height)
{ {
u8 *nextLine, *finish; u8 *nextLine, *finish;
nextLine = dstPtr + dstPitch; nextLine = dstPtr + dstPitch;
do { do {
u32 *bP = (u32 *) srcPtr; u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr; u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine; u32 *nL = (u32 *) nextLine;
u32 currentPixel; u32 currentPixel;
u32 nextPixel; u32 nextPixel;
finish = (u8 *) bP + ((width+1) << 2); finish = (u8 *) bP + ((width+1) << 2);
nextPixel = *bP++; nextPixel = *bP++;
do { do {
currentPixel = nextPixel; currentPixel = nextPixel;
nextPixel = *bP++; nextPixel = *bP++;
u32 colorA, colorB; u32 colorA, colorB;
colorA = currentPixel; colorA = currentPixel;
colorB = nextPixel; colorB = nextPixel;
@ -106,15 +106,15 @@ void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
*(dP + 2) = colorB; *(dP + 2) = colorB;
*(dP + 3) = colorB; *(dP + 3) = colorB;
*(nL+2) = 0; *(nL+2) = 0;
*(nL+3) = 0; *(nL+3) = 0;
nextPixel = *bP++; nextPixel = *bP++;
dP += 4; dP += 4;
nL += 4; nL += 4;
} while ((u8 *) bP < finish); } while ((u8 *) bP < finish);
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
nextLine += dstPitch << 1; nextLine += dstPitch << 1;
@ -127,23 +127,23 @@ void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
{ {
u8 *nextLine, *finish; u8 *nextLine, *finish;
u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16)); u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
nextLine = dstPtr + dstPitch; nextLine = dstPtr + dstPitch;
do { do {
u32 *bP = (u32 *) srcPtr; u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr; u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine; u32 *nL = (u32 *) nextLine;
u32 currentPixel; u32 currentPixel;
u32 nextPixel; u32 nextPixel;
finish = (u8 *) bP + ((width+2) << 1); finish = (u8 *) bP + ((width+2) << 1);
nextPixel = *bP++; nextPixel = *bP++;
do { do {
currentPixel = nextPixel; currentPixel = nextPixel;
nextPixel = *bP++; nextPixel = *bP++;
u32 colorA, colorB; u32 colorA, colorB;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
@ -153,7 +153,7 @@ void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
colorA = currentPixel & 0xFFFF; colorA = currentPixel & 0xFFFF;
colorB = currentPixel >> 16; colorB = currentPixel >> 16;
#endif #endif
*(dP) = colorA = colorA | ((((colorA & colorMask) >> 1) + *(dP) = colorA = colorA | ((((colorA & colorMask) >> 1) +
((colorB & colorMask) >> 1))) << 16; ((colorB & colorMask) >> 1))) << 16;
colorA = ((colorA & colorMask) >> 1); colorA = ((colorA & colorMask) >> 1);
@ -167,12 +167,12 @@ void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
colorB = ((colorB & colorMask) >> 1); colorB = ((colorB & colorMask) >> 1);
colorB += ((colorB & colorMask) >> 1); colorB += ((colorB & colorMask) >> 1);
*(nL + 1) = colorB; *(nL + 1) = colorB;
dP += 2; dP += 2;
nL += 2; nL += 2;
} while ((u8 *) bP < finish); } while ((u8 *) bP < finish);
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
nextLine += dstPitch << 1; nextLine += dstPitch << 1;
@ -185,28 +185,28 @@ void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
{ {
u8 *nextLine, *finish; u8 *nextLine, *finish;
u32 colorMask = ~RGB_LOW_BITS_MASK; u32 colorMask = ~RGB_LOW_BITS_MASK;
nextLine = dstPtr + dstPitch; nextLine = dstPtr + dstPitch;
do { do {
u32 *bP = (u32 *) srcPtr; u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr; u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine; u32 *nL = (u32 *) nextLine;
u32 currentPixel; u32 currentPixel;
u32 nextPixel; u32 nextPixel;
finish = (u8 *) bP + ((width+1) << 2); finish = (u8 *) bP + ((width+1) << 2);
nextPixel = *bP++; nextPixel = *bP++;
do { do {
currentPixel = nextPixel; currentPixel = nextPixel;
nextPixel = *bP++; nextPixel = *bP++;
u32 colorA, colorB, temp; u32 colorA, colorB, temp;
colorA = currentPixel; colorA = currentPixel;
colorB = nextPixel; colorB = nextPixel;
*(dP) = colorA; *(dP) = colorA;
*(dP+1) = temp = ((colorA & colorMask) >> 1) + *(dP+1) = temp = ((colorA & colorMask) >> 1) +
((colorB & colorMask) >> 1); ((colorB & colorMask) >> 1);
@ -221,7 +221,7 @@ void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
dP += 2; dP += 2;
nL += 2; nL += 2;
} while ((u8 *) bP < finish); } while ((u8 *) bP < finish);
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
nextLine += dstPitch << 1; nextLine += dstPitch << 1;

View File

@ -64,11 +64,11 @@ extern bool soundLowPass;
extern bool soundReverse; extern bool soundReverse;
extern int Init_2xSaI(u32); extern int Init_2xSaI(u32);
extern void _2xSaI(u8*,u32,u8*,u8*,u32,int,int); 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 Super2xSaI(u8*,u32,u8*,u8*,u32,int,int);
extern void Super2xSaI32(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 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 Pixelate(u8*,u32,u8*,u8*,u32,int,int);
extern void Pixelate32(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); extern void MotionBlur(u8*,u32,u8*,u8*,u32,int,int);
@ -192,7 +192,7 @@ static int rewindTimer = 0;
#define _stricmp strcasecmp #define _stricmp strcasecmp
bool sdlButtons[4][12] = { 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, { 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[] = { struct option sdlOptions[] = {
{ "agb-print", no_argument, &sdlAgbPrint, 1 }, { "agb-print", no_argument, &sdlAgbPrint, 1 },
{ "auto-frameskip", no_argument, &autoFrameSkip, 1 }, { "auto-frameskip", no_argument, &autoFrameSkip, 1 },
{ "bios", required_argument, 0, 'b' }, { "bios", required_argument, 0, 'b' },
{ "config", required_argument, 0, 'c' }, { "config", required_argument, 0, 'c' },
{ "debug", no_argument, 0, 'd' }, { "debug", no_argument, 0, 'd' },
@ -360,7 +360,7 @@ struct option sdlOptions[] = {
{ "show-speed-normal", no_argument, &showSpeed, 1 }, { "show-speed-normal", no_argument, &showSpeed, 1 },
{ "show-speed-detailed", no_argument, &showSpeed, 2 }, { "show-speed-detailed", no_argument, &showSpeed, 2 },
{ "throttle", required_argument, 0, 'T' }, { "throttle", required_argument, 0, 'T' },
{ "verbose", required_argument, 0, 'v' }, { "verbose", required_argument, 0, 'v' },
{ "video-1x", no_argument, &sizeOption, 0 }, { "video-1x", no_argument, &sizeOption, 0 },
{ "video-2x", no_argument, &sizeOption, 1 }, { "video-2x", no_argument, &sizeOption, 1 },
{ "video-3x", no_argument, &sizeOption, 2 }, { "video-3x", no_argument, &sizeOption, 2 },
@ -400,21 +400,21 @@ extern bool gbIsGameboyRom(char *);
sdlStretcher[sdlStretcherPos++] = 0x06;\ sdlStretcher[sdlStretcherPos++] = 0x06;\
sdlStretcher[sdlStretcherPos++] = 0x83;\ sdlStretcher[sdlStretcherPos++] = 0x83;\
sdlStretcher[sdlStretcherPos++] = 0xc6;\ sdlStretcher[sdlStretcherPos++] = 0xc6;\
sdlStretcher[sdlStretcherPos++] = 0x02; sdlStretcher[sdlStretcherPos++] = 0x02;
#define SDL_LOADL \ #define SDL_LOADL \
sdlStretcher[sdlStretcherPos++] = 0x8b;\ sdlStretcher[sdlStretcherPos++] = 0x8b;\
sdlStretcher[sdlStretcherPos++] = 0x06;\ sdlStretcher[sdlStretcherPos++] = 0x06;\
sdlStretcher[sdlStretcherPos++] = 0x83;\ sdlStretcher[sdlStretcherPos++] = 0x83;\
sdlStretcher[sdlStretcherPos++] = 0xc6;\ sdlStretcher[sdlStretcherPos++] = 0xc6;\
sdlStretcher[sdlStretcherPos++] = 0x04; sdlStretcher[sdlStretcherPos++] = 0x04;
#define SDL_LOADL2 \ #define SDL_LOADL2 \
sdlStretcher[sdlStretcherPos++] = 0x8b;\ sdlStretcher[sdlStretcherPos++] = 0x8b;\
sdlStretcher[sdlStretcherPos++] = 0x06;\ sdlStretcher[sdlStretcherPos++] = 0x06;\
sdlStretcher[sdlStretcherPos++] = 0x83;\ sdlStretcher[sdlStretcherPos++] = 0x83;\
sdlStretcher[sdlStretcherPos++] = 0xc6;\ sdlStretcher[sdlStretcherPos++] = 0xc6;\
sdlStretcher[sdlStretcherPos++] = 0x03; sdlStretcher[sdlStretcherPos++] = 0x03;
#define SDL_STOREW \ #define SDL_STOREW \
sdlStretcher[sdlStretcherPos++] = 0x66;\ sdlStretcher[sdlStretcherPos++] = 0x66;\
@ -422,21 +422,21 @@ extern bool gbIsGameboyRom(char *);
sdlStretcher[sdlStretcherPos++] = 0x07;\ sdlStretcher[sdlStretcherPos++] = 0x07;\
sdlStretcher[sdlStretcherPos++] = 0x83;\ sdlStretcher[sdlStretcherPos++] = 0x83;\
sdlStretcher[sdlStretcherPos++] = 0xc7;\ sdlStretcher[sdlStretcherPos++] = 0xc7;\
sdlStretcher[sdlStretcherPos++] = 0x02; sdlStretcher[sdlStretcherPos++] = 0x02;
#define SDL_STOREL \ #define SDL_STOREL \
sdlStretcher[sdlStretcherPos++] = 0x89;\ sdlStretcher[sdlStretcherPos++] = 0x89;\
sdlStretcher[sdlStretcherPos++] = 0x07;\ sdlStretcher[sdlStretcherPos++] = 0x07;\
sdlStretcher[sdlStretcherPos++] = 0x83;\ sdlStretcher[sdlStretcherPos++] = 0x83;\
sdlStretcher[sdlStretcherPos++] = 0xc7;\ sdlStretcher[sdlStretcherPos++] = 0xc7;\
sdlStretcher[sdlStretcherPos++] = 0x04; sdlStretcher[sdlStretcherPos++] = 0x04;
#define SDL_STOREL2 \ #define SDL_STOREL2 \
sdlStretcher[sdlStretcherPos++] = 0x89;\ sdlStretcher[sdlStretcherPos++] = 0x89;\
sdlStretcher[sdlStretcherPos++] = 0x07;\ sdlStretcher[sdlStretcherPos++] = 0x07;\
sdlStretcher[sdlStretcherPos++] = 0x83;\ sdlStretcher[sdlStretcherPos++] = 0x83;\
sdlStretcher[sdlStretcherPos++] = 0xc7;\ sdlStretcher[sdlStretcherPos++] = 0xc7;\
sdlStretcher[sdlStretcherPos++] = 0x03; sdlStretcher[sdlStretcherPos++] = 0x03;
#define SDL_RET \ #define SDL_RET \
sdlStretcher[sdlStretcherPos++] = 0xc3; sdlStretcher[sdlStretcherPos++] = 0xc3;
@ -823,7 +823,7 @@ void sdlCheckDirectory(char *dir)
if(*p == '/' || if(*p == '/' ||
*p == '\\') *p == '\\')
*p = 0; *p = 0;
if(stat(dir, &buf) == 0) { if(stat(dir, &buf) == 0) {
if(!(buf.st_mode & S_IFDIR)) { if(!(buf.st_mode & S_IFDIR)) {
fprintf(stderr, "Error: %s is not a directory\n", dir); fprintf(stderr, "Error: %s is not a directory\n", dir);
@ -840,9 +840,9 @@ char *sdlGetFilename(char *name)
static char filebuffer[2048]; static char filebuffer[2048];
int len = strlen(name); int len = strlen(name);
char *p = name + len - 1; char *p = name + len - 1;
while(true) { while(true) {
if(*p == '/' || if(*p == '/' ||
*p == '\\') { *p == '\\') {
@ -854,7 +854,7 @@ char *sdlGetFilename(char *name)
if(len == 0) if(len == 0)
break; break;
} }
if(len == 0) if(len == 0)
strcpy(filebuffer, name); strcpy(filebuffer, name);
else else
@ -878,11 +878,11 @@ FILE *sdlFindFile(const char *name)
#endif // ! _WIN32 #endif // ! _WIN32
fprintf(stderr, "Searching for file %s\n", name); fprintf(stderr, "Searching for file %s\n", name);
if(GETCWD(buffer, 2048)) { if(GETCWD(buffer, 2048)) {
fprintf(stderr, "Searching current directory: %s\n", buffer); fprintf(stderr, "Searching current directory: %s\n", buffer);
} }
FILE *f = fopen(name, "r"); FILE *f = fopen(name, "r");
if(f != NULL) { if(f != NULL) {
return f; return f;
@ -924,7 +924,7 @@ FILE *sdlFindFile(const char *name)
strncpy(buffer, path, 4096); strncpy(buffer, path, 4096);
buffer[4095] = 0; buffer[4095] = 0;
char *tok = strtok(buffer, PATH_SEP); char *tok = strtok(buffer, PATH_SEP);
while(tok) { while(tok) {
sprintf(path, "%s%c%s", tok, FILE_SEP, EXE_NAME); sprintf(path, "%s%c%s", tok, FILE_SEP, EXE_NAME);
f = fopen(path, "r"); f = fopen(path, "r");
@ -960,7 +960,7 @@ FILE *sdlFindFile(const char *name)
void sdlReadPreferences(FILE *f) void sdlReadPreferences(FILE *f)
{ {
char buffer[2048]; char buffer[2048];
while(1) { while(1) {
char *s = fgets(buffer, 2048, f); char *s = fgets(buffer, 2048, f);
@ -968,10 +968,10 @@ void sdlReadPreferences(FILE *f)
break; break;
char *p = strchr(s, '#'); char *p = strchr(s, '#');
if(p) if(p)
*p = 0; *p = 0;
char *token = strtok(s, " \t\n\r="); char *token = strtok(s, " \t\n\r=");
if(!token) if(!token)
@ -1099,7 +1099,7 @@ void sdlReadPreferences(FILE *f)
} else if(!strcmp(key, "gbFrameSkip")) { } else if(!strcmp(key, "gbFrameSkip")) {
gbFrameSkip = sdlFromHex(value); gbFrameSkip = sdlFromHex(value);
if(gbFrameSkip < 0 || gbFrameSkip > 9) if(gbFrameSkip < 0 || gbFrameSkip > 9)
gbFrameSkip = 0; gbFrameSkip = 0;
} else if(!strcmp(key, "video")) { } else if(!strcmp(key, "video")) {
sizeOption = sdlFromHex(value); sizeOption = sdlFromHex(value);
if(sizeOption < 0 || sizeOption > 3) if(sizeOption < 0 || sizeOption > 3)
@ -1147,7 +1147,7 @@ void sdlReadPreferences(FILE *f)
case 4: case 4:
break; break;
default: default:
fprintf(stderr, "Unknown sound quality %d. Defaulting to 22Khz\n", fprintf(stderr, "Unknown sound quality %d. Defaulting to 22Khz\n",
soundQuality); soundQuality);
soundQuality = 2; soundQuality = 2;
break; break;
@ -1251,7 +1251,7 @@ static void sdlApplyPerImagePreferences()
char readBuffer[2048]; char readBuffer[2048];
bool found = false; bool found = false;
while(1) { while(1) {
char *s = fgets(readBuffer, 2048, f); char *s = fgets(readBuffer, 2048, f);
@ -1259,10 +1259,10 @@ static void sdlApplyPerImagePreferences()
break; break;
char *p = strchr(s, ';'); char *p = strchr(s, ';');
if(p) if(p)
*p = 0; *p = 0;
char *token = strtok(s, " \t\n\r="); char *token = strtok(s, " \t\n\r=");
if(!token) if(!token)
@ -1298,7 +1298,7 @@ static void sdlApplyPerImagePreferences()
char *value = strtok(NULL, "\t\n\r="); char *value = strtok(NULL, "\t\n\r=");
if(value == NULL) if(value == NULL)
continue; continue;
if(!strcmp(token, "rtcEnabled")) if(!strcmp(token, "rtcEnabled"))
rtcEnable(atoi(value) == 0 ? false : true); rtcEnable(atoi(value) == 0 ? false : true);
else if(!strcmp(token, "flashSize")) { else if(!strcmp(token, "flashSize")) {
@ -1320,7 +1320,7 @@ static void sdlApplyPerImagePreferences()
static int sdlCalculateShift(u32 mask) static int sdlCalculateShift(u32 mask)
{ {
int m = 0; int m = 0;
while(mask) { while(mask) {
m++; m++;
mask >>= 1; mask >>= 1;
@ -1358,7 +1358,7 @@ void sdlWriteState(int num)
num+1); num+1);
else else
sprintf(stateName,"%s%d.sgm", filename, num+1); sprintf(stateName,"%s%d.sgm", filename, num+1);
if(emulator.emuWriteState) if(emulator.emuWriteState)
emulator.emuWriteState(stateName); emulator.emuWriteState(stateName);
@ -1393,7 +1393,7 @@ void sdlWriteBattery()
if(batteryDir[0]) if(batteryDir[0])
sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename)); sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename));
else else
sprintf(buffer, "%s.sav", filename); sprintf(buffer, "%s.sav", filename);
emulator.emuWriteBattery(buffer); emulator.emuWriteBattery(buffer);
@ -1404,12 +1404,12 @@ void sdlWriteBattery()
void sdlReadBattery() void sdlReadBattery()
{ {
char buffer[1048]; char buffer[1048];
if(batteryDir[0]) if(batteryDir[0])
sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename)); sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename));
else else
sprintf(buffer, "%s.sav", filename); sprintf(buffer, "%s.sav", filename);
bool res = false; bool res = false;
res = emulator.emuReadBattery(buffer); res = emulator.emuReadBattery(buffer);
@ -1453,7 +1453,7 @@ void sdlUpdateJoyButton(int which,
int b = joypad[j][i] & 0xfff; int b = joypad[j][i] & 0xfff;
if(dev) { if(dev) {
dev--; dev--;
if((dev == which) && (b >= 128) && (b == (button+128))) { if((dev == which) && (b >= 128) && (b == (button+128))) {
sdlButtons[j][i] = pressed; sdlButtons[j][i] = pressed;
} }
@ -1470,7 +1470,7 @@ void sdlUpdateJoyButton(int which,
sdlMotionButtons[i] = pressed; sdlMotionButtons[i] = pressed;
} }
} }
} }
} }
void sdlUpdateJoyHat(int which, void sdlUpdateJoyHat(int which,
@ -1484,7 +1484,7 @@ void sdlUpdateJoyHat(int which,
int a = joypad[j][i] & 0xfff; int a = joypad[j][i] & 0xfff;
if(dev) { if(dev) {
dev--; dev--;
if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) { if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) {
int dir = a & 3; int dir = a & 3;
int v = 0; int v = 0;
@ -1533,7 +1533,7 @@ void sdlUpdateJoyHat(int which,
sdlMotionButtons[i] = (v ? true : false); sdlMotionButtons[i] = (v ? true : false);
} }
} }
} }
} }
void sdlUpdateJoyAxis(int which, void sdlUpdateJoyAxis(int which,
@ -1547,7 +1547,7 @@ void sdlUpdateJoyAxis(int which,
int a = joypad[j][i] & 0xfff; int a = joypad[j][i] & 0xfff;
if(dev) { if(dev) {
dev--; dev--;
if((dev == which) && (a < 32) && ((a>>1) == axis)) { if((dev == which) && (a < 32) && ((a>>1) == axis)) {
sdlButtons[j][i] = (a & 1) ? (value > 16384) : (value < -16384); 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); sdlMotionButtons[i] = (a & 1) ? (value > 16384) : (value < -16384);
} }
} }
} }
} }
bool sdlCheckJoyKey(int key) bool sdlCheckJoyKey(int key)
@ -1579,7 +1579,7 @@ bool sdlCheckJoyKey(int key)
if(button >= SDL_JoystickNumButtons(sdlDevices[dev])) if(button >= SDL_JoystickNumButtons(sdlDevices[dev]))
return false; return false;
} else if (what < 0x20) { } else if (what < 0x20) {
// joystick axis // joystick axis
what >>= 1; what >>= 1;
if(what >= SDL_JoystickNumAxes(sdlDevices[dev])) if(what >= SDL_JoystickNumAxes(sdlDevices[dev]))
return false; return false;
@ -1612,18 +1612,18 @@ void sdlCheckKeys()
if(dev) { if(dev) {
dev--; dev--;
bool ok = false; bool ok = false;
if(sdlDevices) { if(sdlDevices) {
if(dev < sdlNumDevices) { if(dev < sdlNumDevices) {
if(sdlDevices[dev] == NULL) { if(sdlDevices[dev] == NULL) {
sdlDevices[dev] = SDL_JoystickOpen(dev); sdlDevices[dev] = SDL_JoystickOpen(dev);
} }
ok = sdlCheckJoyKey(joypad[j][i]); ok = sdlCheckJoyKey(joypad[j][i]);
} else } else
ok = false; ok = false;
} }
if(!ok) if(!ok)
joypad[j][i] = defaultJoypad[i]; joypad[j][i] = defaultJoypad[i];
else else
@ -1637,18 +1637,18 @@ void sdlCheckKeys()
if(dev) { if(dev) {
dev--; dev--;
bool ok = false; bool ok = false;
if(sdlDevices) { if(sdlDevices) {
if(dev < sdlNumDevices) { if(dev < sdlNumDevices) {
if(sdlDevices[dev] == NULL) { if(sdlDevices[dev] == NULL) {
sdlDevices[dev] = SDL_JoystickOpen(dev); sdlDevices[dev] = SDL_JoystickOpen(dev);
} }
ok = sdlCheckJoyKey(motion[i]); ok = sdlCheckJoyKey(motion[i]);
} else } else
ok = false; ok = false;
} }
if(!ok) if(!ok)
motion[i] = defaultMotion[i]; motion[i] = defaultMotion[i];
else else
@ -1682,7 +1682,7 @@ void sdlPollEvents()
if(emulating) if(emulating)
soundPause(); soundPause();
} }
memset(delta,255,sizeof(delta)); memset(delta,255,sizeof(delta));
} }
} }
@ -1729,10 +1729,10 @@ void sdlPollEvents()
case SDLK_b: case SDLK_b:
if(!(event.key.keysym.mod & MOD_NOCTRL) && if(!(event.key.keysym.mod & MOD_NOCTRL) &&
(event.key.keysym.mod & KMOD_CTRL)) { (event.key.keysym.mod & KMOD_CTRL)) {
if(emulating && emulator.emuReadMemState && rewindMemory if(emulating && emulator.emuReadMemState && rewindMemory
&& rewindCount) { && rewindCount) {
rewindPos = (rewindPos - 1) & 7; rewindPos = (rewindPos - 1) & 7;
emulator.emuReadMemState(&rewindMemory[REWIND_SIZE*rewindPos], emulator.emuReadMemState(&rewindMemory[REWIND_SIZE*rewindPos],
REWIND_SIZE); REWIND_SIZE);
rewindCount--; rewindCount--;
rewindCounter = 0; rewindCounter = 0;
@ -1799,12 +1799,12 @@ void sdlPollEvents()
case SDLK_4: case SDLK_4:
if(!(event.key.keysym.mod & MOD_NOALT) && if(!(event.key.keysym.mod & MOD_NOALT) &&
(event.key.keysym.mod & KMOD_ALT)) { (event.key.keysym.mod & KMOD_ALT)) {
const char *disableMessages[4] = const char *disableMessages[4] =
{ "autofire A disabled", { "autofire A disabled",
"autofire B disabled", "autofire B disabled",
"autofire R disabled", "autofire R disabled",
"autofire L disabled"}; "autofire L disabled"};
const char *enableMessages[4] = const char *enableMessages[4] =
{ "autofire A", { "autofire A",
"autofire B", "autofire B",
"autofire R", "autofire R",
@ -1950,12 +1950,12 @@ int main(int argc, char **argv)
fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", VERSION); fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", VERSION);
arg0 = argv[0]; arg0 = argv[0];
captureDir[0] = 0; captureDir[0] = 0;
saveDir[0] = 0; saveDir[0] = 0;
batteryDir[0] = 0; batteryDir[0] = 0;
ipsname[0] = 0; ipsname[0] = 0;
int op = -1; int op = -1;
frameSkip = 2; frameSkip = 2;
@ -1966,7 +1966,7 @@ int main(int argc, char **argv)
sdlReadPreferences(); sdlReadPreferences();
sdlPrintUsage = 0; sdlPrintUsage = 0;
while((op = getopt_long(argc, while((op = getopt_long(argc,
argv, argv,
"FNT:Y:G:D:b:c:df:hi:p::s:t:v:1234", "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': case 'v':
if(optarg) { if(optarg) {
systemVerbose = atoi(optarg); systemVerbose = atoi(optarg);
} else } else
systemVerbose = 0; systemVerbose = 0;
break; break;
case '1': case '1':
@ -2169,7 +2169,7 @@ int main(int argc, char **argv)
rtcEnable(sdlRtcEnable ? true : false); rtcEnable(sdlRtcEnable ? true : false);
agbPrintEnable(sdlAgbPrint ? true : false); agbPrintEnable(sdlAgbPrint ? true : false);
if(!debuggerStub) { if(!debuggerStub) {
if(optind >= argc) { if(optind >= argc) {
systemMessage(0,"Missing image name"); systemMessage(0,"Missing image name");
@ -2194,7 +2194,7 @@ int main(int argc, char **argv)
if(optind < argc) { if(optind < argc) {
char *szFile = argv[optind]; char *szFile = argv[optind];
u32 len = strlen(szFile); 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); fprintf(stderr,"%s :%s: File name too long\n",argv[0],szFile);
exit(-1); exit(-1);
@ -2208,7 +2208,7 @@ int main(int argc, char **argv)
if(ipsname[0] == 0) if(ipsname[0] == 0)
sprintf(ipsname, "%s.ips", filename); sprintf(ipsname, "%s.ips", filename);
bool failed = false; bool failed = false;
IMAGE_TYPE type = utilFindType(szFile); IMAGE_TYPE type = utilFindType(szFile);
@ -2218,12 +2218,12 @@ int main(int argc, char **argv)
exit(-1); exit(-1);
} }
cartridgeType = (int)type; cartridgeType = (int)type;
if(type == IMAGE_GB) { if(type == IMAGE_GB) {
failed = !gbLoadRom(szFile); failed = !gbLoadRom(szFile);
if(!failed) { if(!failed) {
gbGetHardwareType(); gbGetHardwareType();
// used for the handling of the gb Boot Rom // used for the handling of the gb Boot Rom
if (gbHardware & 5) if (gbHardware & 5)
{ {
@ -2236,7 +2236,7 @@ int main(int argc, char **argv)
gbCPUInit(tempName, useBios); gbCPUInit(tempName, useBios);
} }
else useBios = false; else useBios = false;
gbReset(); gbReset();
cartridgeType = IMAGE_GB; cartridgeType = IMAGE_GB;
emulator = GBSystem; emulator = GBSystem;
@ -2257,7 +2257,7 @@ int main(int argc, char **argv)
sdlApplyPerImagePreferences(); sdlApplyPerImagePreferences();
doMirroring(mirroringEnable); doMirroring(mirroringEnable);
cartridgeType = 0; cartridgeType = 0;
emulator = GBASystem; emulator = GBASystem;
@ -2266,7 +2266,7 @@ int main(int argc, char **argv)
WRITE32LE(&rom[0], 0xea00002e); WRITE32LE(&rom[0], 0xea00002e);
} }
*/ */
CPUInit(biosFileName, useBios); CPUInit(biosFileName, useBios);
CPUReset(); CPUReset();
if(sdlAutoIPS) { if(sdlAutoIPS) {
@ -2278,7 +2278,7 @@ int main(int argc, char **argv)
} }
} }
} }
if(failed) { if(failed) {
systemMessage(0, "Failed to load file %s", szFile); systemMessage(0, "Failed to load file %s", szFile);
exit(-1); exit(-1);
@ -2297,22 +2297,22 @@ int main(int argc, char **argv)
ioMem = (u8 *)calloc(1, 0x400); ioMem = (u8 *)calloc(1, 0x400);
emulator = GBASystem; emulator = GBASystem;
CPUInit(biosFileName, useBios); CPUInit(biosFileName, useBios);
CPUReset(); CPUReset();
} }
sdlReadBattery(); sdlReadBattery();
if(debuggerStub) if(debuggerStub)
remoteInit(); remoteInit();
int flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO| int flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO|
SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE; SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE;
if(soundOffFlag) if(soundOffFlag)
flags ^= SDL_INIT_AUDIO; flags ^= SDL_INIT_AUDIO;
if(SDL_Init(flags)) { if(SDL_Init(flags)) {
systemMessage(0, "Failed to init SDL: %s", SDL_GetError()); systemMessage(0, "Failed to init SDL: %s", SDL_GetError());
exit(-1); exit(-1);
@ -2321,9 +2321,9 @@ int main(int argc, char **argv)
if(SDL_InitSubSystem(SDL_INIT_JOYSTICK)) { if(SDL_InitSubSystem(SDL_INIT_JOYSTICK)) {
systemMessage(0, "Failed to init joystick support: %s", SDL_GetError()); systemMessage(0, "Failed to init joystick support: %s", SDL_GetError());
} }
sdlCheckKeys(); sdlCheckKeys();
if(cartridgeType == 0) { if(cartridgeType == 0) {
srcWidth = 240; srcWidth = 240;
srcHeight = 160; srcHeight = 160;
@ -2335,7 +2335,7 @@ int main(int argc, char **argv)
gbBorderLineSkip = 256; gbBorderLineSkip = 256;
gbBorderColumnSkip = 48; gbBorderColumnSkip = 48;
gbBorderRowSkip = 40; gbBorderRowSkip = 40;
} else { } else {
srcWidth = 160; srcWidth = 160;
srcHeight = 144; srcHeight = 144;
gbBorderLineSkip = 160; gbBorderLineSkip = 160;
@ -2347,24 +2347,24 @@ int main(int argc, char **argv)
srcWidth = 320; srcWidth = 320;
srcHeight = 240; srcHeight = 240;
} }
destWidth = (sizeOption+1)*srcWidth; destWidth = (sizeOption+1)*srcWidth;
destHeight = (sizeOption+1)*srcHeight; destHeight = (sizeOption+1)*srcHeight;
surface = SDL_SetVideoMode(destWidth, destHeight, 16, surface = SDL_SetVideoMode(destWidth, destHeight, 16,
SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF| SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF|
(fullscreen ? SDL_FULLSCREEN : 0)); (fullscreen ? SDL_FULLSCREEN : 0));
if(surface == NULL) { if(surface == NULL) {
systemMessage(0, "Failed to set video mode"); systemMessage(0, "Failed to set video mode");
SDL_Quit(); SDL_Quit();
exit(-1); exit(-1);
} }
systemRedShift = sdlCalculateShift(surface->format->Rmask); systemRedShift = sdlCalculateShift(surface->format->Rmask);
systemGreenShift = sdlCalculateShift(surface->format->Gmask); systemGreenShift = sdlCalculateShift(surface->format->Gmask);
systemBlueShift = sdlCalculateShift(surface->format->Bmask); systemBlueShift = sdlCalculateShift(surface->format->Bmask);
systemColorDepth = surface->format->BitsPerPixel; systemColorDepth = surface->format->BitsPerPixel;
if(systemColorDepth == 15) if(systemColorDepth == 15)
systemColorDepth = 16; systemColorDepth = 16;
@ -2376,7 +2376,7 @@ int main(int argc, char **argv)
systemGreenShift = 11; systemGreenShift = 11;
systemBlueShift = 19; systemBlueShift = 19;
} }
if(systemColorDepth != 16 && systemColorDepth != 24 && if(systemColorDepth != 16 && systemColorDepth != 24 &&
systemColorDepth != 32) { systemColorDepth != 32) {
fprintf(stderr,"Unsupported color depth '%d'.\nOnly 16, 24 and 32 bit color depths are supported\n", systemColorDepth); 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 #endif
fprintf(stderr,"Color depth: %d\n", systemColorDepth); fprintf(stderr,"Color depth: %d\n", systemColorDepth);
if(systemColorDepth == 16) { if(systemColorDepth == 16) {
if(sdlCalculateMaskWidth(surface->format->Gmask) == 6) { if(sdlCalculateMaskWidth(surface->format->Gmask) == 6) {
Init_2xSaI(565); Init_2xSaI(565);
@ -2520,7 +2520,7 @@ int main(int argc, char **argv)
break; break;
} }
} }
if(systemColorDepth == 16) { if(systemColorDepth == 16) {
switch(ifbType) { switch(ifbType) {
case 0: case 0:
@ -2554,7 +2554,7 @@ int main(int argc, char **argv)
delta = (u8*)malloc(322*242*4); delta = (u8*)malloc(322*242*4);
memset(delta, 255, 322*242*4); memset(delta, 255, 322*242*4);
} }
emulating = 1; emulating = 1;
renderedFrames = 0; renderedFrames = 0;
@ -2562,7 +2562,7 @@ int main(int argc, char **argv)
soundInit(); soundInit();
autoFrameSkipLastTime = throttleLastTime = systemGetClock(); autoFrameSkipLastTime = throttleLastTime = systemGetClock();
SDL_WM_SetCaption("VisualBoyAdvance", NULL); SDL_WM_SetCaption("VisualBoyAdvance", NULL);
while(emulating) { while(emulating) {
@ -2576,7 +2576,7 @@ int main(int argc, char **argv)
if(rewindCount > 8) if(rewindCount > 8)
rewindCount = 8; rewindCount = 8;
if(emulator.emuWriteMemState && if(emulator.emuWriteMemState &&
emulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE], emulator.emuWriteMemState(&rewindMemory[rewindPos*REWIND_SIZE],
REWIND_SIZE)) { REWIND_SIZE)) {
rewindPos = (rewindPos + 1) & 7; rewindPos = (rewindPos + 1) & 7;
if(rewindCount == 8) if(rewindCount == 8)
@ -2596,7 +2596,7 @@ int main(int argc, char **argv)
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
} }
} }
emulating = 0; emulating = 0;
fprintf(stderr,"Shutting down\n"); fprintf(stderr,"Shutting down\n");
remoteCleanUp(); remoteCleanUp();
@ -2611,7 +2611,7 @@ int main(int argc, char **argv)
free(delta); free(delta);
delta = NULL; delta = NULL;
} }
SDL_Quit(); SDL_Quit();
return 0; return 0;
} }
@ -2620,10 +2620,10 @@ void systemMessage(int num, const char *msg, ...)
{ {
char buffer[SYSMSG_BUFFER_SIZE*2]; char buffer[SYSMSG_BUFFER_SIZE*2];
va_list valist; va_list valist;
va_start(valist, msg); va_start(valist, msg);
vsprintf(buffer, msg, valist); vsprintf(buffer, msg, valist);
fprintf(stderr, "%s\n", buffer); fprintf(stderr, "%s\n", buffer);
va_end(valist); va_end(valist);
} }
@ -2631,12 +2631,12 @@ void systemMessage(int num, const char *msg, ...)
void systemDrawScreen() void systemDrawScreen()
{ {
renderedFrames++; renderedFrames++;
if(yuv) { if(yuv) {
Draw_Overlay(surface, sizeOption+1); Draw_Overlay(surface, sizeOption+1);
return; return;
} }
SDL_LockSurface(surface); SDL_LockSurface(surface);
if(screenMessage) { if(screenMessage) {
@ -2646,7 +2646,7 @@ void systemDrawScreen()
if(((systemGetClock() - screenMessageTime) < 3000) && if(((systemGetClock() - screenMessageTime) < 3000) &&
!disableStatusMessages) { !disableStatusMessages) {
drawText(pix, srcPitch, 10, srcHeight - 20, drawText(pix, srcPitch, 10, srcHeight - 20,
screenMessageBuffer); screenMessageBuffer);
} else { } else {
screenMessage = false; screenMessage = false;
} }
@ -2658,7 +2658,7 @@ void systemDrawScreen()
else else
ifbFunction(pix+destWidth*2+4, destWidth*2+4, srcWidth, srcHeight); ifbFunction(pix+destWidth*2+4, destWidth*2+4, srcWidth, srcHeight);
} }
if(filterFunction) { if(filterFunction) {
if(systemColorDepth == 16) if(systemColorDepth == 16)
filterFunction(pix+destWidth+4,destWidth+4, delta, filterFunction(pix+destWidth+4,destWidth+4, delta,
@ -2694,7 +2694,7 @@ void systemDrawScreen()
break; break;
case 1: case 1:
for(i = 0; i < srcHeight; i++) { for(i = 0; i < srcHeight; i++) {
SDL_CALL_STRETCHER; SDL_CALL_STRETCHER;
dest += destPitch; dest += destPitch;
SDL_CALL_STRETCHER; SDL_CALL_STRETCHER;
src += srcPitch; src += srcPitch;
@ -2747,8 +2747,8 @@ void systemDrawScreen()
surface->pitch, surface->pitch,
10, 10,
surface->h-20, surface->h-20,
buffer); buffer);
} }
SDL_UnlockSurface(surface); SDL_UnlockSurface(surface);
// SDL_UpdateRect(surface, 0, 0, destWidth, destHeight); // SDL_UpdateRect(surface, 0, 0, destWidth, destHeight);
@ -2764,9 +2764,9 @@ u32 systemReadJoypad(int which)
{ {
if(which < 0 || which > 3) if(which < 0 || which > 3)
which = sdlDefaultJoypad; which = sdlDefaultJoypad;
u32 res = 0; u32 res = 0;
if(sdlButtons[which][KEY_BUTTON_A]) if(sdlButtons[which][KEY_BUTTON_A])
res |= 1; res |= 1;
if(sdlButtons[which][KEY_BUTTON_B]) if(sdlButtons[which][KEY_BUTTON_B])
@ -2805,7 +2805,7 @@ u32 systemReadJoypad(int which)
res |= autoFire; res |= autoFire;
autoFireToggle = !autoFireToggle; autoFireToggle = !autoFireToggle;
} }
return res; return res;
} }
@ -2819,7 +2819,7 @@ void systemShowSpeed(int speed)
systemSpeed = speed; systemSpeed = speed;
showRenderedFrames = renderedFrames; showRenderedFrames = renderedFrames;
renderedFrames = 0; renderedFrames = 0;
if(!fullscreen && showSpeed) { if(!fullscreen && showSpeed) {
char buffer[80]; char buffer[80];
@ -2840,14 +2840,14 @@ void systemFrame()
void system10Frames(int rate) void system10Frames(int rate)
{ {
u32 time = systemGetClock(); u32 time = systemGetClock();
if(!wasPaused && autoFrameSkip && !throttle) { if(!wasPaused && autoFrameSkip && !throttle) {
u32 diff = time - autoFrameSkipLastTime; u32 diff = time - autoFrameSkipLastTime;
int speed = 100; int speed = 100;
if(diff) if(diff)
speed = (1000000/rate)/diff; speed = (1000000/rate)/diff;
if(speed >= 98) { if(speed >= 98) {
frameskipadjust++; frameskipadjust++;
@ -2867,15 +2867,15 @@ void system10Frames(int rate)
if(systemFrameSkip < 9) if(systemFrameSkip < 9)
systemFrameSkip++; systemFrameSkip++;
} }
} }
} }
if(!wasPaused && throttle) { if(!wasPaused && throttle) {
if(!speedup) { if(!speedup) {
u32 diff = time - throttleLastTime; u32 diff = time - throttleLastTime;
int target = (1000000/(rate*throttle)); int target = (1000000/(rate*throttle));
int d = (target - diff); int d = (target - diff);
if(d > 0) { if(d > 0) {
SDL_Delay(d); SDL_Delay(d);
} }
@ -3102,7 +3102,7 @@ void systemUpdateMotionSensor()
sensorY += 2; sensorY += 2;
if(sensorY > 2047) if(sensorY > 2047)
sensorY = 2047; sensorY = 2047;
} }
} }
int systemGetSensorX() int systemGetSensorX()
@ -3127,7 +3127,7 @@ void systemScreenMessage(const char *msg)
strncpy(screenMessageBuffer, msg, 20); strncpy(screenMessageBuffer, msg, 20);
screenMessageBuffer[20] = 0; screenMessageBuffer[20] = 0;
} else } else
strcpy(screenMessageBuffer, msg); strcpy(screenMessageBuffer, msg);
} }
bool systemCanChangeSoundQuality() bool systemCanChangeSoundQuality()
@ -3153,7 +3153,7 @@ bool systemPauseOnFrame()
void Init_Overlay(SDL_Surface *gbascreen, int overlaytype) void Init_Overlay(SDL_Surface *gbascreen, int overlaytype)
{ {
overlay = SDL_CreateYUVOverlay( GBA_WIDTH, overlay = SDL_CreateYUVOverlay( GBA_WIDTH,
GBA_HEIGHT, GBA_HEIGHT,
overlaytype, gbascreen); overlaytype, gbascreen);
@ -3170,7 +3170,7 @@ void Init_Overlay(SDL_Surface *gbascreen, int overlaytype)
void Quit_Overlay(void) void Quit_Overlay(void)
{ {
SDL_FreeYUVOverlay(overlay); SDL_FreeYUVOverlay(overlay);
} }
@ -3189,16 +3189,16 @@ inline void ConvertRGBtoYV12(SDL_Overlay *o)
int x,y; int x,y;
int yuv[3]; int yuv[3];
Uint8 *p,*op[3]; Uint8 *p,*op[3];
SDL_LockYUVOverlay(o); SDL_LockYUVOverlay(o);
/* Black initialization */ /* Black initialization */
/* /*
memset(o->pixels[0],0,o->pitches[0]*o->h); 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[1],128,o->pitches[1]*((o->h+1)/2));
memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2)); memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
*/ */
/* Convert */ /* Convert */
for(y=0; y<160 && y<o->h; y++) { for(y=0; y<160 && y<o->h; y++) {
p=(Uint8 *)pix+srcPitch*y; p=(Uint8 *)pix+srcPitch*y;
@ -3215,7 +3215,7 @@ inline void ConvertRGBtoYV12(SDL_Overlay *o)
p+=4;//s->format->BytesPerPixel; p+=4;//s->format->BytesPerPixel;
} }
} }
SDL_UnlockYUVOverlay(o); SDL_UnlockYUVOverlay(o);
} }
@ -3224,16 +3224,16 @@ inline void ConvertRGBtoIYUV(SDL_Overlay *o)
int x,y; int x,y;
int yuv[3]; int yuv[3];
Uint8 *p,*op[3]; Uint8 *p,*op[3];
SDL_LockYUVOverlay(o); SDL_LockYUVOverlay(o);
/* Black initialization */ /* Black initialization */
/* /*
memset(o->pixels[0],0,o->pitches[0]*o->h); 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[1],128,o->pitches[1]*((o->h+1)/2));
memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2)); memset(o->pixels[2],128,o->pitches[2]*((o->h+1)/2));
*/ */
/* Convert */ /* Convert */
for(y=0; y<160 && y<o->h; y++) { for(y=0; y<160 && y<o->h; y++) {
p=(Uint8 *)pix+srcPitch*y; p=(Uint8 *)pix+srcPitch*y;
@ -3250,7 +3250,7 @@ inline void ConvertRGBtoIYUV(SDL_Overlay *o)
p+=4; //s->format->BytesPerPixel; p+=4; //s->format->BytesPerPixel;
} }
} }
SDL_UnlockYUVOverlay(o); SDL_UnlockYUVOverlay(o);
} }
@ -3259,9 +3259,9 @@ inline void ConvertRGBtoUYVY(SDL_Overlay *o)
int x,y; int x,y;
int yuv[3]; int yuv[3];
Uint8 *p,*op; Uint8 *p,*op;
SDL_LockYUVOverlay(o); SDL_LockYUVOverlay(o);
for(y=0; y<160 && y<o->h; y++) { for(y=0; y<160 && y<o->h; y++) {
p=(Uint8 *)pix+srcPitch*y; p=(Uint8 *)pix+srcPitch*y;
op=o->pixels[0]+o->pitches[0]*y; op=o->pixels[0]+o->pitches[0]*y;
@ -3273,11 +3273,11 @@ inline void ConvertRGBtoUYVY(SDL_Overlay *o)
*(op++)=yuv[2]; *(op++)=yuv[2];
} else } else
*(op++)=yuv[0]; *(op++)=yuv[0];
p+=4; //s->format->BytesPerPixel; p+=4; //s->format->BytesPerPixel;
} }
} }
SDL_UnlockYUVOverlay(o); SDL_UnlockYUVOverlay(o);
} }
@ -3286,9 +3286,9 @@ inline void ConvertRGBtoYVYU(SDL_Overlay *o)
int x,y; int x,y;
int yuv[3]; int yuv[3];
Uint8 *p,*op; Uint8 *p,*op;
SDL_LockYUVOverlay(o); SDL_LockYUVOverlay(o);
for(y=0; y<160 && y<o->h; y++) { for(y=0; y<160 && y<o->h; y++) {
p=(Uint8 *)pix+srcPitch*y; p=(Uint8 *)pix+srcPitch*y;
op=o->pixels[0]+o->pitches[0]*y; op=o->pixels[0]+o->pitches[0]*y;
@ -3302,11 +3302,11 @@ inline void ConvertRGBtoYVYU(SDL_Overlay *o)
*op=yuv[0]; *op=yuv[0];
op+=2; op+=2;
} }
p+=4; //s->format->BytesPerPixel; p+=4; //s->format->BytesPerPixel;
} }
} }
SDL_UnlockYUVOverlay(o); SDL_UnlockYUVOverlay(o);
} }
@ -3315,9 +3315,9 @@ inline void ConvertRGBtoYUY2(SDL_Overlay *o)
int x,y; int x,y;
int yuv[3]; int yuv[3];
Uint8 *p,*op; Uint8 *p,*op;
SDL_LockYUVOverlay(o); SDL_LockYUVOverlay(o);
for(y=0; y<160 && y<o->h; y++) { for(y=0; y<160 && y<o->h; y++) {
p=(Uint8 *)pix+srcPitch*y; p=(Uint8 *)pix+srcPitch*y;
op=o->pixels[0]+o->pitches[0]*y; op=o->pixels[0]+o->pitches[0]*y;
@ -3331,11 +3331,11 @@ inline void ConvertRGBtoYUY2(SDL_Overlay *o)
*op=yuv[0]; *op=yuv[0];
op+=2; op+=2;
} }
p+=4; //s->format->BytesPerPixel; p+=4; //s->format->BytesPerPixel;
} }
} }
SDL_UnlockYUVOverlay(o); SDL_UnlockYUVOverlay(o);
} }
@ -3362,16 +3362,16 @@ inline void Convert32bit(SDL_Surface *display)
exit(1); exit(1);
break; break;
} }
} }
inline void Draw_Overlay(SDL_Surface *display, int size) inline void Draw_Overlay(SDL_Surface *display, int size)
{ {
SDL_LockYUVOverlay(overlay); SDL_LockYUVOverlay(overlay);
Convert32bit(display); Convert32bit(display);
overlay_rect.x = 0; overlay_rect.x = 0;
overlay_rect.y = 0; overlay_rect.y = 0;
overlay_rect.w = GBA_WIDTH * size; overlay_rect.w = GBA_WIDTH * size;
@ -3391,10 +3391,10 @@ void systemGbBorderOn()
destWidth = (sizeOption+1)*srcWidth; destWidth = (sizeOption+1)*srcWidth;
destHeight = (sizeOption+1)*srcHeight; destHeight = (sizeOption+1)*srcHeight;
surface = SDL_SetVideoMode(destWidth, destHeight, 16, surface = SDL_SetVideoMode(destWidth, destHeight, 16,
SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF| SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF|
(fullscreen ? SDL_FULLSCREEN : 0)); (fullscreen ? SDL_FULLSCREEN : 0));
#ifndef C_CORE #ifndef C_CORE
sdlMakeStretcher(srcWidth); sdlMakeStretcher(srcWidth);
#else #else
@ -3420,19 +3420,19 @@ void systemGbBorderOn()
RGB_LOW_BITS_MASK = 0x821; RGB_LOW_BITS_MASK = 0x821;
} else { } else {
Init_2xSaI(555); Init_2xSaI(555);
RGB_LOW_BITS_MASK = 0x421; RGB_LOW_BITS_MASK = 0x421;
} }
if(cartridgeType == 2) { if(cartridgeType == 2) {
for(int i = 0; i < 0x10000; i++) { for(int i = 0; i < 0x10000; i++) {
systemColorMap16[i] = (((i >> 1) & 0x1f) << systemBlueShift) | systemColorMap16[i] = (((i >> 1) & 0x1f) << systemBlueShift) |
(((i & 0x7c0) >> 6) << systemGreenShift) | (((i & 0x7c0) >> 6) << systemGreenShift) |
(((i & 0xf800) >> 11) << systemRedShift); (((i & 0xf800) >> 11) << systemRedShift);
} }
} else { } else {
for(int i = 0; i < 0x10000; i++) { for(int i = 0; i < 0x10000; i++) {
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
(((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift); (((i & 0x7c00) >> 10) << systemBlueShift);
} }
} }
srcPitch = srcWidth * 2+4; srcPitch = srcWidth * 2+4;
@ -3446,7 +3446,7 @@ void systemGbBorderOn()
for(int i = 0; i < 0x10000; i++) { for(int i = 0; i < 0x10000; i++) {
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
(((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x3e0) >> 5) << systemGreenShift) |
(((i & 0x7c00) >> 10) << systemBlueShift); (((i & 0x7c00) >> 10) << systemBlueShift);
} }
if(systemColorDepth == 32) if(systemColorDepth == 32)
srcPitch = srcWidth*4 + 4; srcPitch = srcWidth*4 + 4;

View File

@ -220,11 +220,11 @@ static void debuggerPrefetch()
static void debuggerApplyBreakpoint(u32 address, int num, int size) static void debuggerApplyBreakpoint(u32 address, int num, int size)
{ {
if(size) if(size)
debuggerWriteMemory(address, (u32)(0xe1200070 | debuggerWriteMemory(address, (u32)(0xe1200070 |
(num & 0xf) | (num & 0xf) |
((num<<4)&0xf0))); ((num<<4)&0xf0)));
else else
debuggerWriteHalfWord(address, debuggerWriteHalfWord(address,
(u16)(0xbe00 | num)); (u16)(0xbe00 | num));
} }
@ -236,7 +236,7 @@ static void debuggerDisableBreakpoints()
debuggerBreakpointList[i].value); debuggerBreakpointList[i].value);
else else
debuggerWriteHalfWord(debuggerBreakpointList[i].address, debuggerWriteHalfWord(debuggerBreakpointList[i].address,
debuggerBreakpointList[i].value); debuggerBreakpointList[i].value);
} }
} }
@ -249,7 +249,7 @@ static void debuggerEnableBreakpoints(bool skipPC)
debuggerApplyBreakpoint(debuggerBreakpointList[i].address, debuggerApplyBreakpoint(debuggerBreakpointList[i].address,
i, i,
debuggerBreakpointList[i].size); debuggerBreakpointList[i].size);
} }
} }
static void debuggerUsage(const char *cmd) static void debuggerUsage(const char *cmd)
@ -257,8 +257,8 @@ static void debuggerUsage(const char *cmd)
for(int i = 0; ; i++) { for(int i = 0; ; i++) {
if(debuggerCommands[i].name) { if(debuggerCommands[i].name) {
if(!strcmp(debuggerCommands[i].name, cmd)) { if(!strcmp(debuggerCommands[i].name, cmd)) {
printf("%s %s\n\n%s\n", printf("%s %s\n\n%s\n",
debuggerCommands[i].name, debuggerCommands[i].name,
debuggerCommands[i].syntax ? debuggerCommands[i].syntax : "", debuggerCommands[i].syntax ? debuggerCommands[i].syntax : "",
debuggerCommands[i].help); debuggerCommands[i].help);
break; break;
@ -267,7 +267,7 @@ static void debuggerUsage(const char *cmd)
printf("Unrecognized command '%s'.", cmd); printf("Unrecognized command '%s'.", cmd);
break; break;
} }
} }
} }
static void debuggerPrintBaseType(Type *t, u32 value, u32 location, static void debuggerPrintBaseType(Type *t, u32 value, u32 location,
@ -325,7 +325,7 @@ static void debuggerPrintBaseType(Type *t, u32 value, u32 location,
} }
return; return;
} }
switch(t->encoding) { switch(t->encoding) {
case DW_ATE_boolean: case DW_ATE_boolean:
if(value) if(value)
@ -367,9 +367,9 @@ static void debuggerPrintBaseType(Type *t, u32 value, u32 location,
static const char *debuggerPrintType(Type *t) static const char *debuggerPrintType(Type *t)
{ {
char buffer[1024]; char buffer[1024];
static char buffer2[1024]; static char buffer2[1024];
if(t->type == TYPE_pointer) { if(t->type == TYPE_pointer) {
if(t->pointer) if(t->pointer)
strcpy(buffer, debuggerPrintType(t->pointer)); strcpy(buffer, debuggerPrintType(t->pointer));
@ -380,7 +380,7 @@ static const char *debuggerPrintType(Type *t)
} else if(t->type == TYPE_reference) { } else if(t->type == TYPE_reference) {
strcpy(buffer, debuggerPrintType(t->pointer)); strcpy(buffer, debuggerPrintType(t->pointer));
sprintf(buffer2, "%s &", buffer); sprintf(buffer2, "%s &", buffer);
return buffer2; return buffer2;
} }
return t->name; return t->name;
} }
@ -441,7 +441,7 @@ static void debuggerPrintMember(Function *f,
v = debuggerReadHalfWord(location); v = debuggerReadHalfWord(location);
else if(size == 4) else if(size == 4)
v = debuggerReadMemory(location); v = debuggerReadMemory(location);
while(bitSize) { while(bitSize) {
int top = size*8 - off; int top = size*8 - off;
int bot = top - bitSize; int bot = top - bitSize;
@ -467,7 +467,7 @@ static void debuggerPrintMember(Function *f,
} else { } else {
debuggerPrintValueInternal(f, m->type, m->location, m->bitSize, debuggerPrintValueInternal(f, m->type, m->location, m->bitSize,
m->bitOffset, objLocation); m->bitOffset, objLocation);
} }
} }
static void debuggerPrintStructure(Function *f, Type *t, u32 objLocation) static void debuggerPrintStructure(Function *f, Type *t, u32 objLocation)
@ -555,14 +555,14 @@ static void debuggerPrintValueInternal(Function *f, Type *t,
default: default:
printf("%08x", value); printf("%08x", value);
break; break;
} }
} }
static void debuggerPrintValueInternal(Function *f, Type *t, ELFBlock *loc, static void debuggerPrintValueInternal(Function *f, Type *t, ELFBlock *loc,
int bitSize, int bitOffset, int bitSize, int bitOffset,
u32 objLocation) u32 objLocation)
{ {
LocationType type; LocationType type;
u32 location; u32 location;
if(loc) { if(loc) {
if(objLocation) if(objLocation)
@ -580,7 +580,7 @@ static void debuggerPrintValueInternal(Function *f, Type *t, ELFBlock *loc,
static void debuggerPrintValue(Function *f, Object *o) static void debuggerPrintValue(Function *f, Object *o)
{ {
debuggerPrintValueInternal(f, o->type, o->location, 0, 0, 0); debuggerPrintValueInternal(f, o->type, o->location, 0, 0, 0);
printf("\n"); printf("\n");
} }
@ -593,7 +593,7 @@ static void debuggerSymbols(int argc, char **argv)
bool match = false; bool match = false;
int matchSize = 0; int matchSize = 0;
const char *matchStr = NULL; const char *matchStr = NULL;
if(argc == 2) { if(argc == 2) {
match = true; match = true;
matchSize = strlen(argv[1]); matchSize = strlen(argv[1]);
@ -665,7 +665,7 @@ static void debuggerPrint(int argc, char **argv)
u32 pc = armNextPC; u32 pc = armNextPC;
Function *f = NULL; Function *f = NULL;
CompileUnit *u = NULL; CompileUnit *u = NULL;
elfGetCurrentFunction(pc, elfGetCurrentFunction(pc,
&f, &u); &f, &u);
@ -686,8 +686,8 @@ static void debuggerPrint(int argc, char **argv)
printf("Unknown option %s\n", argv[1]); printf("Unknown option %s\n", argv[1]);
return; return;
} }
} }
const char *s = argc == 2 ? argv[1] : argv[2]; const char *s = argc == 2 ? argv[1] : argv[2];
extern const char *exprString; extern const char *exprString;
@ -748,7 +748,7 @@ static void debuggerDebug(int n, char **args)
systemDebug = v; systemDebug = v;
printf("Debug level set to %d\n", systemDebug); printf("Debug level set to %d\n", systemDebug);
} else } else
debuggerUsage("trace"); debuggerUsage("trace");
} }
static void debuggerVerbose(int n, char **args) static void debuggerVerbose(int n, char **args)
@ -759,7 +759,7 @@ static void debuggerVerbose(int n, char **args)
systemVerbose = v; systemVerbose = v;
printf("Verbose level set to %d\n", systemVerbose); printf("Verbose level set to %d\n", systemVerbose);
} else } else
debuggerUsage("verbose"); debuggerUsage("verbose");
} }
static void debuggerWhere(int n, char **args) static void debuggerWhere(int n, char **args)
@ -791,11 +791,11 @@ static void debuggerLocals(int n, char **args)
printf("%s=", o->name); printf("%s=", o->name);
debuggerPrintValue(f, o); debuggerPrintValue(f, o);
} }
o = o->next; o = o->next;
} }
} else { } else {
printf("No information for current address\n"); printf("No information for current address\n");
} }
} }
static void debuggerNext(int n, char **args) static void debuggerNext(int n, char **args)
@ -820,7 +820,7 @@ static void debuggerNext(int n, char **args)
if(elfGetCurrentFunction(a, &f, &u)) { if(elfGetCurrentFunction(a, &f, &u)) {
const char *file; const char *file;
int line = elfFindLine(u, f, a, &file); int line = elfFindLine(u, f, a, &file);
printf("File %s, function %s, line %d\n", file, f->name, printf("File %s, function %s, line %d\n", file, f->name,
line); line);
} }
@ -864,7 +864,7 @@ static void debuggerContinue(int n, char **args)
Function *f = NULL; Function *f = NULL;
CompileUnit *u = NULL; CompileUnit *u = NULL;
if(elfGetCurrentFunction(armNextPC, &f, &u)) { if(elfGetCurrentFunction(armNextPC, &f, &u)) {
const char *file; const char *file;
int line = elfFindLine(u,f,armNextPC,&file); int line = elfFindLine(u,f,armNextPC,&file);
@ -900,11 +900,11 @@ static void debuggerBreakDelete(int n, char **args)
n++; n++;
if(n < debuggerNumOfBreakpoints) { if(n < debuggerNumOfBreakpoints) {
for(int i = n; i < debuggerNumOfBreakpoints; i++) { for(int i = n; i < debuggerNumOfBreakpoints; i++) {
debuggerBreakpointList[i-1].address = debuggerBreakpointList[i-1].address =
debuggerBreakpointList[i].address; debuggerBreakpointList[i].address;
debuggerBreakpointList[i-1].value = debuggerBreakpointList[i-1].value =
debuggerBreakpointList[i].value; debuggerBreakpointList[i].value;
debuggerBreakpointList[i-1].size = debuggerBreakpointList[i-1].size =
debuggerBreakpointList[i].size; debuggerBreakpointList[i].size;
} }
} }
@ -913,7 +913,7 @@ static void debuggerBreakDelete(int n, char **args)
else else
printf("No breakpoints are set\n"); printf("No breakpoints are set\n");
} else } else
debuggerUsage("bd"); debuggerUsage("bd");
} }
static void debuggerBreak(int n, char **args) static void debuggerBreak(int n, char **args)
@ -933,7 +933,7 @@ static void debuggerBreak(int n, char **args)
u32 addr; u32 addr;
Function *f; Function *f;
CompileUnit *u; CompileUnit *u;
if(elfFindLineInModule(&addr, name, line)) { if(elfFindLineInModule(&addr, name, line)) {
if(elfGetCurrentFunction(addr, &f, &u)) { if(elfGetCurrentFunction(addr, &f, &u)) {
u32 addr2; u32 addr2;
@ -956,7 +956,7 @@ static void debuggerBreak(int n, char **args)
Function *f; Function *f;
CompileUnit *u; CompileUnit *u;
u32 addr; u32 addr;
if(elfGetCurrentFunction(armNextPC, &f, &u)) { if(elfGetCurrentFunction(armNextPC, &f, &u)) {
if(elfFindLineInUnit(&addr, u, line)) { if(elfFindLineInUnit(&addr, u, line)) {
if(elfGetCurrentFunction(addr, &f, &u)) { if(elfGetCurrentFunction(addr, &f, &u)) {
@ -997,14 +997,14 @@ static void debuggerBreak(int n, char **args)
// debuggerApplyBreakpoint(address, i, size); // debuggerApplyBreakpoint(address, i, size);
debuggerNumOfBreakpoints++; debuggerNumOfBreakpoints++;
if(size) if(size)
printf("Added ARM breakpoint at %08x\n", address); printf("Added ARM breakpoint at %08x\n", address);
else else
printf("Added THUMB breakpoint at %08x\n", address); printf("Added THUMB breakpoint at %08x\n", address);
} else { } else {
printf("%s is not a function symbol\n", args[1]); printf("%s is not a function symbol\n", args[1]);
} }
} else } else
debuggerUsage("break"); debuggerUsage("break");
} }
static void debuggerBreakThumb(int n, char **args) static void debuggerBreakThumb(int n, char **args)
@ -1020,7 +1020,7 @@ static void debuggerBreakThumb(int n, char **args)
debuggerNumOfBreakpoints++; debuggerNumOfBreakpoints++;
printf("Added THUMB breakpoint at %08x\n", address); printf("Added THUMB breakpoint at %08x\n", address);
} else } else
debuggerUsage("bt"); debuggerUsage("bt");
} }
static void debuggerBreakArm(int n, char **args) static void debuggerBreakArm(int n, char **args)
@ -1039,7 +1039,7 @@ static void debuggerBreakArm(int n, char **args)
debuggerUsage("ba"); debuggerUsage("ba");
} }
/*extern*/ void debuggerBreakOnWrite(u32 address, u32 oldvalue, u32 value, /*extern*/ void debuggerBreakOnWrite(u32 address, u32 oldvalue, u32 value,
int size, int t) int size, int t)
{ {
const char *type = "write"; const char *type = "write";
@ -1047,13 +1047,13 @@ static void debuggerBreakArm(int n, char **args)
type = "change"; type = "change";
if(size == 2) 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); type, address, oldvalue, value);
else if(size == 1) 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); type, address, (u16)oldvalue,(u16)value);
else 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); type, address, (u8)oldvalue, (u8)value);
debugger = true; debugger = true;
} }
@ -1070,12 +1070,12 @@ static void debuggerBreakWriteClear(int n, char **args)
(address >= 0x03000000 && address < 0x03008000) || (address >= 0x03000000 && address < 0x03008000) ||
(address >= 0x05000000 && address < 0x05000400) || (address >= 0x05000000 && address < 0x05000400) ||
(address >= 0x06000000 && address < 0x06018000) || (address >= 0x06000000 && address < 0x06018000) ||
(address >= 0x07000000 && address < 0x07000400))) { (address >= 0x07000000 && address < 0x07000400))) {
printf("Invalid address: %08x\n", address); printf("Invalid address: %08x\n", address);
return; return;
} }
u32 final = address + n; u32 final = address + n;
switch(address >> 24) { switch(address >> 24) {
case 2: case 2:
{ {
@ -1173,12 +1173,12 @@ static void debuggerBreakWrite(int n, char **args)
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
if (! ((address >= 0x02000000 && address < 0x02040000) || if (! ((address >= 0x02000000 && address < 0x02040000) ||
(address >= 0x03000000 && address < 0x03008000) || (address >= 0x03000000 && address < 0x03008000) ||
(address >= 0x05000000 && address < 0x05000400) || (address >= 0x05000000 && address < 0x05000400) ||
(address >= 0x06000000 && address < 0x06018000) || (address >= 0x06000000 && address < 0x06018000) ||
(address >= 0x07000000 && address < 0x07000400))) { (address >= 0x07000000 && address < 0x07000400))) {
printf("Invalid address: %08x\n", address); printf("Invalid address: %08x\n", address);
return; return;
} }
@ -1227,9 +1227,9 @@ static void debuggerBreakWrite(int n, char **args)
freezeOAM[(address + i) & 0x3ff] = 1; freezeOAM[(address + i) & 0x3ff] = 1;
break; break;
} }
} else } else
debuggerUsage("bpw"); debuggerUsage("bpw");
} }
static void debuggerBreakChangeClear(int n, char **args) static void debuggerBreakChangeClear(int n, char **args)
@ -1239,17 +1239,17 @@ static void debuggerBreakChangeClear(int n, char **args)
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
if (! ((address >= 0x02000000 && address < 0x02040000) || if (! ((address >= 0x02000000 && address < 0x02040000) ||
(address >= 0x03000000 && address < 0x03008000) || (address >= 0x03000000 && address < 0x03008000) ||
(address >= 0x05000000 && address < 0x05000400) || (address >= 0x05000000 && address < 0x05000400) ||
(address >= 0x06000000 && address < 0x06018000) || (address >= 0x06000000 && address < 0x06018000) ||
(address >= 0x07000000 && address < 0x07000400))) { (address >= 0x07000000 && address < 0x07000400))) {
printf("Invalid address: %08x\n", address); printf("Invalid address: %08x\n", address);
return; return;
} }
u32 final = address + n; u32 final = address + n;
switch(address >> 24) { switch(address >> 24) {
case 2: case 2:
{ {
@ -1329,7 +1329,7 @@ static void debuggerBreakChangeClear(int n, char **args)
for(i = 0; i < 0x400; i++) for(i = 0; i < 0x400; i++)
if(freezeOAM[i] == 2) if(freezeOAM[i] == 2)
freezeOAM[i] = 0; freezeOAM[i] = 0;
printf("Cleared all break on change\n"); printf("Cleared all break on change\n");
} else } else
debuggerUsage("bpcc"); debuggerUsage("bpcc");
@ -1346,12 +1346,12 @@ static void debuggerBreakChange(int n, char **args)
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
if (! ((address >= 0x02000000 && address < 0x02040000) || if (! ((address >= 0x02000000 && address < 0x02040000) ||
(address >= 0x03000000 && address < 0x03008000) || (address >= 0x03000000 && address < 0x03008000) ||
(address >= 0x05000000 && address < 0x05000400) || (address >= 0x05000000 && address < 0x05000400) ||
(address >= 0x06000000 && address < 0x06018000) || (address >= 0x06000000 && address < 0x06018000) ||
(address >= 0x07000000 && address < 0x07000400))) { (address >= 0x07000000 && address < 0x07000400))) {
printf("Invalid address: %08x\n", address); printf("Invalid address: %08x\n", address);
return; return;
} }
@ -1372,7 +1372,7 @@ static void debuggerBreakChange(int n, char **args)
return; return;
} }
printf("Added break on change at %08x for %d bytes\n", address, n); printf("Added break on change at %08x for %d bytes\n", address, n);
switch(address >> 24) { switch(address >> 24) {
case 2: case 2:
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
@ -1431,8 +1431,8 @@ static void debuggerDisassembleThumb(FILE *f, u32 pc, int count)
if(l > len) if(l > len)
len = l; len = l;
} }
sprintf(format, "%%08x %%-%ds %%s\n", len); sprintf(format, "%%08x %%-%ds %%s\n", len);
for(i = 0; i < count; i++) { for(i = 0; i < count; i++) {
u32 addr = pc; u32 addr = pc;
pc += disThumb(pc, buffer, 2); pc += disThumb(pc, buffer, 2);
@ -1455,7 +1455,7 @@ static void debuggerDisassembleArm(int n, char **args)
if(n >= 3) { if(n >= 3) {
sscanf(args[2], "%d", &count); sscanf(args[2], "%d", &count);
} }
debuggerDisassembleArm(stdout, pc, count); debuggerDisassembleArm(stdout, pc, count);
} }
static void debuggerDisassembleThumb(int n, char **args) static void debuggerDisassembleThumb(int n, char **args)
@ -1508,7 +1508,7 @@ static void debuggerFileDisassembleArm(int n, char **args)
if(n >= 4) { if(n >= 4) {
sscanf(args[3], "%d", &count); sscanf(args[3], "%d", &count);
} }
debuggerDisassembleArm(f, pc, count); debuggerDisassembleArm(f, pc, count);
fclose(f); fclose(f);
} }
@ -1526,7 +1526,7 @@ static void debuggerFileDisassembleThumb(int n, char **args)
printf("Error: cannot open file %s\n", args[1]); printf("Error: cannot open file %s\n", args[1]);
return; return;
} }
if(n >= 3) { if(n >= 3) {
sscanf(args[2], "%x", &pc); sscanf(args[2], "%x", &pc);
} }
@ -1547,7 +1547,7 @@ void debuggerFindText(int n, char **args)
{ {
SearchResults = 0; SearchResults = 0;
sscanf(args[1], "%x", &SearchStart); sscanf(args[1], "%x", &SearchStart);
if (n == 4) if (n == 4)
{ {
sscanf(args[2], "%u", &SearchMaxMatches); sscanf(args[2], "%u", &SearchMaxMatches);
@ -1567,7 +1567,7 @@ void debuggerFindText(int n, char **args)
}; };
debuggerDoSearch (); debuggerDoSearch ();
} else } else
debuggerUsage("ft"); debuggerUsage("ft");
}; };
@ -1578,7 +1578,7 @@ void debuggerFindHex(int n, char **args)
{ {
SearchResults = 0; SearchResults = 0;
sscanf(args[1], "%x", &SearchStart); sscanf(args[1], "%x", &SearchStart);
char SearchHex [128]; char SearchHex [128];
if (n == 4) if (n == 4)
{ {
@ -1609,9 +1609,9 @@ void debuggerFindHex(int n, char **args)
sscanf (&SearchHex [i << 1], "%02x", &cbuf); sscanf (&SearchHex [i << 1], "%02x", &cbuf);
SearchData [i] = cbuf; SearchData [i] = cbuf;
}; };
debuggerDoSearch (); debuggerDoSearch ();
} else } else
debuggerUsage("fh"); debuggerUsage("fh");
}; };
@ -1626,10 +1626,10 @@ void debuggerFindResume(int n, char **args)
debuggerUsage("fr"); debuggerUsage("fr");
return; return;
}; };
if (n == 2) if (n == 2)
sscanf(args[1], "%u", &SearchMaxMatches); sscanf(args[1], "%u", &SearchMaxMatches);
debuggerDoSearch(); debuggerDoSearch();
} else } else
@ -1857,16 +1857,16 @@ static void debuggerIoDMA()
{ {
printf("DM0SAD = %08x\n", (DM0SAD_H<<16)|DM0SAD_L); printf("DM0SAD = %08x\n", (DM0SAD_H<<16)|DM0SAD_L);
printf("DM0DAD = %08x\n", (DM0DAD_H<<16)|DM0DAD_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("DM1SAD = %08x\n", (DM1SAD_H<<16)|DM1SAD_L);
printf("DM1DAD = %08x\n", (DM1DAD_H<<16)|DM1DAD_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("DM2SAD = %08x\n", (DM2SAD_H<<16)|DM2SAD_L);
printf("DM2DAD = %08x\n", (DM2DAD_H<<16)|DM2DAD_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("DM3SAD = %08x\n", (DM3SAD_H<<16)|DM3SAD_L);
printf("DM3DAD = %08x\n", (DM3DAD_H<<16)|DM3DAD_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() static void debuggerIoTimer()
@ -1883,7 +1883,7 @@ static void debuggerIoTimer()
static void debuggerIoMisc() static void debuggerIoMisc()
{ {
printf("P1 = %04x\n", P1); printf("P1 = %04x\n", P1);
printf("IE = %04x\n", IE); printf("IE = %04x\n", IE);
printf("IF = %04x\n", IF); printf("IF = %04x\n", IF);
printf("IME = %04x\n", IME); printf("IME = %04x\n", IME);
@ -1917,7 +1917,7 @@ static void debuggerEditByte(int n, char **args)
sscanf(args[2], "%x", &byte); sscanf(args[2], "%x", &byte);
debuggerWriteByte(address, (u8)byte); debuggerWriteByte(address, (u8)byte);
} else } else
debuggerUsage("eb"); debuggerUsage("eb");
} }
static void debuggerEditHalfWord(int n, char **args) static void debuggerEditHalfWord(int n, char **args)
@ -1933,7 +1933,7 @@ static void debuggerEditHalfWord(int n, char **args)
sscanf(args[2], "%x", &HalfWord); sscanf(args[2], "%x", &HalfWord);
debuggerWriteHalfWord(address, (u16)HalfWord); debuggerWriteHalfWord(address, (u16)HalfWord);
} else } else
debuggerUsage("eh"); debuggerUsage("eh");
} }
static void debuggerEditRegister(int n, char **args) static void debuggerEditRegister(int n, char **args)
@ -1951,7 +1951,7 @@ static void debuggerEditRegister(int n, char **args)
reg[r].I=val; reg[r].I=val;
printf("Register changed.\n"); printf("Register changed.\n");
} else } else
debuggerUsage("er"); debuggerUsage("er");
} }
static void debuggerEdit(int n, char **args) static void debuggerEdit(int n, char **args)
@ -1967,7 +1967,7 @@ static void debuggerEdit(int n, char **args)
sscanf(args[2], "%x", &byte); sscanf(args[2], "%x", &byte);
debuggerWriteMemory(address, (u32)byte); debuggerWriteMemory(address, (u32)byte);
} else } else
debuggerUsage("ew"); debuggerUsage("ew");
} }
@ -1995,7 +1995,7 @@ static void debuggerMemoryByte(int n, char **args)
int n = debuggerReadByte(addr+13); int n = debuggerReadByte(addr+13);
int o = debuggerReadByte(addr+14); int o = debuggerReadByte(addr+14);
int p = debuggerReadByte(addr+15); 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", 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, 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), ASCII(a),ASCII(b),ASCII(c),ASCII(d),
@ -2005,7 +2005,7 @@ static void debuggerMemoryByte(int n, char **args)
addr += 16; addr += 16;
} }
} else } else
debuggerUsage("mb"); debuggerUsage("mb");
} }
static void debuggerMemoryHalfWord(int n, char **args) static void debuggerMemoryHalfWord(int n, char **args)
@ -2031,7 +2031,7 @@ static void debuggerMemoryHalfWord(int n, char **args)
int n = debuggerReadByte(addr+13); int n = debuggerReadByte(addr+13);
int o = debuggerReadByte(addr+14); int o = debuggerReadByte(addr+14);
int p = debuggerReadByte(addr+15); 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", 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, 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), ASCII(a),ASCII(b),ASCII(c),ASCII(d),
@ -2041,7 +2041,7 @@ static void debuggerMemoryHalfWord(int n, char **args)
addr += 16; addr += 16;
} }
} else } else
debuggerUsage("mh"); debuggerUsage("mh");
} }
static void debuggerMemory(int n, char **args) static void debuggerMemory(int n, char **args)
@ -2070,7 +2070,7 @@ static void debuggerMemory(int n, char **args)
int n = debuggerReadByte(addr+13); int n = debuggerReadByte(addr+13);
int o = debuggerReadByte(addr+14); int o = debuggerReadByte(addr+14);
int p = debuggerReadByte(addr+15); 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", 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, 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), ASCII(a),ASCII(b),ASCII(c),ASCII(d),
@ -2080,7 +2080,7 @@ static void debuggerMemory(int n, char **args)
addr += 16; addr += 16;
} }
} else } else
debuggerUsage("mw"); debuggerUsage("mw");
} }
static void debuggerQuit(int, char **) static void debuggerQuit(int, char **)
@ -2088,7 +2088,7 @@ static void debuggerQuit(int, char **)
char buffer[10]; char buffer[10];
printf("Are you sure you want to quit (y/n)? "); printf("Are you sure you want to quit (y/n)? ");
fgets(buffer, 1024, stdin); fgets(buffer, 1024, stdin);
if(buffer[0] == 'y' || buffer[0] == 'Y') { if(buffer[0] == 'y' || buffer[0] == 'Y') {
debugger = false; debugger = false;
emulating = false; emulating = false;
@ -2131,22 +2131,22 @@ static void debuggerDumpLoad(int n, char** args)
const char *file; const char *file;
FILE *f; FILE *f;
int c; int c;
if(n==3) { if(n==3) {
file=args[1]; file=args[1];
sscanf(args[2],"%x",&address); sscanf(args[2],"%x",&address);
f=fopen(file,"rb"); f=fopen(file,"rb");
if(!f) { if(!f) {
printf("Error opening file.\n"); printf("Error opening file.\n");
return; return;
} }
fseek(f,0,SEEK_END); fseek(f,0,SEEK_END);
int size=ftell(f); int size=ftell(f);
fseek(f,0,SEEK_SET); fseek(f,0,SEEK_SET);
for(int i=0;i<size;i++) { for(int i=0;i<size;i++) {
c = fgetc(f); c = fgetc(f);
if(c == -1) if(c == -1)
@ -2166,23 +2166,23 @@ static void debuggerDumpSave(int n, char** args)
u32 size = 0; u32 size = 0;
const char *file; const char *file;
FILE *f; FILE *f;
if(n==4) { if(n==4) {
file=args[1]; file=args[1];
sscanf(args[2],"%x",&address); sscanf(args[2],"%x",&address);
sscanf(args[3],"%x",&size); sscanf(args[3],"%x",&size);
f=fopen(file,"wb"); f=fopen(file,"wb");
if(!f) { if(!f) {
printf("Error opening file.\n"); printf("Error opening file.\n");
return; return;
} }
for(u32 i = 0; i < size; i++) { for(u32 i = 0; i < size; i++) {
fputc(debuggerReadByte(address), f); fputc(debuggerReadByte(address), f);
address++; address++;
} }
fclose(f); fclose(f);
} else } else
debuggerUsage("dsave"); debuggerUsage("dsave");
@ -2192,14 +2192,14 @@ static void debuggerCondBreakThumb(int n, char **args)
{ {
if(n > 4) { //conditional args handled separately if(n > 4) { //conditional args handled separately
int i = debuggerNumOfBreakpoints; int i = debuggerNumOfBreakpoints;
u32 address = 0; u32 address = 0;
sscanf(args[1],"%x", &address); sscanf(args[1],"%x", &address);
debuggerBreakpointList[i].address = address; debuggerBreakpointList[i].address = address;
debuggerBreakpointList[i].value = debuggerReadHalfWord(address); debuggerBreakpointList[i].value = debuggerReadHalfWord(address);
debuggerBreakpointList[i].size = 0; debuggerBreakpointList[i].size = 0;
debuggerCondValidate(n, args,2); debuggerCondValidate(n, args,2);
} else } else
debuggerUsage("cbt"); debuggerUsage("cbt");
@ -2209,10 +2209,10 @@ static void debuggerCondBreakThumb(int n, char **args)
static void debuggerCondBreakArm(int n, char **args) static void debuggerCondBreakArm(int n, char **args)
{ {
if(n > 4) { //conditional args handled separately if(n > 4) { //conditional args handled separately
int i = debuggerNumOfBreakpoints; int i = debuggerNumOfBreakpoints;
u32 address = 0; u32 address = 0;
sscanf(args[1],"%x", &address); sscanf(args[1],"%x", &address);
debuggerBreakpointList[i].address = address; debuggerBreakpointList[i].address = address;
debuggerBreakpointList[i].value = debuggerReadMemory(address); debuggerBreakpointList[i].value = debuggerReadMemory(address);
@ -2230,29 +2230,29 @@ static void debuggerCondValidate(int n, char **args,int start)
2: value 2: value
3: size 3: size
*/ */
int i=debuggerNumOfBreakpoints; int i=debuggerNumOfBreakpoints;
char *address=args[start]; char *address=args[start];
const char *op=args[start+1]; const char *op=args[start+1];
char *value=args[start+2]; char *value=args[start+2];
const char *tsize,*taddress,*tvalue; const char *tsize,*taddress,*tvalue;
int rel=0; int rel=0;
u32 value1=0; u32 value1=0;
u32 value2=0; u32 value2=0;
char size=0; char size=0;
int j=1; int j=1;
if(n==6) { if(n==6) {
size = args[start+3][0]; size = args[start+3][0];
if(size != 'b' && size != 'h' && size != 'w') { if(size != 'b' && size != 'h' && size != 'w') {
printf("Invalid size.\n"); printf("Invalid size.\n");
return; return;
} }
switch(size) { switch(size) {
case 'b': case 'b':
debuggerBreakpointList[i].cond_size=1; debuggerBreakpointList[i].cond_size=1;
@ -2276,7 +2276,7 @@ static void debuggerCondValidate(int n, char **args,int start)
j++; j++;
} }
address[j-1]=0; address[j-1]=0;
sscanf(address,"%x",&value1); sscanf(address,"%x",&value1);
switch(size) { switch(size) {
case 'h': case 'h':
@ -2307,7 +2307,7 @@ static void debuggerCondValidate(int n, char **args,int start)
} }
address[j-1]=0; address[j-1]=0;
sscanf(address,"%d",&value1); sscanf(address,"%d",&value1);
if(value1 > 16) { if(value1 > 16) {
printf("Invalid Register.\n"); printf("Invalid Register.\n");
return; return;
@ -2324,12 +2324,12 @@ static void debuggerCondValidate(int n, char **args,int start)
debuggerBreakpointList[i].cond_address = value1; debuggerBreakpointList[i].cond_address = value1;
// Check op // Check op
switch(op[0]) { switch(op[0]) {
case '=': // 1 case '=': // 1
if (op[1] == '=' && op[2]==0) if (op[1] == '=' && op[2]==0)
rel=1; rel=1;
else else
goto error; goto error;
break; break;
case '!': //2 case '!': //2
@ -2359,7 +2359,7 @@ static void debuggerCondValidate(int n, char **args,int start)
printf("Invalid comparison operator.\n"); printf("Invalid comparison operator.\n");
return; return;
} }
if(op==0) { if(op==0) {
printf("Invalid comparison operator.\n"); printf("Invalid comparison operator.\n");
return; return;
@ -2404,7 +2404,7 @@ static void debuggerCondValidate(int n, char **args,int start)
} }
value[j-1]=0; value[j-1]=0;
sscanf(value,"%d",&value2); sscanf(value,"%d",&value2);
if(value2 > 16) { if(value2 > 16) {
printf("Invalid Register.\n"); printf("Invalid Register.\n");
return; return;
@ -2416,7 +2416,7 @@ static void debuggerCondValidate(int n, char **args,int start)
sscanf(value, "%x",&value2); sscanf(value, "%x",&value2);
debuggerBreakpointList[i].ia2=false; debuggerBreakpointList[i].ia2=false;
tvalue="0x"; tvalue="0x";
switch(size) { switch(size) {
case 'b': case 'b':
value2 &=0xFF; value2 &=0xFF;
@ -2431,10 +2431,10 @@ static void debuggerCondValidate(int n, char **args,int start)
} }
break; break;
} }
debuggerBreakpointList[i].cond_value = value2; debuggerBreakpointList[i].cond_value = value2;
debuggerNumOfBreakpoints++; debuggerNumOfBreakpoints++;
// At here, everything's set. Display message. // At here, everything's set. Display message.
switch(size) { switch(size) {
case 0: case 0:
@ -2477,13 +2477,13 @@ static bool debuggerCondEvaluate(int num)
// check if there is a condition // check if there is a condition
if(debuggerBreakpointList[num].cond_rel == 0) if(debuggerBreakpointList[num].cond_rel == 0)
return true; return true;
u32 address=debuggerBreakpointList[num].cond_address; u32 address=debuggerBreakpointList[num].cond_address;
char size=debuggerBreakpointList[num].cond_size; char size=debuggerBreakpointList[num].cond_size;
u32 value=debuggerBreakpointList[num].cond_value; u32 value=debuggerBreakpointList[num].cond_value;
u32 value1=0; u32 value1=0;
u32 value2=0; u32 value2=0;
if(address<17) if(address<17)
value1=reg[address].I; value1=reg[address].I;
else { else {
@ -2499,7 +2499,7 @@ static bool debuggerCondEvaluate(int num)
break; break;
} }
} }
//value2 //value2
if(debuggerBreakpointList[num].ia2) { //is address or register if(debuggerBreakpointList[num].ia2) { //is address or register
if(value<17) if(value<17)
@ -2618,11 +2618,11 @@ char* strqtok (char* string, const char* ctrl)
char buffer[1024]; char buffer[1024];
char *commands[10]; char *commands[10];
int commandCount = 0; int commandCount = 0;
if(emulator.emuUpdateCPSR) if(emulator.emuUpdateCPSR)
emulator.emuUpdateCPSR(); emulator.emuUpdateCPSR();
debuggerRegisters(0, NULL); debuggerRegisters(0, NULL);
while(debugger) { while(debugger) {
systemSoundPause(); systemSoundPause();
debuggerDisableBreakpoints(); debuggerDisableBreakpoints();
@ -2649,7 +2649,7 @@ char* strqtok (char* string, const char* ctrl)
debuggerCommands[j].function(commandCount, commands); debuggerCommands[j].function(commandCount, commands);
break; break;
} }
} }
} }
} }

View File

@ -1,303 +1,303 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten // Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2005 Forgotten and the VBA development team // Copyright (C) 2005 Forgotten and the VBA development team
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option) // the Free Software Foundation; either version 2, or(at your option)
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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 // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "System.h" #include "System.h"
void Simple2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void Simple2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
u8 *nextLine, *finish; u8 *nextLine, *finish;
nextLine = dstPtr + dstPitch; nextLine = dstPtr + dstPitch;
do { do {
u32 *bP = (u32 *) srcPtr; u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr; u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine; u32 *nL = (u32 *) nextLine;
u32 currentPixel; u32 currentPixel;
finish = (u8 *) bP + ((width+2) << 1); finish = (u8 *) bP + ((width+2) << 1);
currentPixel = *bP++; currentPixel = *bP++;
do { do {
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
u32 color = currentPixel >> 16; u32 color = currentPixel >> 16;
#else #else
u32 color = currentPixel & 0xffff; u32 color = currentPixel & 0xffff;
#endif #endif
color = color | (color << 16); color = color | (color << 16);
*(dP) = color; *(dP) = color;
*(nL) = color; *(nL) = color;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
color = currentPixel & 0xffff; color = currentPixel & 0xffff;
#else #else
color = currentPixel >> 16; color = currentPixel >> 16;
#endif #endif
color = color| (color << 16); color = color| (color << 16);
*(dP + 1) = color; *(dP + 1) = color;
*(nL + 1) = color; *(nL + 1) = color;
currentPixel = *bP++; currentPixel = *bP++;
dP += 2; dP += 2;
nL += 2; nL += 2;
} while ((u8 *) bP < finish); } while ((u8 *) bP < finish);
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
nextLine += dstPitch << 1; nextLine += dstPitch << 1;
} }
while (--height); while (--height);
} }
void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
u8 *nextLine, *finish; u8 *nextLine, *finish;
nextLine = dstPtr + dstPitch; nextLine = dstPtr + dstPitch;
do { do {
u32 *bP = (u32 *) srcPtr; u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr; u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine; u32 *nL = (u32 *) nextLine;
u32 currentPixel; u32 currentPixel;
finish = (u8 *) bP + ((width+1) << 2); finish = (u8 *) bP + ((width+1) << 2);
currentPixel = *bP++; currentPixel = *bP++;
do { do {
u32 color = currentPixel; u32 color = currentPixel;
*(dP) = color; *(dP) = color;
*(dP+1) = color; *(dP+1) = color;
*(nL) = color; *(nL) = color;
*(nL + 1) = color; *(nL + 1) = color;
currentPixel = *bP++; currentPixel = *bP++;
dP += 2; dP += 2;
nL += 2; nL += 2;
} while ((u8 *) bP < finish); } while ((u8 *) bP < finish);
srcPtr += srcPitch; srcPtr += srcPitch;
dstPtr += dstPitch << 1; dstPtr += dstPitch << 1;
nextLine += dstPitch << 1; nextLine += dstPitch << 1;
} }
while (--height); while (--height);
} }
void Simple3x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void Simple3x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
#define magnification 3 #define magnification 3
#define colorBytes 2 // 16 bit colors = 2 byte colors #define colorBytes 2 // 16 bit colors = 2 byte colors
// Generic Simple magnification filter // Generic Simple magnification filter
int x, y; // Source Position Counter int x, y; // Source Position Counter
unsigned int dx, dy; // Destination pixel's pixels unsigned int dx, dy; // Destination pixel's pixels
unsigned short col; // Source color 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 srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
dstPitch = dstPitch / colorBytes; dstPitch = dstPitch / colorBytes;
unsigned short *src, *dst, *dst2; 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 src = (unsigned short *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
dst = (unsigned short *)dstPtr; dst = (unsigned short *)dstPtr;
for (y = 0; y < height; y++) // Line for (y = 0; y < height; y++) // Line
{ {
for (x = 0; x < width; x++) // Pixel in Line for (x = 0; x < width; x++) // Pixel in Line
{ {
col = *src; col = *src;
dst2 = dst; dst2 = dst;
*dst2 = col; *dst2 = col;
for (dy = 0; dy < magnification; dy++) for (dy = 0; dy < magnification; dy++)
{ {
for (dx = 0; dx < magnification; dx++) for (dx = 0; dx < magnification; dx++)
{ {
*dst2 = col; *dst2 = col;
dst2++; dst2++;
} }
dst2+=dstPitch; dst2+=dstPitch;
dst2-=magnification; dst2-=magnification;
} }
src++; src++;
dst+=magnification; dst+=magnification;
} }
src+=srcPitch; src+=srcPitch;
dst+=dstPitch * magnification; dst+=dstPitch * magnification;
dst-=width * magnification; dst-=width * magnification;
} }
#undef magnification #undef magnification
#undef colorBytes #undef colorBytes
} }
void Simple3x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void Simple3x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
#define magnification 3 #define magnification 3
#define colorBytes 4 // 32 bit colors = 4 byte colors #define colorBytes 4 // 32 bit colors = 4 byte colors
// Generic Simple magnification filter // Generic Simple magnification filter
int x, y; // Source Position Counter int x, y; // Source Position Counter
unsigned int dx, dy; // Destination pixel's pixels unsigned int dx, dy; // Destination pixel's pixels
unsigned int col; // Source color 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 srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
dstPitch = dstPitch / colorBytes; dstPitch = dstPitch / colorBytes;
unsigned int *src, *dst, *dst2; 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 src = (unsigned int *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
dst = (unsigned int *)dstPtr; dst = (unsigned int *)dstPtr;
for (y = 0; y < height; y++) // Line for (y = 0; y < height; y++) // Line
{ {
for (x = 0; x < width; x++) // Pixel in Line for (x = 0; x < width; x++) // Pixel in Line
{ {
col = *src; col = *src;
dst2 = dst; dst2 = dst;
*dst2 = col; *dst2 = col;
for (dy = 0; dy < magnification; dy++) for (dy = 0; dy < magnification; dy++)
{ {
for (dx = 0; dx < magnification; dx++) for (dx = 0; dx < magnification; dx++)
{ {
*dst2 = col; *dst2 = col;
dst2++; dst2++;
} }
dst2+=dstPitch; dst2+=dstPitch;
dst2-=magnification; dst2-=magnification;
} }
src++; src++;
dst+=magnification; dst+=magnification;
} }
src+=srcPitch; src+=srcPitch;
dst+=dstPitch * magnification; dst+=dstPitch * magnification;
dst-=width * magnification; dst-=width * magnification;
} }
#undef magnification #undef magnification
#undef colorBytes #undef colorBytes
} }
void Simple4x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void Simple4x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
#define magnification 4 #define magnification 4
#define colorBytes 2 // 16 bit colors = 2 byte colors #define colorBytes 2 // 16 bit colors = 2 byte colors
// Generic Simple magnification filter // Generic Simple magnification filter
int x, y; // Source Position Counter int x, y; // Source Position Counter
unsigned int dx, dy; // Destination pixel's pixels unsigned int dx, dy; // Destination pixel's pixels
unsigned short col; // Source color 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 srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
dstPitch = dstPitch / colorBytes; dstPitch = dstPitch / colorBytes;
unsigned short *src, *dst, *dst2; 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 src = (unsigned short *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
dst = (unsigned short *)dstPtr; dst = (unsigned short *)dstPtr;
for (y = 0; y < height; y++) // Line for (y = 0; y < height; y++) // Line
{ {
for (x = 0; x < width; x++) // Pixel in Line for (x = 0; x < width; x++) // Pixel in Line
{ {
col = *src; col = *src;
dst2 = dst; dst2 = dst;
*dst2 = col; *dst2 = col;
for (dy = 0; dy < magnification; dy++) for (dy = 0; dy < magnification; dy++)
{ {
for (dx = 0; dx < magnification; dx++) for (dx = 0; dx < magnification; dx++)
{ {
*dst2 = col; *dst2 = col;
dst2++; dst2++;
} }
dst2+=dstPitch; dst2+=dstPitch;
dst2-=magnification; dst2-=magnification;
} }
src++; src++;
dst+=magnification; dst+=magnification;
} }
src+=srcPitch; src+=srcPitch;
dst+=dstPitch * magnification; dst+=dstPitch * magnification;
dst-=width * magnification; dst-=width * magnification;
} }
#undef magnification #undef magnification
#undef colorBytes #undef colorBytes
} }
void Simple4x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void Simple4x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) u8 *dstPtr, u32 dstPitch, int width, int height)
{ {
#define magnification 4 #define magnification 4
#define colorBytes 4 // 32 bit colors = 4 byte colors #define colorBytes 4 // 32 bit colors = 4 byte colors
// Generic Simple magnification filter // Generic Simple magnification filter
int x, y; // Source Position Counter int x, y; // Source Position Counter
unsigned int dx, dy; // Destination pixel's pixels unsigned int dx, dy; // Destination pixel's pixels
unsigned int col; // Source color 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 srcPitch = (srcPitch / colorBytes) - width; // This is the part of the source pitch in pixels that is more than the source image
dstPitch = dstPitch / colorBytes; dstPitch = dstPitch / colorBytes;
unsigned int *src, *dst, *dst2; 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 src = (unsigned int *)srcPtr; // Since everything is time-critical this should be better than converting the pointers x*y times
dst = (unsigned int *)dstPtr; dst = (unsigned int *)dstPtr;
for (y = 0; y < height; y++) // Line for (y = 0; y < height; y++) // Line
{ {
for (x = 0; x < width; x++) // Pixel in Line for (x = 0; x < width; x++) // Pixel in Line
{ {
col = *src; col = *src;
dst2 = dst; dst2 = dst;
*dst2 = col; *dst2 = col;
for (dy = 0; dy < magnification; dy++) for (dy = 0; dy < magnification; dy++)
{ {
for (dx = 0; dx < magnification; dx++) for (dx = 0; dx < magnification; dx++)
{ {
*dst2 = col; *dst2 = col;
dst2++; dst2++;
} }
dst2+=dstPitch; dst2+=dstPitch;
dst2-=magnification; dst2-=magnification;
} }
src++; src++;
dst+=magnification; dst+=magnification;
} }
src+=srcPitch; src+=srcPitch;
dst+=dstPitch * magnification; dst+=dstPitch * magnification;
dst-=width * magnification; dst-=width * magnification;
} }
#undef magnification #undef magnification
#undef colorBytes #undef colorBytes
} }

View File

@ -1,481 +1,481 @@
#include <math.h> #include <math.h>
#include "libresample-0.1.3/include/libresample.h" #include "libresample-0.1.3/include/libresample.h"
#include "snd_interp.h" #include "snd_interp.h"
// this was once borrowed from libmodplug, and was also used to generate the FIR coefficient // this was once borrowed from libmodplug, and was also used to generate the FIR coefficient
// tables that ZSNES uses for its "FIR" interpolation mode // tables that ZSNES uses for its "FIR" interpolation mode
/* /*
------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------
fir interpolation doc, fir interpolation doc,
(derived from "an engineer's guide to fir digital filters", n.j. loy) (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)) 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) c[-N..N] = (i==0) ? fc : sin(fc*pi*i)/(pi*i)
then apply selected window to coefficients then apply selected window to coefficients
c[-N..N] *= w(0..N) c[-N..N] *= w(0..N)
with n in 2*N and w(n) being a window function (see loy) 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. then calculate gain and scale filter coefs to have unity gain.
------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------
*/ */
// quantizer scale of window coefs // quantizer scale of window coefs
#define WFIR_QUANTBITS 14 #define WFIR_QUANTBITS 14
#define WFIR_QUANTSCALE (1L<<WFIR_QUANTBITS) #define WFIR_QUANTSCALE (1L<<WFIR_QUANTBITS)
#define WFIR_8SHIFT (WFIR_QUANTBITS-8) #define WFIR_8SHIFT (WFIR_QUANTBITS-8)
#define WFIR_16BITSHIFT (WFIR_QUANTBITS) #define WFIR_16BITSHIFT (WFIR_QUANTBITS)
// log2(number)-1 of precalculated taps range is [4..12] // log2(number)-1 of precalculated taps range is [4..12]
#define WFIR_FRACBITS 12 #define WFIR_FRACBITS 12
#define WFIR_LUTLEN ((1L<<(WFIR_FRACBITS+1))+1) #define WFIR_LUTLEN ((1L<<(WFIR_FRACBITS+1))+1)
// number of samples in window // number of samples in window
#define WFIR_LOG2WIDTH 3 #define WFIR_LOG2WIDTH 3
#define WFIR_WIDTH (1L<<WFIR_LOG2WIDTH) #define WFIR_WIDTH (1L<<WFIR_LOG2WIDTH)
#define WFIR_SMPSPERWING ((WFIR_WIDTH-1)>>1) #define WFIR_SMPSPERWING ((WFIR_WIDTH-1)>>1)
// cutoff (1.0 == pi/2) // cutoff (1.0 == pi/2)
#define WFIR_CUTOFF 0.95f #define WFIR_CUTOFF 0.95f
// wfir type // wfir type
#define WFIR_HANN 0 #define WFIR_HANN 0
#define WFIR_HAMMING 1 #define WFIR_HAMMING 1
#define WFIR_BLACKMANEXACT 2 #define WFIR_BLACKMANEXACT 2
#define WFIR_BLACKMAN3T61 3 #define WFIR_BLACKMAN3T61 3
#define WFIR_BLACKMAN3T67 4 #define WFIR_BLACKMAN3T67 4
#define WFIR_BLACKMAN4T92 5 #define WFIR_BLACKMAN4T92 5
#define WFIR_BLACKMAN4T74 6 #define WFIR_BLACKMAN4T74 6
#define WFIR_KAISER4T 7 #define WFIR_KAISER4T 7
#define WFIR_LANCZOS 8 #define WFIR_LANCZOS 8
#define WFIR_TYPE WFIR_LANCZOS #define WFIR_TYPE WFIR_LANCZOS
// wfir help // wfir help
#ifndef M_zPI #ifndef M_zPI
#define M_zPI 3.1415926535897932384626433832795 #define M_zPI 3.1415926535897932384626433832795
#endif #endif
#define M_zEPS 1e-8 #define M_zEPS 1e-8
#define M_zBESSELEPS 1e-21 #define M_zBESSELEPS 1e-21
class CzWINDOWEDFIR class CzWINDOWEDFIR
{ public: { public:
CzWINDOWEDFIR( ); CzWINDOWEDFIR( );
~CzWINDOWEDFIR( ); ~CzWINDOWEDFIR( );
float coef( int _PCnr, float _POfs, float _PCut, int _PWidth, int _PType ) //float _PPos, float _PFc, int _PLen ) float coef( int _PCnr, float _POfs, float _PCut, int _PWidth, int _PType ) //float _PPos, float _PFc, int _PLen )
{ double _LWidthM1 = _PWidth-1; { double _LWidthM1 = _PWidth-1;
double _LWidthM1Half = 0.5*_LWidthM1; double _LWidthM1Half = 0.5*_LWidthM1;
double _LPosU = ((double)_PCnr - _POfs); double _LPosU = ((double)_PCnr - _POfs);
double _LPos = _LPosU-_LWidthM1Half; double _LPos = _LPosU-_LWidthM1Half;
double _LPIdl = 2.0*M_zPI/_LWidthM1; double _LPIdl = 2.0*M_zPI/_LWidthM1;
double _LWc,_LSi; double _LWc,_LSi;
if( fabs(_LPos)<M_zEPS ) if( fabs(_LPos)<M_zEPS )
{ _LWc = 1.0; { _LWc = 1.0;
_LSi = _PCut; _LSi = _PCut;
} }
else else
{ switch( _PType ) { switch( _PType )
{ case WFIR_HANN: { case WFIR_HANN:
_LWc = 0.50 - 0.50 * cos(_LPIdl*_LPosU); _LWc = 0.50 - 0.50 * cos(_LPIdl*_LPosU);
break; break;
case WFIR_HAMMING: case WFIR_HAMMING:
_LWc = 0.54 - 0.46 * cos(_LPIdl*_LPosU); _LWc = 0.54 - 0.46 * cos(_LPIdl*_LPosU);
break; break;
case WFIR_BLACKMANEXACT: case WFIR_BLACKMANEXACT:
_LWc = 0.42 - 0.50 * cos(_LPIdl*_LPosU) + 0.08 * cos(2.0*_LPIdl*_LPosU); _LWc = 0.42 - 0.50 * cos(_LPIdl*_LPosU) + 0.08 * cos(2.0*_LPIdl*_LPosU);
break; break;
case WFIR_BLACKMAN3T61: case WFIR_BLACKMAN3T61:
_LWc = 0.44959 - 0.49364 * cos(_LPIdl*_LPosU) + 0.05677 * cos(2.0*_LPIdl*_LPosU); _LWc = 0.44959 - 0.49364 * cos(_LPIdl*_LPosU) + 0.05677 * cos(2.0*_LPIdl*_LPosU);
break; break;
case WFIR_BLACKMAN3T67: case WFIR_BLACKMAN3T67:
_LWc = 0.42323 - 0.49755 * cos(_LPIdl*_LPosU) + 0.07922 * cos(2.0*_LPIdl*_LPosU); _LWc = 0.42323 - 0.49755 * cos(_LPIdl*_LPosU) + 0.07922 * cos(2.0*_LPIdl*_LPosU);
break; break;
case WFIR_BLACKMAN4T92: 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); _LWc = 0.35875 - 0.48829 * cos(_LPIdl*_LPosU) + 0.14128 * cos(2.0*_LPIdl*_LPosU) - 0.01168 * cos(3.0*_LPIdl*_LPosU);
break; break;
case WFIR_BLACKMAN4T74: 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); _LWc = 0.40217 - 0.49703 * cos(_LPIdl*_LPosU) + 0.09392 * cos(2.0*_LPIdl*_LPosU) - 0.00183 * cos(3.0*_LPIdl*_LPosU);
break; break;
case WFIR_KAISER4T: 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); _LWc = 0.40243 - 0.49804 * cos(_LPIdl*_LPosU) + 0.09831 * cos(2.0*_LPIdl*_LPosU) - 0.00122 * cos(3.0*_LPIdl*_LPosU);
break; break;
case WFIR_LANCZOS: case WFIR_LANCZOS:
_LWc = 1 - (sin(_LPIdl*_LPosU) / (_LPIdl*_LPosU)); _LWc = 1 - (sin(_LPIdl*_LPosU) / (_LPIdl*_LPosU));
break; break;
default: default:
_LWc = 1.0; _LWc = 1.0;
break; break;
} }
_LPos *= M_zPI; _LPos *= M_zPI;
_LSi = sin(_PCut*_LPos)/_LPos; _LSi = sin(_PCut*_LPos)/_LPos;
} }
return (float)(_LWc*_LSi); return (float)(_LWc*_LSi);
} }
static signed short lut[WFIR_LUTLEN*WFIR_WIDTH]; static signed short lut[WFIR_LUTLEN*WFIR_WIDTH];
}; };
signed short CzWINDOWEDFIR::lut[WFIR_LUTLEN*WFIR_WIDTH]; signed short CzWINDOWEDFIR::lut[WFIR_LUTLEN*WFIR_WIDTH];
CzWINDOWEDFIR::CzWINDOWEDFIR() CzWINDOWEDFIR::CzWINDOWEDFIR()
{ int _LPcl; { int _LPcl;
float _LPcllen = (float)(1L<<WFIR_FRACBITS); // number of precalculated lines for 0..1 (-1..0) float _LPcllen = (float)(1L<<WFIR_FRACBITS); // number of precalculated lines for 0..1 (-1..0)
float _LNorm = 1.0f / (float)(2.0f * _LPcllen); float _LNorm = 1.0f / (float)(2.0f * _LPcllen);
float _LCut = WFIR_CUTOFF; float _LCut = WFIR_CUTOFF;
float _LScale = (float)WFIR_QUANTSCALE; float _LScale = (float)WFIR_QUANTSCALE;
float _LGain,_LCoefs[WFIR_WIDTH]; float _LGain,_LCoefs[WFIR_WIDTH];
for( _LPcl=0;_LPcl<WFIR_LUTLEN;_LPcl++ ) for( _LPcl=0;_LPcl<WFIR_LUTLEN;_LPcl++ )
{ {
float _LOfs = ((float)_LPcl-_LPcllen)*_LNorm; float _LOfs = ((float)_LPcl-_LPcllen)*_LNorm;
int _LCc,_LIdx = _LPcl<<WFIR_LOG2WIDTH; int _LCc,_LIdx = _LPcl<<WFIR_LOG2WIDTH;
for( _LCc=0,_LGain=0.0f;_LCc<WFIR_WIDTH;_LCc++ ) for( _LCc=0,_LGain=0.0f;_LCc<WFIR_WIDTH;_LCc++ )
{ _LGain += (_LCoefs[_LCc] = coef( _LCc, _LOfs, _LCut, WFIR_WIDTH, WFIR_TYPE )); { _LGain += (_LCoefs[_LCc] = coef( _LCc, _LOfs, _LCut, WFIR_WIDTH, WFIR_TYPE ));
} }
_LGain = 1.0f/_LGain; _LGain = 1.0f/_LGain;
for( _LCc=0;_LCc<WFIR_WIDTH;_LCc++ ) for( _LCc=0;_LCc<WFIR_WIDTH;_LCc++ )
{ float _LCoef = (float)floor( 0.5 + _LScale*_LCoefs[_LCc]*_LGain ); { float _LCoef = (float)floor( 0.5 + _LScale*_LCoefs[_LCc]*_LGain );
lut[_LIdx+_LCc] = (signed short)( (_LCoef<-_LScale)?-_LScale:((_LCoef>_LScale)?_LScale:_LCoef) ); lut[_LIdx+_LCc] = (signed short)( (_LCoef<-_LScale)?-_LScale:((_LCoef>_LScale)?_LScale:_LCoef) );
} }
} }
} }
CzWINDOWEDFIR::~CzWINDOWEDFIR() CzWINDOWEDFIR::~CzWINDOWEDFIR()
{ // nothing todo { // nothing todo
} }
CzWINDOWEDFIR sfir; CzWINDOWEDFIR sfir;
template <class T, int buffer_size> template <class T, int buffer_size>
class sample_buffer class sample_buffer
{ {
int ptr, filled; int ptr, filled;
T * buffer; T * buffer;
public: public:
sample_buffer() : ptr(0), filled(0) sample_buffer() : ptr(0), filled(0)
{ {
buffer = new T[buffer_size]; buffer = new T[buffer_size];
} }
~sample_buffer() ~sample_buffer()
{ {
if (buffer) delete [] buffer; if (buffer) delete [] buffer;
} }
void clear() void clear()
{ {
ptr = filled = 0; ptr = filled = 0;
} }
inline int size() const inline int size() const
{ {
return filled; return filled;
} }
inline void push_back(T sample) inline void push_back(T sample)
{ {
buffer[ptr] = sample; buffer[ptr] = sample;
if (++ptr >= buffer_size) ptr = 0; if (++ptr >= buffer_size) ptr = 0;
if (filled < buffer_size) filled++; if (filled < buffer_size) filled++;
} }
inline void erase(int count) inline void erase(int count)
{ {
if (count > filled) filled = 0; if (count > filled) filled = 0;
else filled -= count; else filled -= count;
} }
inline T operator[] (int index) const inline T operator[] (int index) const
{ {
index += ptr - filled; index += ptr - filled;
if (index < 0) index += buffer_size; if (index < 0) index += buffer_size;
else if (index > buffer_size) index -= buffer_size; else if (index > buffer_size) index -= buffer_size;
return buffer[index]; return buffer[index];
} }
}; };
class foo_null : public foo_interpolate class foo_null : public foo_interpolate
{ {
int sample; int sample;
public: public:
foo_null() : sample(0) {} foo_null() : sample(0) {}
~foo_null() {} ~foo_null() {}
void reset() {} void reset() {}
void push(int psample) void push(int psample)
{ {
sample = psample; sample = psample;
} }
int pop() int pop()
{ {
return sample; return sample;
} }
}; };
class foo_linear : public foo_interpolate class foo_linear : public foo_interpolate
{ {
sample_buffer<int,4> samples; sample_buffer<int,4> samples;
int position; int position;
inline int smp(int index) inline int smp(int index)
{ {
return samples[index]; return samples[index];
} }
public: public:
foo_linear() foo_linear()
{ {
position = 0; position = 0;
} }
~foo_linear() {} ~foo_linear() {}
void reset() void reset()
{ {
position = 0; position = 0;
samples.clear(); samples.clear();
} }
void push(int sample) void push(int sample)
{ {
samples.push_back(sample); samples.push_back(sample);
} }
int pop() int pop()
{ {
int ret; int ret;
if (position > 0x7fff) if (position > 0x7fff)
{ {
int howmany = position >> 15; int howmany = position >> 15;
position &= 0x7fff; position &= 0x7fff;
samples.erase(howmany); samples.erase(howmany);
} }
if (samples.size() < 2) return 0; if (samples.size() < 2) return 0;
ret = smp(0) * (0x8000 - position); ret = smp(0) * (0x8000 - position);
ret += smp(1) * position; ret += smp(1) * position;
ret >>= 15; ret >>= 15;
position+=lrate; position+=lrate;
return ret; return ret;
} }
}; };
// and this integer cubic interpolation implementation was kind of borrowed from either TiMidity // 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... // or the P.E.Op.S. SPU project, or is in use in both, or something...
class foo_cubic : public foo_interpolate class foo_cubic : public foo_interpolate
{ {
sample_buffer<int,12> samples; sample_buffer<int,12> samples;
int position; int position;
inline int smp(int index) inline int smp(int index)
{ {
return samples[index]; return samples[index];
} }
public: public:
foo_cubic() foo_cubic()
{ {
position = 0; position = 0;
} }
~foo_cubic() {} ~foo_cubic() {}
void reset() void reset()
{ {
position = 0; position = 0;
samples.clear(); samples.clear();
} }
void push(int sample) void push(int sample)
{ {
samples.push_back(sample); samples.push_back(sample);
} }
int pop() int pop()
{ {
int ret; int ret;
if (position > 0x7fff) if (position > 0x7fff)
{ {
int howmany = position >> 15; int howmany = position >> 15;
position &= 0x7fff; position &= 0x7fff;
samples.erase(howmany); samples.erase(howmany);
} }
if (samples.size() < 4) return 0; if (samples.size() < 4) return 0;
ret = smp(3) - 3 * smp(2) + 3 * smp(1) - smp(0); ret = smp(3) - 3 * smp(2) + 3 * smp(1) - smp(0);
ret *= (position - (2 << 15)) / 6; ret *= (position - (2 << 15)) / 6;
ret >>= 15; ret >>= 15;
ret += smp(2) - 2 * smp(1) + smp(0); ret += smp(2) - 2 * smp(1) + smp(0);
ret *= (position - (1 << 15)) >> 1; ret *= (position - (1 << 15)) >> 1;
ret >>= 15; ret >>= 15;
ret += smp(1) - smp(0); ret += smp(1) - smp(0);
ret *= position; ret *= position;
ret >>= 15; ret >>= 15;
ret += smp(0); ret += smp(0);
if (ret > 32767) ret = 32767; if (ret > 32767) ret = 32767;
else if (ret < -32768) ret = -32768; else if (ret < -32768) ret = -32768;
position+=lrate; position+=lrate;
return ret; return ret;
} }
}; };
class foo_fir : public foo_interpolate class foo_fir : public foo_interpolate
{ {
sample_buffer<int,24> samples; sample_buffer<int,24> samples;
int position; int position;
inline int smp(int index) inline int smp(int index)
{ {
return samples[index]; return samples[index];
} }
public: public:
foo_fir() foo_fir()
{ {
position = 0; position = 0;
} }
~foo_fir() ~foo_fir()
{ {
position=666; position=666;
} }
void reset() void reset()
{ {
position = 0; position = 0;
samples.clear(); samples.clear();
} }
void push(int sample) void push(int sample)
{ {
samples.push_back(sample); samples.push_back(sample);
} }
int pop() int pop()
{ {
int ret; int ret;
if (position > 0x7fff) if (position > 0x7fff)
{ {
int howmany = position >> 15; int howmany = position >> 15;
position &= 0x7fff; position &= 0x7fff;
samples.erase(howmany); samples.erase(howmany);
} }
if (samples.size() < 8) return 0; if (samples.size() < 8) return 0;
ret = smp(0) * CzWINDOWEDFIR::lut[(position & ~7) ]; ret = smp(0) * CzWINDOWEDFIR::lut[(position & ~7) ];
ret += smp(1) * CzWINDOWEDFIR::lut[(position & ~7) + 1]; ret += smp(1) * CzWINDOWEDFIR::lut[(position & ~7) + 1];
ret += smp(2) * CzWINDOWEDFIR::lut[(position & ~7) + 2]; ret += smp(2) * CzWINDOWEDFIR::lut[(position & ~7) + 2];
ret += smp(3) * CzWINDOWEDFIR::lut[(position & ~7) + 3]; ret += smp(3) * CzWINDOWEDFIR::lut[(position & ~7) + 3];
ret += smp(4) * CzWINDOWEDFIR::lut[(position & ~7) + 4]; ret += smp(4) * CzWINDOWEDFIR::lut[(position & ~7) + 4];
ret += smp(5) * CzWINDOWEDFIR::lut[(position & ~7) + 5]; ret += smp(5) * CzWINDOWEDFIR::lut[(position & ~7) + 5];
ret += smp(6) * CzWINDOWEDFIR::lut[(position & ~7) + 6]; ret += smp(6) * CzWINDOWEDFIR::lut[(position & ~7) + 6];
ret += smp(7) * CzWINDOWEDFIR::lut[(position & ~7) + 7]; ret += smp(7) * CzWINDOWEDFIR::lut[(position & ~7) + 7];
ret >>= WFIR_QUANTBITS; ret >>= WFIR_QUANTBITS;
if (ret > 32767) ret = 32767; if (ret > 32767) ret = 32767;
else if (ret < -32768) ret = -32768; else if (ret < -32768) ret = -32768;
position+=lrate; position+=lrate;
return ret; return ret;
} }
}; };
class foo_libresample : public foo_interpolate class foo_libresample : public foo_interpolate
{ {
sample_buffer<float,32> samples; sample_buffer<float,32> samples;
void * resampler; void * resampler;
public: public:
foo_libresample() foo_libresample()
{ {
resampler = 0; resampler = 0;
} }
~foo_libresample() ~foo_libresample()
{ {
reset(); reset();
} }
void reset() void reset()
{ {
samples.clear(); samples.clear();
if (resampler) if (resampler)
{ {
resample_close(resampler); resample_close(resampler);
resampler = 0; resampler = 0;
} }
} }
void push(int sample) void push(int sample)
{ {
samples.push_back(float(sample)); samples.push_back(float(sample));
} }
int pop() int pop()
{ {
int ret; int ret;
if (!resampler) if (!resampler)
{ {
resampler = resample_open(0, .25, 44100. / 4000.); resampler = resample_open(0, .25, 44100. / 4000.);
} }
{ {
int count = samples.size(); int count = samples.size();
float * in = new float[count]; float * in = new float[count];
float out; float out;
int used, returned; int used, returned;
for (used = 0; used < count; used++) for (used = 0; used < count; used++)
{ {
in[used] = samples[used]; in[used] = samples[used];
} }
returned = resample_process(resampler, 32767. / lrate, in, count, 0, &used, &out, 1); returned = resample_process(resampler, 32767. / lrate, in, count, 0, &used, &out, 1);
if (used) if (used)
{ {
samples.erase(used); samples.erase(used);
} }
delete [] in; delete [] in;
if (returned < 1) return 0; if (returned < 1) return 0;
ret = (int)out; ret = (int)out;
} }
if (ret > 32767) ret = 32767; if (ret > 32767) ret = 32767;
else if (ret < -32768) ret = -32768; else if (ret < -32768) ret = -32768;
return ret; return ret;
} }
}; };
foo_interpolate * get_filter(int which) foo_interpolate * get_filter(int which)
{ {
switch (which) switch (which)
{ {
default: default:
return new foo_null; return new foo_null;
case 1: case 1:
return new foo_linear; return new foo_linear;
case 2: case 2:
return new foo_cubic; return new foo_cubic;
case 3: case 3:
return new foo_fir; return new foo_fir;
case 4: case 4:
return new foo_libresample; return new foo_libresample;
} }
} }

View File

@ -1,35 +1,35 @@
#ifndef __SND_INTERP_H__ #ifndef __SND_INTERP_H__
#define __SND_INTERP_H__ #define __SND_INTERP_H__
class foo_interpolate class foo_interpolate
{ {
public: public:
foo_interpolate() {} foo_interpolate() {}
virtual ~foo_interpolate() {}; virtual ~foo_interpolate() {};
virtual void reset() = 0; virtual void reset() = 0;
long lrate; long lrate;
virtual void rate(double rate) virtual void rate(double rate)
{ {
lrate = (int)(32768. * rate); lrate = (int)(32768. * rate);
}; };
virtual void push(int sample) = 0; virtual void push(int sample) = 0;
virtual int pop() = 0; virtual int pop() = 0;
}; };
extern foo_interpolate * get_filter(int which); extern foo_interpolate * get_filter(int which);
/* /*
// complicated, synced interface, specific to this implementation // complicated, synced interface, specific to this implementation
double calc_rate(int timer); double calc_rate(int timer);
void interp_switch(int which); void interp_switch(int which);
void interp_reset(int ch); void interp_reset(int ch);
inline void interp_push(int ch, int sample); inline void interp_push(int ch, int sample);
inline int interp_pop(int ch, double rate); */ inline int interp_pop(int ch, double rate); */
#endif #endif

View File

@ -25,7 +25,7 @@
for (xxx=0; xxx<18; xxx++){ \ for (xxx=0; xxx<18; xxx++){ \
oldreg[xxx]=reg[xxx].I; \ oldreg[xxx]=reg[xxx].I; \
} \ } \
} }
#ifdef C_CORE #ifdef C_CORE
@ -813,7 +813,7 @@ switch(opcode >> 8) {
int source = (opcode >> 3) & 0x07; int source = (opcode >> 3) & 0x07;
int shift = (opcode >> 6) & 0x1f; int shift = (opcode >> 6) & 0x1f;
u32 value; u32 value;
if(shift) { if(shift) {
LSL_RD_RM_I5; LSL_RD_RM_I5;
} else { } else {
@ -839,7 +839,7 @@ switch(opcode >> 8) {
int source = (opcode >> 3) & 0x07; int source = (opcode >> 3) & 0x07;
int shift = (opcode >> 6) & 0x1f; int shift = (opcode >> 6) & 0x1f;
u32 value; u32 value;
if(shift) { if(shift) {
LSR_RD_RM_I5; LSR_RD_RM_I5;
} else { } else {
@ -860,13 +860,13 @@ switch(opcode >> 8) {
case 0x15: case 0x15:
case 0x16: case 0x16:
case 0x17: case 0x17:
{ {
// ASR Rd, Rm, #Imm 5 // ASR Rd, Rm, #Imm 5
int dest = opcode & 0x07; int dest = opcode & 0x07;
int source = (opcode >> 3) & 0x07; int source = (opcode >> 3) & 0x07;
int shift = (opcode >> 6) & 0x1f; int shift = (opcode >> 6) & 0x1f;
u32 value; u32 value;
if(shift) { if(shift) {
ASR_RD_RM_I5; ASR_RD_RM_I5;
} else { } else {
@ -975,31 +975,31 @@ case 0x28:
case 0x30: case 0x30:
// ADD R0,#Offset8 // ADD R0,#Offset8
ADD_RN_O8(0); ADD_RN_O8(0);
break; break;
case 0x31: case 0x31:
// ADD R1,#Offset8 // ADD R1,#Offset8
ADD_RN_O8(1); ADD_RN_O8(1);
break; break;
case 0x32: case 0x32:
// ADD R2,#Offset8 // ADD R2,#Offset8
ADD_RN_O8(2); ADD_RN_O8(2);
break; break;
case 0x33: case 0x33:
// ADD R3,#Offset8 // ADD R3,#Offset8
ADD_RN_O8(3); ADD_RN_O8(3);
break; break;
case 0x34: case 0x34:
// ADD R4,#Offset8 // ADD R4,#Offset8
ADD_RN_O8(4); ADD_RN_O8(4);
break; break;
case 0x35: case 0x35:
// ADD R5,#Offset8 // ADD R5,#Offset8
ADD_RN_O8(5); ADD_RN_O8(5);
break; break;
case 0x36: case 0x36:
// ADD R6,#Offset8 // ADD R6,#Offset8
ADD_RN_O8(6); ADD_RN_O8(6);
break; break;
case 0x37: case 0x37:
// ADD R7,#Offset8 // ADD R7,#Offset8
ADD_RN_O8(7); ADD_RN_O8(7);
@ -1046,7 +1046,7 @@ case 0x28:
reg[dest].I &= reg[(opcode >> 3)&7].I; reg[dest].I &= reg[(opcode >> 3)&7].I;
N_FLAG = reg[dest].I & 0x80000000 ? true : false; N_FLAG = reg[dest].I & 0x80000000 ? true : false;
Z_FLAG = reg[dest].I ? false : true; Z_FLAG = reg[dest].I ? false : true;
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
#define THUMB_CONSOLE_OUTPUT(a,b) \ #define THUMB_CONSOLE_OUTPUT(a,b) \
if((opcode == 0x4000) && (reg[0].I == 0xC0DED00D)) {\ if((opcode == 0x4000) && (reg[0].I == 0xC0DED00D)) {\
extern void (*dbgOutput)(char *, u32);\ extern void (*dbgOutput)(char *, u32);\
@ -1082,7 +1082,7 @@ case 0x28:
value = 0; value = 0;
C_FLAG = false; C_FLAG = false;
} }
reg[dest].I = value; reg[dest].I = value;
} }
N_FLAG = reg[dest].I & 0x80000000 ? true : false; N_FLAG = reg[dest].I & 0x80000000 ? true : false;
Z_FLAG = reg[dest].I ? false : true; Z_FLAG = reg[dest].I ? false : true;
@ -1104,7 +1104,7 @@ case 0x28:
value = 0; value = 0;
C_FLAG = false; C_FLAG = false;
} }
reg[dest].I = value; reg[dest].I = value;
} }
N_FLAG = reg[dest].I & 0x80000000 ? true : false; N_FLAG = reg[dest].I & 0x80000000 ? true : false;
Z_FLAG = reg[dest].I ? false : true; Z_FLAG = reg[dest].I ? false : true;
@ -1124,7 +1124,7 @@ case 0x28:
if(value) { if(value) {
if(value < 32) { if(value < 32) {
ASR_RD_RS; ASR_RD_RS;
reg[dest].I = value; reg[dest].I = value;
} else { } else {
if(reg[dest].I & 0x80000000){ if(reg[dest].I & 0x80000000){
reg[dest].I = 0xFFFFFFFF; reg[dest].I = 0xFFFFFFFF;
@ -1154,7 +1154,7 @@ case 0x28:
// SBC Rd, Rs // SBC Rd, Rs
int dest = opcode & 0x07; int dest = opcode & 0x07;
u32 value = reg[(opcode >> 3)&7].I; u32 value = reg[(opcode >> 3)&7].I;
// SBC // SBC
SBC_RD_RS; SBC_RD_RS;
} }
@ -1164,7 +1164,7 @@ case 0x28:
{ {
int dest = opcode & 7; int dest = opcode & 7;
u32 value = reg[(opcode >> 3)&7].B.B0; u32 value = reg[(opcode >> 3)&7].B.B0;
if(value) { if(value) {
value = value & 0x1f; value = value & 0x1f;
if(value == 0) { if(value == 0) {
@ -1222,7 +1222,7 @@ case 0x28:
switch((opcode >> 6) & 3) { switch((opcode >> 6) & 3) {
case 0x00: case 0x00:
{ {
// ORR Rd, Rs // ORR Rd, Rs
int dest = opcode & 7; int dest = opcode & 7;
reg[dest].I |= reg[(opcode >> 3) & 7].I; reg[dest].I |= reg[(opcode >> 3) & 7].I;
Z_FLAG = reg[dest].I ? false : true; Z_FLAG = reg[dest].I ? false : true;
@ -1293,7 +1293,7 @@ case 0x28:
THUMB_PREFETCH; THUMB_PREFETCH;
clockTicks = codeTicksAccessSeq16(armNextPC)+1; clockTicks = codeTicksAccessSeq16(armNextPC)+1;
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1; clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
} }
break; break;
case 3: case 3:
// ADD Hd, Hs // ADD Hd, Hs
@ -1304,7 +1304,7 @@ case 0x28:
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
clockTicks = codeTicksAccessSeq16(armNextPC)+1; clockTicks = codeTicksAccessSeq16(armNextPC)+1;
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1; clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
} }
break; break;
} }
@ -1368,7 +1368,7 @@ case 0x28:
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
clockTicks = codeTicksAccessSeq16(armNextPC)+1; clockTicks = codeTicksAccessSeq16(armNextPC)+1;
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1; clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
} }
break; break;
case 3: case 3:
@ -1385,8 +1385,8 @@ case 0x28:
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
clockTicks = codeTicksAccessSeq16(armNextPC)+1; clockTicks = codeTicksAccessSeq16(armNextPC)+1;
clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1; clockTicks += clockTicks+codeTicksAccess16(armNextPC)+1;
} }
break; break;
} }
} }
@ -1436,7 +1436,7 @@ case 0x28:
codeTicksAccess16(armNextPC) + 3; codeTicksAccess16(armNextPC) + 3;
} else { } else {
armState = true; armState = true;
reg[15].I &= 0xFFFFFFFC; reg[15].I &= 0xFFFFFFFC;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 4; reg[15].I += 4;
ARM_PREFETCH; ARM_PREFETCH;
@ -1654,7 +1654,7 @@ case 0x28:
reg[opcode&7].W.W0); reg[opcode&7].W.W0);
clockTicks = dataTicksAccess16(address) + codeTicksAccess16(armNextPC) + 2; clockTicks = dataTicksAccess16(address) + codeTicksAccess16(armNextPC) + 2;
} }
break; break;
case 0x88: case 0x88:
case 0x89: case 0x89:
case 0x8a: case 0x8a:
@ -1690,7 +1690,7 @@ case 0x28:
CPUWriteMemory(address, reg[regist].I); CPUWriteMemory(address, reg[regist].I);
clockTicks = dataTicksAccess32(address) + codeTicksAccess16(armNextPC) + 2; clockTicks = dataTicksAccess32(address) + codeTicksAccess16(armNextPC) + 2;
} }
break; break;
case 0x98: case 0x98:
case 0x99: case 0x99:
case 0x9a: case 0x9a:
@ -1704,7 +1704,7 @@ case 0x28:
u8 regist = (opcode >> 8) & 7; u8 regist = (opcode >> 8) & 7;
if (!busPrefetchCount) if (!busPrefetchCount)
busPrefetch = busPrefetchEnable; busPrefetch = busPrefetchEnable;
u32 address = reg[13].I + ((opcode&255)<<2); u32 address = reg[13].I + ((opcode&255)<<2);
reg[regist].I = CPUReadMemoryQuick(address); reg[regist].I = CPUReadMemoryQuick(address);
clockTicks = 3 + dataTicksAccess32(address) + clockTicks = 3 + dataTicksAccess32(address) +
codeTicksAccess16(armNextPC); codeTicksAccess16(armNextPC);
@ -1723,7 +1723,7 @@ case 0x28:
u8 regist = (opcode >> 8) & 7; u8 regist = (opcode >> 8) & 7;
reg[regist].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2); reg[regist].I = (reg[15].I & 0xFFFFFFFC) + ((opcode&255)<<2);
} }
break; break;
case 0xa8: case 0xa8:
case 0xa9: case 0xa9:
case 0xaa: case 0xaa:
@ -1737,7 +1737,7 @@ case 0x28:
u8 regist = (opcode >> 8) & 7; u8 regist = (opcode >> 8) & 7;
reg[regist].I = reg[13].I + ((opcode&255)<<2); reg[regist].I = reg[13].I + ((opcode&255)<<2);
} }
break; break;
case 0xb0: case 0xb0:
{ {
// ADD SP, Imm // ADD SP, Imm
@ -1828,7 +1828,7 @@ case 0x28:
reg[13].I = temp; reg[13].I = temp;
clockTicks += codeTicksAccess16(armNextPC)+2; clockTicks += codeTicksAccess16(armNextPC)+2;
} }
break; break;
case 0xbd: case 0xbd:
// POP {Rlist, PC} // POP {Rlist, PC}
{ {
@ -1858,7 +1858,7 @@ case 0x28:
busPrefetchCount=0; busPrefetchCount=0;
clockTicks += codeTicksAccess16(armNextPC) + codeTicksAccess16(armNextPC) + 3; clockTicks += codeTicksAccess16(armNextPC) + codeTicksAccess16(armNextPC) + 3;
} }
break; break;
#define THUMB_STM_REG(val,r,b) \ #define THUMB_STM_REG(val,r,b) \
if(opcode & (val)) {\ if(opcode & (val)) {\
CPUWriteMemory(address, reg[(r)].I);\ CPUWriteMemory(address, reg[(r)].I);\
@ -1897,7 +1897,7 @@ case 0x28:
THUMB_STM_REG(128, 7, regist); THUMB_STM_REG(128, 7, regist);
clockTicks = codeTicksAccess16(armNextPC)+1; clockTicks = codeTicksAccess16(armNextPC)+1;
} }
break; break;
#define THUMB_LDM_REG(val,r) \ #define THUMB_LDM_REG(val,r) \
if(opcode & (val)) {\ if(opcode & (val)) {\
reg[(r)].I = CPUReadMemory(address);\ reg[(r)].I = CPUReadMemory(address);\
@ -1953,14 +1953,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xd1: case 0xd1:
// BNE offset // BNE offset
if(!Z_FLAG) { if(!Z_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -1968,14 +1968,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xd2: case 0xd2:
// BCS offset // BCS offset
if(C_FLAG) { if(C_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -1983,14 +1983,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xd3: case 0xd3:
// BCC offset // BCC offset
if(!C_FLAG) { if(!C_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -1998,14 +1998,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xd4: case 0xd4:
// BMI offset // BMI offset
if(N_FLAG) { if(N_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -2013,14 +2013,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xd5: case 0xd5:
// BPL offset // BPL offset
if(!N_FLAG) { if(!N_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -2028,14 +2028,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xd6: case 0xd6:
// BVS offset // BVS offset
if(V_FLAG) { if(V_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -2043,14 +2043,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xd7: case 0xd7:
// BVC offset // BVC offset
if(!V_FLAG) { if(!V_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -2058,14 +2058,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xd8: case 0xd8:
// BHI offset // BHI offset
if(C_FLAG && !Z_FLAG) { if(C_FLAG && !Z_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -2073,14 +2073,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xd9: case 0xd9:
// BLS offset // BLS offset
if(!C_FLAG || Z_FLAG) { if(!C_FLAG || Z_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -2088,14 +2088,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xda: case 0xda:
// BGE offset // BGE offset
if(N_FLAG == V_FLAG) { if(N_FLAG == V_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -2103,14 +2103,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xdb: case 0xdb:
// BLT offset // BLT offset
if(N_FLAG != V_FLAG) { if(N_FLAG != V_FLAG) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -2118,14 +2118,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xdc: case 0xdc:
// BGT offset // BGT offset
if(!Z_FLAG && (N_FLAG == V_FLAG)) { if(!Z_FLAG && (N_FLAG == V_FLAG)) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -2133,14 +2133,14 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xdd: case 0xdd:
// BLE offset // BLE offset
if(Z_FLAG || (N_FLAG != V_FLAG)) { if(Z_FLAG || (N_FLAG != V_FLAG)) {
#ifdef BKPT_SUPPORT #ifdef BKPT_SUPPORT
UPDATE_OLD_REG UPDATE_OLD_REG
#endif #endif
reg[15].I += ((s8)(opcode & 0xFF)) << 1; reg[15].I += ((s8)(opcode & 0xFF)) << 1;
armNextPC = reg[15].I; armNextPC = reg[15].I;
reg[15].I += 2; reg[15].I += 2;
THUMB_PREFETCH; THUMB_PREFETCH;
@ -2148,7 +2148,7 @@ case 0x28:
codeTicksAccess16(armNextPC)+3; codeTicksAccess16(armNextPC)+3;
busPrefetchCount=0; busPrefetchCount=0;
} }
break; break;
case 0xdf: case 0xdf:
{ {
// SWI #comment // SWI #comment
@ -2191,7 +2191,7 @@ case 0x28:
reg[14].I = reg[15].I + (offset << 12); reg[14].I = reg[15].I + (offset << 12);
clockTicks = codeTicksAccessSeq16(armNextPC) + 1; clockTicks = codeTicksAccessSeq16(armNextPC) + 1;
} }
break; break;
case 0xf4: case 0xf4:
case 0xf5: case 0xf5:
case 0xf6: case 0xf6:
@ -2202,7 +2202,7 @@ case 0x28:
reg[14].I = reg[15].I + ((offset << 12) | 0xFF800000); reg[14].I = reg[15].I + ((offset << 12) | 0xFF800000);
clockTicks = codeTicksAccessSeq16(armNextPC) + 1; clockTicks = codeTicksAccessSeq16(armNextPC) + 1;
} }
break; break;
case 0xf8: case 0xf8:
case 0xf9: case 0xf9:
case 0xfa: case 0xfa:
@ -2230,7 +2230,7 @@ case 0x28:
// BKPT #comment // BKPT #comment
extern void (*dbgSignal)(int,int); extern void (*dbgSignal)(int,int);
reg[15].I -= 2; reg[15].I -= 2;
armNextPC -= 2; armNextPC -= 2;
dbgSignal(5, opcode & 255); dbgSignal(5, opcode & 255);
return; return;
#endif #endif

View File

@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // 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, Version 0.15 beta, Mar 19th, 1998,
Read unzip.h for more info Read unzip.h for more info
@ -162,7 +162,7 @@ local int unzlocal_getByte(FILE *fin,int *pi)
} }
else else
{ {
if (ferror(fin)) if (ferror(fin))
return UNZ_ERRNO; return UNZ_ERRNO;
else else
return UNZ_EOF; 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) 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); err = unzlocal_getByte(fin,&i);
x = (uLong)i; x = (uLong)i;
if (err==UNZ_OK) if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i); err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<8; x += ((uLong)i)<<8;
if (err==UNZ_OK) if (err==UNZ_OK)
*pX = x; *pX = x;
else else
@ -201,7 +201,7 @@ local int unzlocal_getLong (FILE *fin,uLong *pX)
err = unzlocal_getByte(fin,&i); err = unzlocal_getByte(fin,&i);
x = (uLong)i; x = (uLong)i;
if (err==UNZ_OK) if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i); err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<8; x += ((uLong)i)<<8;
@ -213,7 +213,7 @@ local int unzlocal_getLong (FILE *fin,uLong *pX)
if (err==UNZ_OK) if (err==UNZ_OK)
err = unzlocal_getByte(fin,&i); err = unzlocal_getByte(fin,&i);
x += ((uLong)i)<<24; x += ((uLong)i)<<24;
if (err==UNZ_OK) if (err==UNZ_OK)
*pX = x; *pX = x;
else else
@ -256,7 +256,7 @@ local int strcmpcasenosensitive_internal (const char *fileName1,
#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
#endif #endif
/* /*
Compare two filename (fileName1,fileName2). Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi 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 strcmp(fileName1,fileName2);
return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
} }
#define BUFREADCOMMENT (0x400) #define BUFREADCOMMENT (0x400)
@ -291,13 +291,13 @@ local uLong unzlocal_SearchCentralDir(FILE *fin)
uLong uBackRead; uLong uBackRead;
uLong uMaxBack=0xffff; /* maximum size of global comment */ uLong uMaxBack=0xffff; /* maximum size of global comment */
uLong uPosFound=0; uLong uPosFound=0;
if (fseek(fin,0,SEEK_END) != 0) if (fseek(fin,0,SEEK_END) != 0)
return 0; return 0;
uSizeFile = ftell( fin ); uSizeFile = ftell( fin );
if (uMaxBack>uSizeFile) if (uMaxBack>uSizeFile)
uMaxBack = uSizeFile; uMaxBack = uSizeFile;
@ -310,13 +310,13 @@ local uLong unzlocal_SearchCentralDir(FILE *fin)
{ {
uLong uReadSize,uReadPos ; uLong uReadSize,uReadPos ;
int i; int i;
if (uBackRead+BUFREADCOMMENT>uMaxBack) if (uBackRead+BUFREADCOMMENT>uMaxBack)
uBackRead = uMaxBack; uBackRead = uMaxBack;
else else
uBackRead+=BUFREADCOMMENT; uBackRead+=BUFREADCOMMENT;
uReadPos = uSizeFile-uBackRead ; uReadPos = uSizeFile-uBackRead ;
uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
(BUFREADCOMMENT+4) : (uSizeFile-uReadPos); (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
if (fseek(fin,uReadPos,SEEK_SET)!=0) if (fseek(fin,uReadPos,SEEK_SET)!=0)
break; break;
@ -325,7 +325,7 @@ local uLong unzlocal_SearchCentralDir(FILE *fin)
break; break;
for (i=(int)uReadSize-3; (i--)>0;) 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)) ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
{ {
uPosFound = uReadPos+i; uPosFound = uReadPos+i;
@ -355,12 +355,12 @@ extern unzFile ZEXPORT unzOpen (const char *path)
uLong central_pos,uL; uLong central_pos,uL;
FILE * fin ; 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*/ spaning ZIP, unsupported, always 0*/
uLong number_disk_with_CD; /* number the the disk with central dir, used uLong number_disk_with_CD; /* number the the disk with central dir, used
for spaning ZIP, unsupported, always 0*/ for spaning ZIP, unsupported, always 0*/
uLong number_entry_CD; /* total number of entries in uLong number_entry_CD; /* total number of entries in
the central dir the central dir
(same than number_entry on nospan) */ (same than number_entry on nospan) */
int err=UNZ_OK; 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) if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)
err=UNZ_ERRNO; 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 */ starting disk number */
if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)
err=UNZ_ERRNO; err=UNZ_ERRNO;
@ -417,7 +417,7 @@ extern unzFile ZEXPORT unzOpen (const char *path)
if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)
err=UNZ_ERRNO; 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_OK))
err=UNZ_BADZIPFILE; err=UNZ_BADZIPFILE;
@ -432,12 +432,12 @@ extern unzFile ZEXPORT unzOpen (const char *path)
(us.offset_central_dir+us.size_central_dir); (us.offset_central_dir+us.size_central_dir);
us.central_pos = central_pos; us.central_pos = central_pos;
us.pfile_in_zip_read = NULL; us.pfile_in_zip_read = NULL;
s=(unz_s*)ALLOC(sizeof(unz_s)); s=(unz_s*)ALLOC(sizeof(unz_s));
*s=us; *s=us;
unzGoToFirstFile((unzFile)s); unzGoToFirstFile((unzFile)s);
return (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, local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
unz_file_info *pfile_info, unz_file_info *pfile_info,
unz_file_info_internal unz_file_info_internal
*pfile_info_internal, *pfile_info_internal,
char *szFileName, char *szFileName,
uLong fileNameBufferSize, uLong fileNameBufferSize,
@ -604,7 +604,7 @@ local int unzlocal_GetCurrentFileInfoInternal (unzFile file,
lSeek -= uSizeRead; lSeek -= uSizeRead;
} }
if ((err==UNZ_OK) && (extraField!=NULL)) if ((err==UNZ_OK) && (extraField!=NULL))
{ {
uLong uSizeRead ; uLong uSizeRead ;
@ -624,9 +624,9 @@ local int unzlocal_GetCurrentFileInfoInternal (unzFile file,
lSeek += file_info.size_file_extra - uSizeRead; lSeek += file_info.size_file_extra - uSizeRead;
} }
else else
lSeek+=file_info.size_file_extra; lSeek+=file_info.size_file_extra;
if ((err==UNZ_OK) && (szComment!=NULL)) if ((err==UNZ_OK) && (szComment!=NULL))
{ {
uLong uSizeRead ; uLong uSizeRead ;
@ -710,7 +710,7 @@ extern int ZEXPORT unzGoToFirstFile (unzFile file)
*/ */
extern int ZEXPORT unzGoToNextFile (unzFile file) extern int ZEXPORT unzGoToNextFile (unzFile file)
{ {
unz_s* s; unz_s* s;
int err; int err;
if (file==NULL) if (file==NULL)
@ -744,10 +744,10 @@ extern int ZEXPORT unzLocateFile (unzFile file,
const char *szFileName, const char *szFileName,
int iCaseSensitivity) int iCaseSensitivity)
{ {
unz_s* s; unz_s* s;
int err; int err;
uLong num_fileSaved; uLong num_fileSaved;
uLong pos_in_central_dirSaved; 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 */ if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */
err=UNZ_ERRNO; 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)) ((uFlags & 8)==0))
err=UNZ_BADZIPFILE; err=UNZ_BADZIPFILE;
@ -874,7 +874,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s,
return err; return err;
} }
/* /*
Open for reading data the current file in the zipfile. 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. 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; pfile_in_zip_read_info->stream_initialised=0;
if ((s->cur_file_info.compression_method!=0) && if ((s->cur_file_info.compression_method!=0) &&
(s->cur_file_info.compression_method!=Z_DEFLATED)) (s->cur_file_info.compression_method!=Z_DEFLATED))
err=UNZ_BADZIPFILE; 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.zalloc = (alloc_func)0;
pfile_in_zip_read_info->stream.zfree = (free_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); err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
if (err == Z_OK) if (err == Z_OK)
pfile_in_zip_read_info->stream_initialised=1; pfile_in_zip_read_info->stream_initialised=1;
/* windowBits is passed < 0 to tell that there is no zlib header. /* windowBits is passed < 0 to tell that there is no zlib header.
* Note that in this case inflate *requires* an extra "dummy" byte * Note that in this case inflate *requires* an extra "dummy" byte
* after the compressed stream in order to complete decompression and * after the compressed stream in order to complete decompression and
* return Z_STREAM_END. * return Z_STREAM_END.
* In unzip, i don't wait absolutely Z_STREAM_END because I known the * In unzip, i don't wait absolutely Z_STREAM_END because I known the
* size of both compressed and uncompressed data * 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 ; 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 ; s->cur_file_info.uncompressed_size ;
pfile_in_zip_read_info->pos_in_zipfile = pfile_in_zip_read_info->pos_in_zipfile =
s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
iSizeVar; iSizeVar;
pfile_in_zip_read_info->stream.avail_in = (uInt)0; 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.next_out = (Bytef*)buf;
pfile_in_zip_read_info->stream.avail_out = (uInt)len; pfile_in_zip_read_info->stream.avail_out = (uInt)len;
if (len>pfile_in_zip_read_info->rest_read_uncompressed) 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; (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
while (pfile_in_zip_read_info->stream.avail_out>0) 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) if (uReadThis == 0)
return UNZ_EOF; return UNZ_EOF;
if (fseek(pfile_in_zip_read_info->file, 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) pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)
return UNZ_ERRNO; return UNZ_ERRNO;
if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, 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->pos_in_zipfile += uReadThis;
pfile_in_zip_read_info->rest_read_compressed-=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; (Bytef*)pfile_in_zip_read_info->read_buffer;
pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; 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) if (pfile_in_zip_read_info->compression_method==0)
{ {
uInt uDoCopy,i ; 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) pfile_in_zip_read_info->stream.avail_in)
uDoCopy = pfile_in_zip_read_info->stream.avail_out ; uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
else else
uDoCopy = pfile_in_zip_read_info->stream.avail_in ; uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
for (i=0;i<uDoCopy;i++) for (i=0;i<uDoCopy;i++)
*(pfile_in_zip_read_info->stream.next_out+i) = *(pfile_in_zip_read_info->stream.next_out+i) =
*(pfile_in_zip_read_info->stream.next_in+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->crc32 = crc32(pfile_in_zip_read_info->crc32,
pfile_in_zip_read_info->stream.next_out, pfile_in_zip_read_info->stream.next_out,
uDoCopy); uDoCopy);
@ -1077,8 +1077,8 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
uOutThis = uTotalOutAfter-uTotalOutBefore; uOutThis = uTotalOutAfter-uTotalOutBefore;
pfile_in_zip_read_info->crc32 = pfile_in_zip_read_info->crc32 =
crc32(pfile_in_zip_read_info->crc32,bufBefore, crc32(pfile_in_zip_read_info->crc32,bufBefore,
(uInt)(uOutThis)); (uInt)(uOutThis));
@ -1086,10 +1086,10 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
uOutThis; uOutThis;
iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
if (err==Z_STREAM_END) if (err==Z_STREAM_END)
return (iRead==0) ? UNZ_EOF : iRead; return (iRead==0) ? UNZ_EOF : iRead;
if (err!=Z_OK) if (err!=Z_OK)
break; 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) extern int ZEXPORT unzeof (unzFile file)
{ {
@ -1133,7 +1133,7 @@ extern int ZEXPORT unzeof (unzFile file)
if (pfile_in_zip_read_info==NULL) if (pfile_in_zip_read_info==NULL)
return UNZ_PARAMERROR; return UNZ_PARAMERROR;
if (pfile_in_zip_read_info->rest_read_uncompressed == 0) if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
return 1; return 1;
else 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 if buf!=NULL, len is the size of the buffer, the extra header is copied in
buf. 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 the error code
*/ */
extern int ZEXPORT unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len) 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) if (pfile_in_zip_read_info==NULL)
return UNZ_PARAMERROR; 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); pfile_in_zip_read_info->pos_local_extrafield);
if (buf==NULL) if (buf==NULL)
return (int)size_to_read; return (int)size_to_read;
if (len>size_to_read) if (len>size_to_read)
read_now = (uInt)size_to_read; read_now = (uInt)size_to_read;
else else
@ -1182,9 +1182,9 @@ extern int ZEXPORT unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len)
if (read_now==0) if (read_now==0)
return 0; return 0;
if (fseek(pfile_in_zip_read_info->file, 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) pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)
return UNZ_ERRNO; return UNZ_ERRNO;

View File

@ -17,7 +17,7 @@
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // 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, Version 0.15 beta, Mar 19th, 1998,
Copyright (C) 1998 Gilles Vollant 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 ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
PkWare has also a specification at : PkWare has also a specification at :
ftp://ftp.pkware.com/probdesc.zip */ ftp://ftp.pkware.com/probdesc.zip */
@ -71,7 +71,7 @@ extern "C" {
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted /* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */ from (void*) without cast */
typedef struct TagunzFile__ { int unused; } unzFile__; typedef struct TagunzFile__ { int unused; } unzFile__;
typedef unzFile__ *unzFile; typedef unzFile__ *unzFile;
#else #else
typedef voidp unzFile; typedef voidp unzFile;
@ -88,7 +88,7 @@ typedef voidp unzFile;
#define UNZ_CRCERROR (-105) #define UNZ_CRCERROR (-105)
/* tm_unz contain date/time info */ /* 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_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [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 compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */ uLong crc; /* crc-32 4 bytes */
uLong compressed_size; /* compressed size 4 bytes */ uLong compressed_size; /* compressed size 4 bytes */
uLong uncompressed_size; /* uncompressed size 4 bytes */ uLong uncompressed_size; /* uncompressed size 4 bytes */
uLong size_filename; /* filename length 2 bytes */ uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */ uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment 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. 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, const char *szFileName,
int iCaseSensitivity)); 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 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, voidp buf,
unsigned len)); unsigned len));
/* /*
@ -268,7 +268,7 @@ extern z_off_t ZEXPORT unztell OF((unzFile file));
extern int ZEXPORT unzeof 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, 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 if buf!=NULL, len is the size of the buffer, the extra header is copied in
buf. 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 the error code
*/ */

View File

@ -27,7 +27,7 @@ AVIWrite::AVIWrite()
m_streamCompressed = NULL; m_streamCompressed = NULL;
m_streamSound = NULL; m_streamSound = NULL;
m_samplesSound = 0; m_samplesSound = 0;
AVIFileInit(); AVIFileInit();
} }
@ -38,7 +38,7 @@ AVIWrite::~AVIWrite()
if(m_streamCompressed) if(m_streamCompressed)
AVIStreamClose(m_streamCompressed); AVIStreamClose(m_streamCompressed);
if(m_stream) if(m_stream)
AVIStreamClose(m_stream); AVIStreamClose(m_stream);
@ -65,13 +65,13 @@ void AVIWrite::SetSoundFormat(WAVEFORMATEX *format)
m_soundHeader.dwInitialFrames = 1; m_soundHeader.dwInitialFrames = 1;
m_soundHeader.dwRate = format->nAvgBytesPerSec; m_soundHeader.dwRate = format->nAvgBytesPerSec;
m_soundHeader.dwSampleSize = format->nBlockAlign; m_soundHeader.dwSampleSize = format->nBlockAlign;
// create the sound stream // create the sound stream
if(FAILED(AVIFileCreateStream(m_file, &m_streamSound, &m_soundHeader))) { if(FAILED(AVIFileCreateStream(m_file, &m_streamSound, &m_soundHeader))) {
m_failed = true; m_failed = true;
return; return;
} }
// setup the sound stream format // setup the sound stream format
if(FAILED(AVIStreamSetFormat(m_streamSound, 0 , (void *)&m_soundFormat, if(FAILED(AVIStreamSetFormat(m_streamSound, 0 , (void *)&m_soundFormat,
sizeof(WAVEFORMATEX)))) { sizeof(WAVEFORMATEX)))) {
@ -104,7 +104,7 @@ bool AVIWrite::Open(const char *filename)
m_failed = true; m_failed = true;
return false; return false;
} }
ZeroMemory(&m_options, sizeof(AVICOMPRESSOPTIONS)); ZeroMemory(&m_options, sizeof(AVICOMPRESSOPTIONS));
m_arrayOptions[0] = &m_options; m_arrayOptions[0] = &m_options;
@ -113,13 +113,13 @@ bool AVIWrite::Open(const char *filename)
m_failed = true; m_failed = true;
return false; return false;
} }
// create the compressed stream // create the compressed stream
if(FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL))) { if(FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL))) {
m_failed = true; m_failed = true;
return false; return false;
} }
// setup the video stream format // setup the video stream format
if(FAILED( AVIStreamSetFormat(m_streamCompressed, 0, if(FAILED( AVIStreamSetFormat(m_streamCompressed, 0,
&m_bitmap, &m_bitmap,
@ -160,7 +160,7 @@ bool AVIWrite::AddFrame(const int frame, const char *bmp)
{ {
if (m_failed) if (m_failed)
return false; return false;
// write the frame to the video stream // write the frame to the video stream
if(FAILED(AVIStreamWrite(m_streamCompressed, if(FAILED(AVIStreamWrite(m_streamCompressed,
frame, frame,

View File

@ -60,10 +60,10 @@ BEGIN_MESSAGE_MAP(AboutDialog, CDialog)
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// AboutDialog message handlers // AboutDialog message handlers
BOOL AboutDialog::OnInitDialog() BOOL AboutDialog::OnInitDialog()
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
CWnd *p = GetDlgItem(IDC_TRANSLATOR_URL); CWnd *p = GetDlgItem(IDC_TRANSLATOR_URL);
if(p) { if(p) {
m_translator.SubclassDlgItem(IDC_TRANSLATOR_URL, this); m_translator.SubclassDlgItem(IDC_TRANSLATOR_URL, this);

View File

@ -70,10 +70,10 @@ BEGIN_MESSAGE_MAP(AccelEditor, CDialog)
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// AccelEditor message handlers // AccelEditor message handlers
BOOL AccelEditor::OnInitDialog() BOOL AccelEditor::OnInitDialog()
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
DIALOG_SIZER_START( sz ) DIALOG_SIZER_START( sz )
DIALOG_SIZER_ENTRY( IDC_STATIC1, DS_MoveX) DIALOG_SIZER_ENTRY( IDC_STATIC1, DS_MoveX)
DIALOG_SIZER_ENTRY( IDC_STATIC2, DS_MoveY) DIALOG_SIZER_ENTRY( IDC_STATIC2, DS_MoveY)
@ -97,7 +97,7 @@ BOOL AccelEditor::OnInitDialog()
NULL); NULL);
InitCommands(); InitCommands();
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE // EXCEPTION: OCX Property Pages should return FALSE
} }
@ -108,7 +108,7 @@ void AccelEditor::InitCommands()
m_alreadyAffected.SetWindowText(""); m_alreadyAffected.SetWindowText("");
POSITION pos = mgr.m_mapAccelString.GetStartPosition(); POSITION pos = mgr.m_mapAccelString.GetStartPosition();
while(pos != NULL) { while(pos != NULL) {
CString command; CString command;
WORD wID; WORD wID;
@ -123,17 +123,17 @@ void AccelEditor::InitCommands()
OnSelchangeCommands(); OnSelchangeCommands();
} }
void AccelEditor::OnCancel() void AccelEditor::OnCancel()
{ {
EndDialog(FALSE); EndDialog(FALSE);
} }
void AccelEditor::OnOk() void AccelEditor::OnOk()
{ {
EndDialog(TRUE); EndDialog(TRUE);
} }
void AccelEditor::OnSelchangeCommands() void AccelEditor::OnSelchangeCommands()
{ {
// Check if some commands exist. // Check if some commands exist.
int index = m_commands.GetCurSel(); int index = m_commands.GetCurSel();
@ -144,7 +144,7 @@ void AccelEditor::OnSelchangeCommands()
m_currents.ResetContent(); m_currents.ResetContent();
CCmdAccelOb* pCmdAccel; CCmdAccelOb* pCmdAccel;
if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel)) { if (mgr.m_mapAccelTable.Lookup(wIDCommand, pCmdAccel)) {
CAccelsOb* pAccel; CAccelsOb* pAccel;
CString szBuffer; CString szBuffer;
@ -164,20 +164,20 @@ void AccelEditor::OnSelchangeCommands()
} }
void AccelEditor::OnReset() void AccelEditor::OnReset()
{ {
mgr.Default(); mgr.Default();
InitCommands(); // update the listboxes. InitCommands(); // update the listboxes.
} }
void AccelEditor::OnAssign() void AccelEditor::OnAssign()
{ {
// Control if it's not already affected // Control if it's not already affected
CCmdAccelOb* pCmdAccel; CCmdAccelOb* pCmdAccel;
CAccelsOb* pAccel; CAccelsOb* pAccel;
WORD wIDCommand; WORD wIDCommand;
POSITION pos; POSITION pos;
WORD wKey; WORD wKey;
bool bCtrl, bAlt, bShift; bool bCtrl, bAlt, bShift;
@ -241,13 +241,13 @@ void AccelEditor::OnAssign()
m_key.ResetKey(); m_key.ResetKey();
} }
void AccelEditor::OnRemove() void AccelEditor::OnRemove()
{ {
// Some controls // Some controls
int indexCurrent = m_currents.GetCurSel(); int indexCurrent = m_currents.GetCurSel();
if (indexCurrent == LB_ERR) if (indexCurrent == LB_ERR)
return; return;
// 2nd part. // 2nd part.
int indexCmd = m_commands.GetCurSel(); int indexCmd = m_commands.GetCurSel();
if (indexCmd == LB_ERR) if (indexCmd == LB_ERR)

View File

@ -246,7 +246,7 @@ bool CAcceleratorManager::UpdateWndTable()
arrayACCEL.Add(pACCEL); arrayACCEL.Add(pACCEL);
} }
} }
INT_PTR nAccel = arrayACCEL.GetSize(); INT_PTR nAccel = arrayACCEL.GetSize();
LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, nAccel * sizeof(ACCEL)); LPACCEL lpAccel = (LPACCEL)LocalAlloc(LPTR, nAccel * sizeof(ACCEL));
if (!lpAccel) { if (!lpAccel) {
@ -258,7 +258,7 @@ bool CAcceleratorManager::UpdateWndTable()
} }
for (iLoop = 0; iLoop < nAccel; iLoop++) { for (iLoop = 0; iLoop < nAccel; iLoop++) {
pACCEL = arrayACCEL.GetAt(iLoop); pACCEL = arrayACCEL.GetAt(iLoop);
lpAccel[iLoop].fVirt = pACCEL->fVirt; lpAccel[iLoop].fVirt = pACCEL->fVirt;
lpAccel[iLoop].key = pACCEL->key; lpAccel[iLoop].key = pACCEL->key;
@ -419,7 +419,7 @@ bool CAcceleratorManager::CreateEntry(WORD wIDCommand, LPCTSTR szCommand)
bool CAcceleratorManager::GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel) bool CAcceleratorManager::GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel)
{ {
ASSERT(pACCEL != NULL); ASSERT(pACCEL != NULL);
CAccelsOb accel(pACCEL); CAccelsOb accel(pACCEL);
accel.GetString(szAccel); accel.GetString(szAccel);
@ -493,7 +493,7 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
OSVERSIONINFO info; OSVERSIONINFO info;
info.dwOSVersionInfoSize = sizeof(info); info.dwOSVersionInfoSize = sizeof(info);
GetVersionEx(&info); GetVersionEx(&info);
if(info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { if(info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
MENUITEMINFO info; MENUITEMINFO info;
char ss[128]; char ss[128];
@ -502,7 +502,7 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
info.fMask = MIIM_ID | MIIM_SUBMENU; info.fMask = MIIM_ID | MIIM_SUBMENU;
for(int i = 0; i < count; i++) { for(int i = 0; i < count; i++) {
GetMenuItemInfo(menu, i, TRUE, &info); GetMenuItemInfo(menu, i, TRUE, &info);
if(info.hSubMenu != NULL) { if(info.hSubMenu != NULL) {
UpdateMenu(info.hSubMenu); UpdateMenu(info.hSubMenu);
} else { } else {
@ -518,15 +518,15 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
int index = str.Find('\t'); int index = str.Find('\t');
if(index != -1) if(index != -1)
str = str.Left(index); str = str.Left(index);
WORD command = info.wID; WORD command = info.wID;
CCmdAccelOb *o; CCmdAccelOb *o;
if(m_mapAccelTable.Lookup(command, o)) { if(m_mapAccelTable.Lookup(command, o)) {
if(o->m_Accels.GetCount()) { if(o->m_Accels.GetCount()) {
POSITION pos = o->m_Accels.GetHeadPosition(); POSITION pos = o->m_Accels.GetHeadPosition();
CAccelsOb *accel = o->m_Accels.GetNext(pos); CAccelsOb *accel = o->m_Accels.GetNext(pos);
CString s; CString s;
accel->GetString(s); accel->GetString(s);
str += "\t"; str += "\t";
@ -542,13 +542,13 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
MENUITEMINFO info; MENUITEMINFO info;
wchar_t ss[128]; wchar_t ss[128];
wchar_t str[512]; wchar_t str[512];
ZeroMemory(&info, sizeof(info)); ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info); info.cbSize = sizeof(info);
info.fMask = MIIM_ID | MIIM_SUBMENU; info.fMask = MIIM_ID | MIIM_SUBMENU;
for(int i = 0; i < count; i++) { for(int i = 0; i < count; i++) {
GetMenuItemInfo(menu, i, TRUE, &info); GetMenuItemInfo(menu, i, TRUE, &info);
if(info.hSubMenu != NULL) { if(info.hSubMenu != NULL) {
UpdateMenu(info.hSubMenu); UpdateMenu(info.hSubMenu);
} else { } else {
@ -562,19 +562,19 @@ void CAcceleratorManager::UpdateMenu(HMENU menu)
GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info2); GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info2);
wcscpy(str, ss); wcscpy(str, ss);
wchar_t *p = wcschr(str, '\t'); wchar_t *p = wcschr(str, '\t');
if(p) if(p)
*p = 0; *p = 0;
CCmdAccelOb *o; CCmdAccelOb *o;
WORD command = info.wID; WORD command = info.wID;
if(m_mapAccelTable.Lookup(command, o)) { if(m_mapAccelTable.Lookup(command, o)) {
if(o->m_Accels.GetCount()) { if(o->m_Accels.GetCount()) {
POSITION pos = o->m_Accels.GetHeadPosition(); POSITION pos = o->m_Accels.GetHeadPosition();
CAccelsOb *accel = o->m_Accels.GetNext(pos); CAccelsOb *accel = o->m_Accels.GetNext(pos);
CString s; CString s;
accel->GetString(s); accel->GetString(s);
@ -618,7 +618,7 @@ bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey)
CCmdAccelOb* pCmdAccel; CCmdAccelOb* pCmdAccel;
CAccelsOb* pAccel; CAccelsOb* pAccel;
DWORD dwIDAccelData, dwAccelData; DWORD dwIDAccelData, dwAccelData;
BOOL bExistID; BOOL bExistID;
int iIndex = 0; int iIndex = 0;
if(count) { if(count) {
WORD wKey; WORD wKey;
@ -628,10 +628,10 @@ bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey)
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
pCmdAccel->DeleteUserAccels(); pCmdAccel->DeleteUserAccels();
} }
while(iIndex < count) { while(iIndex < count) {
dwIDAccelData = data[iIndex++]; dwIDAccelData = data[iIndex++];
WORD wIDCommand = LOWORD(dwIDAccelData); WORD wIDCommand = LOWORD(dwIDAccelData);
bExistID = m_mapAccelTable.Lookup(wIDCommand, pCmdAccel); bExistID = m_mapAccelTable.Lookup(wIDCommand, pCmdAccel);
@ -679,12 +679,12 @@ bool CAcceleratorManager::Write()
{ {
CDWordArray AccelsDatasArray; CDWordArray AccelsDatasArray;
CDWordArray CmdDatasArray; CDWordArray CmdDatasArray;
int iCount = 0; int iCount = 0;
CCmdAccelOb* pCmdAccel; CCmdAccelOb* pCmdAccel;
CAccelsOb* pAccel; CAccelsOb* pAccel;
DWORD dwAccelData; DWORD dwAccelData;
WORD wKey; WORD wKey;
POSITION pos = m_mapAccelTable.GetStartPosition(); POSITION pos = m_mapAccelTable.GetStartPosition();
while (pos != NULL) { while (pos != NULL) {
@ -702,13 +702,13 @@ bool CAcceleratorManager::Write()
if (CmdDatasArray.GetSize() > 0) { if (CmdDatasArray.GetSize() > 0) {
CmdDatasArray.InsertAt(0, MAKELONG(pCmdAccel->m_wIDCommand, CmdDatasArray.GetSize())); CmdDatasArray.InsertAt(0, MAKELONG(pCmdAccel->m_wIDCommand, CmdDatasArray.GetSize()));
AccelsDatasArray.Append(CmdDatasArray); AccelsDatasArray.Append(CmdDatasArray);
iCount++; iCount++;
} }
} }
// AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount)); // AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount));
INT_PTR count = AccelsDatasArray.GetSize(); INT_PTR count = AccelsDatasArray.GetSize();
DWORD *data = (DWORD *)malloc(count * sizeof(DWORD)); DWORD *data = (DWORD *)malloc(count * sizeof(DWORD));
ASSERT(data != NULL); ASSERT(data != NULL);
@ -736,7 +736,7 @@ bool CAcceleratorManager::CreateDefaultTable()
{ {
if (m_bDefaultTable) if (m_bDefaultTable)
return false; return false;
CCmdAccelOb* pCmdAccel; CCmdAccelOb* pCmdAccel;
CCmdAccelOb* pNewCmdAccel; CCmdAccelOb* pNewCmdAccel;
@ -749,14 +749,14 @@ bool CAcceleratorManager::CreateDefaultTable()
m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
pNewCmdAccel = new CCmdAccelOb; pNewCmdAccel = new CCmdAccelOb;
ASSERT(pNewCmdAccel != NULL); ASSERT(pNewCmdAccel != NULL);
POSITION pos = pCmdAccel->m_Accels.GetHeadPosition(); POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
while (pos != NULL) { while (pos != NULL) {
pAccel = pCmdAccel->m_Accels.GetNext(pos); pAccel = pCmdAccel->m_Accels.GetNext(pos);
if (!pAccel->m_bLocked) { if (!pAccel->m_bLocked) {
pNewAccel = new CAccelsOb; pNewAccel = new CAccelsOb;
ASSERT(pNewAccel != NULL); ASSERT(pNewAccel != NULL);
*pNewAccel = *pAccel; *pNewAccel = *pAccel;
pNewCmdAccel->m_Accels.AddTail(pNewAccel); pNewCmdAccel->m_Accels.AddTail(pNewAccel);
} }
@ -764,9 +764,9 @@ bool CAcceleratorManager::CreateDefaultTable()
if (pNewCmdAccel->m_Accels.GetCount() != 0) { if (pNewCmdAccel->m_Accels.GetCount() != 0) {
pNewCmdAccel->m_wIDCommand = pCmdAccel->m_wIDCommand; pNewCmdAccel->m_wIDCommand = pCmdAccel->m_wIDCommand;
pNewCmdAccel->m_szCommand = pCmdAccel->m_szCommand; pNewCmdAccel->m_szCommand = pCmdAccel->m_szCommand;
m_mapAccelTableSaved.SetAt(wKey, pNewCmdAccel); m_mapAccelTableSaved.SetAt(wKey, pNewCmdAccel);
} else } else
delete pNewCmdAccel; delete pNewCmdAccel;
} }

View File

@ -68,7 +68,7 @@ class CAcceleratorManager : public CObject {
bool Load(); bool Load();
bool Write(); bool Write();
// Get the initials accels, not the user's // 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 // Save a copy in the 2 maps called xxxSaved, which are used in case
// of Default(), to reload the defaults accels. // of Default(), to reload the defaults accels.
bool CreateDefaultTable(); bool CreateDefaultTable();

View File

@ -74,22 +74,22 @@ BEGIN_MESSAGE_MAP(Associate, CDialog)
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Associate message handlers // Associate message handlers
BOOL Associate::OnInitDialog() BOOL Associate::OnInitDialog()
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
CenterWindow(); CenterWindow();
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE // EXCEPTION: OCX Property Pages should return FALSE
} }
void Associate::OnCancel() void Associate::OnCancel()
{ {
EndDialog(FALSE); EndDialog(FALSE);
} }
void Associate::OnOk() void Associate::OnOk()
{ {
UpdateData(); UpdateData();
@ -117,7 +117,7 @@ void Associate::OnOk()
regAssociateType("VisualBoyAdvance.Binary", regAssociateType("VisualBoyAdvance.Binary",
"Binary", "Binary",
commandPath); commandPath);
for(int i = 0; i < 7; i++) { for(int i = 0; i < 7; i++) {
if(mask & (1<<i)) { if(mask & (1<<i)) {
regCreateFileType(types[i],"VisualBoyAdvance.Binary"); regCreateFileType(types[i],"VisualBoyAdvance.Binary");

View File

@ -95,12 +95,12 @@ void BitmapControl::OnDraw(CDC* dc)
if(stretch) { if(stretch) {
bmpInfo->bmiHeader.biWidth = w; bmpInfo->bmiHeader.biWidth = w;
bmpInfo->bmiHeader.biHeight = -h; bmpInfo->bmiHeader.biHeight = -h;
StretchDIBits(memDC.GetSafeHdc(), StretchDIBits(memDC.GetSafeHdc(),
0, 0,
0, 0,
w1, w1,
h1, h1,
0, 0,
0, 0,
w, w,
@ -111,7 +111,7 @@ void BitmapControl::OnDraw(CDC* dc)
SRCCOPY); SRCCOPY);
} else { } else {
FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE))); FillOutsideRect(&memDC, CBrush::FromHandle(GetSysColorBrush(COLOR_BTNFACE)));
bmpInfo->bmiHeader.biWidth = w; bmpInfo->bmiHeader.biWidth = w;
bmpInfo->bmiHeader.biHeight = -h; bmpInfo->bmiHeader.biHeight = -h;
SetDIBitsToDevice(memDC.GetSafeHdc(), SetDIBitsToDevice(memDC.GetSafeHdc(),
@ -133,7 +133,7 @@ void BitmapControl::OnDraw(CDC* dc)
memDC.SelectObject(pOldBitmap); memDC.SelectObject(pOldBitmap);
bitmap.DeleteObject(); bitmap.DeleteObject();
memDC.DeleteDC(); memDC.DeleteDC();
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -154,18 +154,18 @@ void BitmapControl::Dump(CDumpContext& dc) const
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// BitmapControl message handlers // BitmapControl message handlers
BOOL BitmapControl::OnEraseBkgnd(CDC* pDC) BOOL BitmapControl::OnEraseBkgnd(CDC* pDC)
{ {
return TRUE; return TRUE;
} }
void BitmapControl::OnSize(UINT nType, int cx, int cy) void BitmapControl::OnSize(UINT nType, int cx, int cy)
{ {
if(!stretch) if(!stretch)
CScrollView::OnSize(nType, cx, cy); CScrollView::OnSize(nType, cx, cy);
} }
void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt) void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
{ {
if(!data) if(!data)
return; return;
@ -173,14 +173,14 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
int y = pt.y; int y = pt.y;
WPARAM point; WPARAM point;
if(stretch) { if(stretch) {
RECT rect; RECT rect;
GetClientRect(&rect); GetClientRect(&rect);
int height = rect.bottom - rect.top; int height = rect.bottom - rect.top;
int width = rect.right - rect.left; int width = rect.right - rect.left;
int xx = (x * w) / width; int xx = (x * w) / width;
int yy = (y * h) / height; int yy = (y * h) / height;
@ -207,7 +207,7 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
return; return;
point = p.x | (p.y<<16); point = p.x | (p.y<<16);
int xxx = p.x / 8; int xxx = p.x / 8;
int yyy = p.y / 8; int yyy = p.y / 8;
@ -217,7 +217,7 @@ void BitmapControl::OnLButtonDown(UINT nFlags, CPoint pt)
i * w * 3], 8 * 3); i * w * 3], 8 * 3);
} }
} }
GetParent()->SendMessage(WM_MAPINFO, GetParent()->SendMessage(WM_MAPINFO,
point, point,
(LPARAM)colors); (LPARAM)colors);
@ -282,6 +282,6 @@ bool BitmapControl::getStretch()
return stretch; return stretch;
} }
void BitmapControl::PostNcDestroy() void BitmapControl::PostNcDestroy()
{ {
} }

View File

@ -71,7 +71,7 @@ BEGIN_MESSAGE_MAP(BugReport, CDialog)
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// BugReport message handlers // BugReport message handlers
void BugReport::OnCopy() void BugReport::OnCopy()
{ {
OpenClipboard(); OpenClipboard();
@ -79,38 +79,38 @@ void BugReport::OnCopy()
CString report; CString report;
m_report.GetWindowText(report); m_report.GetWindowText(report);
HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE,
(report.GetLength() + 1) * sizeof(CHAR)); (report.GetLength() + 1) * sizeof(CHAR));
if (hglbCopy == NULL) { if (hglbCopy == NULL) {
CloseClipboard(); CloseClipboard();
return; return;
} }
// Lock the handle and copy the text to the buffer. // Lock the handle and copy the text to the buffer.
LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy); LPSTR lptstrCopy = (LPSTR)GlobalLock(hglbCopy);
memcpy(lptstrCopy, (const char *)report, memcpy(lptstrCopy, (const char *)report,
report.GetLength() * sizeof(CHAR)); report.GetLength() * sizeof(CHAR));
lptstrCopy[report.GetLength()] = (TCHAR) 0; // null character lptstrCopy[report.GetLength()] = (TCHAR) 0; // null character
GlobalUnlock(hglbCopy); GlobalUnlock(hglbCopy);
// Place the handle on the clipboard. // Place the handle on the clipboard.
SetClipboardData(CF_TEXT, hglbCopy); SetClipboardData(CF_TEXT, hglbCopy);
CloseClipboard(); CloseClipboard();
systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard"); systemMessage(IDS_BUG_REPORT, "Bug report has been copied to the Clipboard");
} }
void BugReport::OnOk() void BugReport::OnOk()
{ {
EndDialog(TRUE); EndDialog(TRUE);
} }
BOOL BugReport::OnInitDialog() BOOL BugReport::OnInitDialog()
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
CenterWindow(); CenterWindow();
CString report = createReport(); CString report = createReport();
@ -118,7 +118,7 @@ BOOL BugReport::OnInitDialog()
m_report.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT))); m_report.SetFont(CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FIXED_FONT)));
m_report.SetWindowText(report); m_report.SetWindowText(report);
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE // EXCEPTION: OCX Property Pages should return FALSE
} }
@ -167,7 +167,7 @@ CString BugReport::createReport()
strncpy(buffer, (const char *)&rom[0xa0], 12); strncpy(buffer, (const char *)&rom[0xa0], 12);
buffer[12] = 0; buffer[12] = 0;
AppendFormat(report, "Internal name: %s\r\n", buffer); AppendFormat(report, "Internal name: %s\r\n", buffer);
strncpy(buffer, (const char *)&rom[0xac], 4); strncpy(buffer, (const char *)&rom[0xac], 4);
buffer[4] = 0; buffer[4] = 0;
AppendFormat(report, "Game code : %s\r\n", buffer); AppendFormat(report, "Game code : %s\r\n", buffer);
@ -177,7 +177,7 @@ CString BugReport::createReport()
u32 *end = (u32 *)((char *)rom+theApp.romSize); u32 *end = (u32 *)((char *)rom+theApp.romSize);
while(p < end) { while(p < end) {
u32 d = READ32LE(p); u32 d = READ32LE(p);
if(d == 0x52504545) { if(d == 0x52504545) {
if(memcmp(p, "EEPROM_", 7) == 0) { if(memcmp(p, "EEPROM_", 7) == 0) {
res += (const char *)p; res += (const char *)p;
@ -212,7 +212,7 @@ CString BugReport::createReport()
AppendFormat(report, "Game title : %s\r\n", buffer); AppendFormat(report, "Game title : %s\r\n", buffer);
} }
} }
AppendFormat(report, "Using BIOS : %d\r\n", theApp.useBiosFile); AppendFormat(report, "Using BIOS : %d\r\n", theApp.useBiosFile);
AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile); AppendFormat(report, "Skip BIOS : %d\r\n", theApp.skipBiosFile);
AppendFormat(report, "Disable SFX : %d\r\n", cpuDisableSfx); 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, "Blue shift : %08x\r\n", systemBlueShift);
AppendFormat(report, "Layer setting: %04X\r\n", layerSettings); AppendFormat(report, "Layer setting: %04X\r\n", layerSettings);
AppendFormat(report, "Mirroring : %d\r\n", mirroringEnable); 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); theApp.winSaveType, cpuSaveType);
AppendFormat(report, "Flash size : %08X (%08x)\r\n", AppendFormat(report, "Flash size : %08X (%08x)\r\n",
theApp.winFlashSize, flashSize); theApp.winFlashSize, flashSize);
AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable, AppendFormat(report, "RTC : %d (%d)\r\n", theApp.winRtcEnable,
rtcIsEnabled()); rtcIsEnabled());

View File

@ -22,7 +22,7 @@
// Version : 1.0 * Author : T.Maurel // Version : 1.0 * Author : T.Maurel
// Date : 17.08.98 // Date : 17.08.98
// //
// Remarks : // Remarks :
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -207,7 +207,7 @@ CAccelsOb::CAccelsOb()
CAccelsOb::CAccelsOb(CAccelsOb* pFrom) CAccelsOb::CAccelsOb(CAccelsOb* pFrom)
{ {
ASSERT(pFrom != NULL); ASSERT(pFrom != NULL);
m_cVirt = pFrom->m_cVirt; m_cVirt = pFrom->m_cVirt;
m_wKey = pFrom->m_wKey; m_wKey = pFrom->m_wKey;
m_bLocked = pFrom->m_bLocked; m_bLocked = pFrom->m_bLocked;
@ -231,7 +231,7 @@ CAccelsOb::CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked)
CAccelsOb::CAccelsOb(LPACCEL pACCEL) CAccelsOb::CAccelsOb(LPACCEL pACCEL)
{ {
ASSERT(pACCEL != NULL); ASSERT(pACCEL != NULL);
m_cVirt = pACCEL->fVirt; m_cVirt = pACCEL->fVirt;
m_wKey = pACCEL->key; m_wKey = pACCEL->key;
m_bLocked = false; m_bLocked = false;
@ -246,7 +246,7 @@ CAccelsOb& CAccelsOb::operator=(const CAccelsOb& from)
m_cVirt = from.m_cVirt; m_cVirt = from.m_cVirt;
m_wKey = from.m_wKey; m_wKey = from.m_wKey;
m_bLocked = from.m_bLocked; m_bLocked = from.m_bLocked;
return *this; return *this;
} }
@ -290,18 +290,18 @@ bool CAccelsOb::IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift)
// CString szTemp; // CString szTemp;
// GetString(szTemp); // GetString(szTemp);
bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false; bool m_bCtrl = (m_cVirt & FCONTROL) ? true : false;
bool bRet = (bCtrl == m_bCtrl); bool bRet = (bCtrl == m_bCtrl);
bool m_bAlt = (m_cVirt & FALT) ? true : false; bool m_bAlt = (m_cVirt & FALT) ? true : false;
bRet &= (bAlt == m_bAlt); bRet &= (bAlt == m_bAlt);
bool m_bShift = (m_cVirt & FSHIFT) ? true : false; bool m_bShift = (m_cVirt & FSHIFT) ? true : false;
bRet &= (bShift == m_bShift); bRet &= (bShift == m_bShift);
bRet &= static_cast<bool>(m_wKey == wKey); bRet &= static_cast<bool>(m_wKey == wKey);
return bRet; return bRet;
} }
@ -316,7 +316,7 @@ DWORD CAccelsOb::GetData()
cLocalCodes = DEFAULT_ACCEL; cLocalCodes = DEFAULT_ACCEL;
else else
cLocalCodes = USER_ACCEL; cLocalCodes = USER_ACCEL;
WORD bCodes = MAKEWORD(m_cVirt, cLocalCodes); WORD bCodes = MAKEWORD(m_cVirt, cLocalCodes);
return MAKELONG(m_wKey, bCodes); return MAKELONG(m_wKey, bCodes);
} }
@ -328,10 +328,10 @@ DWORD CAccelsOb::GetData()
bool CAccelsOb::SetData(DWORD dwDatas) bool CAccelsOb::SetData(DWORD dwDatas)
{ {
m_wKey = LOWORD(dwDatas); m_wKey = LOWORD(dwDatas);
WORD bCodes = HIWORD(dwDatas); WORD bCodes = HIWORD(dwDatas);
m_cVirt = LOBYTE(bCodes); m_cVirt = LOBYTE(bCodes);
BYTE cLocalCodes = HIBYTE(bCodes); BYTE cLocalCodes = HIBYTE(bCodes);
m_bLocked = static_cast<bool>(cLocalCodes == DEFAULT_ACCEL); m_bLocked = static_cast<bool>(cLocalCodes == DEFAULT_ACCEL);
return true; return true;
@ -388,10 +388,10 @@ CCmdAccelOb::CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand)
CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked) CCmdAccelOb::CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked)
{ {
ASSERT(szCommand != NULL); ASSERT(szCommand != NULL);
m_wIDCommand = wIDCommand; m_wIDCommand = wIDCommand;
m_szCommand = szCommand; m_szCommand = szCommand;
CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked); CAccelsOb* pAccel = DEBUG_NEW CAccelsOb(cVirt, wKey, bLocked);
ASSERT(pAccel != NULL); ASSERT(pAccel != NULL);
m_Accels.AddTail(pAccel); m_Accels.AddTail(pAccel);
@ -439,10 +439,10 @@ void CCmdAccelOb::Add(CAccelsOb* pAccel)
CCmdAccelOb& CCmdAccelOb::operator=(const CCmdAccelOb& from) CCmdAccelOb& CCmdAccelOb::operator=(const CCmdAccelOb& from)
{ {
Reset(); Reset();
m_wIDCommand = from.m_wIDCommand; m_wIDCommand = from.m_wIDCommand;
m_szCommand = from.m_szCommand; m_szCommand = from.m_szCommand;
CAccelsOb* pAccel; CAccelsOb* pAccel;
POSITION pos = from.m_Accels.GetHeadPosition(); POSITION pos = from.m_Accels.GetHeadPosition();
while (pos != NULL) { while (pos != NULL) {
@ -480,7 +480,7 @@ void CCmdAccelOb::Reset()
{ {
m_wIDCommand = 0; m_wIDCommand = 0;
m_szCommand = "Empty command"; m_szCommand = "Empty command";
CAccelsOb* pAccel; CAccelsOb* pAccel;
POSITION pos = m_Accels.GetHeadPosition(); POSITION pos = m_Accels.GetHeadPosition();
while (pos != NULL) { while (pos != NULL) {

View File

@ -22,7 +22,7 @@
// Version : 1.0 * Author : T.Maurel // Version : 1.0 * Author : T.Maurel
// Date : 17.08.98 // Date : 17.08.98
// //
// Remarks : // Remarks :
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef __CMDACCEL_OB_INCLUDE #ifndef __CMDACCEL_OB_INCLUDE

View File

@ -63,7 +63,7 @@ void ColorButton::PreSubclassWindow()
void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{ {
ASSERT(lpDrawItemStruct); ASSERT(lpDrawItemStruct);
int r = (color & 0x1f) << 3; int r = (color & 0x1f) << 3;
int g = (color & 0x3e0) >> 2; int g = (color & 0x3e0) >> 2;
int b = (color & 0x7c00) >> 7; int b = (color & 0x7c00) >> 7;
@ -82,8 +82,8 @@ void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
DrawEdge(dc, &rect, EDGE_RAISED, BF_RECT); DrawEdge(dc, &rect, EDGE_RAISED, BF_RECT);
InflateRect(&rect, -margins.cx, -margins.cy); 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)); ::GetSysColor(COLOR_3DFACE) : RGB(r,g,b));
FillRect(dc, &rect, br); FillRect(dc, &rect, br);
@ -92,7 +92,7 @@ void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
InflateRect(&rect, -1, -1); InflateRect(&rect, -1, -1);
DrawFocusRect(dc, &rect); DrawFocusRect(dc, &rect);
} }
DeleteObject(br); DeleteObject(br);
} }

View File

@ -56,12 +56,12 @@ BEGIN_MESSAGE_MAP(ColorControl, CWnd)
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ColorControl message handlers // ColorControl message handlers
void ColorControl::OnPaint() void ColorControl::OnPaint()
{ {
CPaintDC dc(this); // device context for painting CPaintDC dc(this); // device context for painting
} }
BOOL ColorControl::OnEraseBkgnd(CDC* pDC) BOOL ColorControl::OnEraseBkgnd(CDC* pDC)
{ {
int r = (color & 0x1f) << 3; int r = (color & 0x1f) << 3;
int g = (color & 0x3e0) >> 2; int g = (color & 0x3e0) >> 2;

View File

@ -167,7 +167,7 @@ struct {
{ "OptionsSoundVolume1x", ID_OPTIONS_SOUND_VOLUME_1X }, { "OptionsSoundVolume1x", ID_OPTIONS_SOUND_VOLUME_1X },
{ "OptionsSoundVolume2x", ID_OPTIONS_SOUND_VOLUME_2X }, { "OptionsSoundVolume2x", ID_OPTIONS_SOUND_VOLUME_2X },
{ "OptionsSoundVolume3x", ID_OPTIONS_SOUND_VOLUME_3X }, { "OptionsSoundVolume3x", ID_OPTIONS_SOUND_VOLUME_3X },
{ "OptionsSoundVolume4x", ID_OPTIONS_SOUND_VOLUME_4X }, { "OptionsSoundVolume4x", ID_OPTIONS_SOUND_VOLUME_4X },
{ "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER }, { "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER },
{ "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC }, { "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC },
{ "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS }, { "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS },
@ -236,13 +236,13 @@ bool winAccelGetID(const char *command, WORD& id)
{ {
if(!initialized) { if(!initialized) {
int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]); int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
for(int i = 0; i < count; i++) { 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; initialized = true;
} }
return winAccelStrings.Lookup(command, id) ? true : false; 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