pcsxr-1.9.92

This commit is contained in:
PCSX* teams 2010-11-16 14:15:22 +02:00 committed by Grazvydas Ignotas
commit ef79bbde53
462 changed files with 235737 additions and 0 deletions

2
ABOUT-NLS Normal file
View File

@ -0,0 +1,2 @@
PCSX-df uses gettext internally, but can be configured without it.
The gettext library is not included with PCSX-df.

39
AUTHORS Normal file
View File

@ -0,0 +1,39 @@
PCSX Upstream Authors: Linuzappz <linuzappz@pcsx.net>
Shadow <shadow@pcsx.net>
Pete Bernett <psswitch@online.de>
NoComp <NoComp@mailcity.com>
Nik3d
Akumax <akumax@pcsx.net>
PCSX Copyright: (c) 1999-2003 Pcsx Team
(c) 1998 Vision Thing
df Upstream Authors: Ryan Schultz <schultz.ryan@gmail.com>
Andrew Burton <adb@iinet.net.au>
Stephen Chao <schao@myrealbox.com>
Marcus Comstedt <marcus@mc.pp.se>
Stefan Sikora <hoshy@schrauberstube.de>
df Copyright: (c) 2005 Ryan Schultz
(c) 2005 Andrew Burton
(c) 2007 Stephen Chao
(c) 2006 Marcus Comstedt
PCSX-Reloaded Authors/Contributors: avlex (Help on xcode project)
Dario (Various bugfixes)
edgbla (Root counters, various core/plugin fixes)
Firnis (GTE code from PCSX-Revolution Project)
Gabriele Gorla (MDEC decoder)
maggix (Snow Leopard compile fix)
NeToU (Bugfix)
Peter Collingbourne (Various core/psxbios fixes)
siveritas (Bugfix)
shalma (GTE Divider, various core fixes)
Tristin Celestin (PulseAudio support)
Wei Mingzhi (Maintainer, input plugin, iso/cheat support, misc stuff)
PCSX-Reloaded Translators: edgbla (Russian)
Giovanni Scafora (Italian)
Tibério Vítor (Brazilian Portuguese)
Wei Mingzhi (Simplified & Traditional Chinese)

353
COPYING Normal file
View File

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

2078
ChangeLog Normal file

File diff suppressed because it is too large Load Diff

486
ChangeLog.df Normal file
View File

@ -0,0 +1,486 @@
2008-05-06
- mdec: improvement for FF9, maybe other games run better, too
2008-05-04
- hdebug: supress multiple debugger-instances when using savestates, patch by Benoit Gschwind
2008-05-02
- dfiso: cleanup, rewrite and relicensing
2008-03-16
- dfOpenGL: configuration for window-resolution added
2008-03-09
- some uses of psxHu32() as an lvalue fixed
2008-03-07
- dfiso: several improvements of the new functions
2008-03-04
- dfiso: CDDA-playback and .toc-parsing implemented, minor source cleanups
2008-02-25
- HLE-Bios: initheap, malloc, free rewritten
- HLE-Bios: experimental patch in EnterCriticalSection, this one replaces the one in OpenEvent
- Interpreter: bug fix for HLE-jumptable
2008-01-22
- HLE-Bios: SetMem(size) added
- HLE-Bios: bugfix in OpenEvent(), several games work now with HLE, others do not, needs more investigation
- dfbinimage: modifications for compilation with recent portaudio
- dfbinimage: cleanup directory
2008-01-17
- minor debugger improvement
2008-01-16
- dfiso: conditional use of libnautilus for easy usage
- dfiso: additional default drives
- dfOpenGL included in autobuild-process
- HLE-Bios: bugfixes malloc() and free()
- HLE-Bios: bugfix for loading files, lots of games should start now with emulated Bios!
2008-01-12
- speed up for interpreter without debugger
- minor debugger improvements
2008-01-11
- integrated game debugger
2008-01-09
- dfiso: multiple bug fixes, not needed files removed
- dfiso: dependency to libnautilus deleted, instead function for cd-drive scanning in /sys/block
2008-01-08
- libpcsxcore: segfault in loadcdrom() fixed
- gui: segfaults on closing memory-card-dialog fixed
2007-12-13
- dfxvideo: bugfixes yuv-adaptor
Please consult the darcs changelog for the latest.
Sun Apr 23 11:39:31 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* disable building of peops-video config
Sun Apr 23 11:38:53 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add partial config file write/read to gpucfg (doesn't have fixes support yet)
Sat Apr 22 23:22:49 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add the start of a peops-video reworking
Sat Apr 22 23:21:08 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* save sound config on close
Fri Apr 14 23:51:22 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* move plugins/sound to plugins/dfsound
Fri Apr 14 23:50:28 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* fix segfault when a library changes between PCSX's startup and the loading of a CD
Fri Apr 14 23:48:41 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* name tweaking on DFSound
Fri Apr 14 23:31:39 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* update spu to use GTK2 with a new glade interface
Fri Apr 14 22:54:37 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* cleanup binaries
Fri Apr 14 22:47:35 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* reactivate autorepeat on dfinput PADclose
Fri Apr 14 22:44:25 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* fix dfinput config program
Fri Apr 14 22:14:12 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* fix dumbness in sound plugin that caused config file name to be prefixed with garbage
Fri Apr 14 22:12:35 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* drop omnijoy
Fri Apr 14 22:12:06 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* move padjoy to dfinput folder
Fri Apr 14 22:11:07 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* move padjoy around and rename it to DFInput (Gamepad/Keyboard Input)
Fri Apr 14 21:54:30 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add plugins which i apparently forgot about...
Fri Apr 14 21:52:37 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add a tweaked padjoy, which will probably be the new default input; this one supports the keyboard and is gtk2
Fri Apr 14 21:49:51 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* extend CheckPlugins testing and use it in more places; fixes segfault when a plugin symlink disappears
Fri Apr 14 21:49:22 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* fix short path lengths for BiosDir and PluginsDir
Fri Apr 14 14:46:31 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* fix nogui support
Fri Apr 14 14:32:35 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* build mooby with debug
Fri Apr 14 14:29:32 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* prevent segfault on Escape press in-game by forcing exit
This is a tragedy, but I see no way to restart the GUI without completely reworking PCSX
to use functions with actual return values (PCSX team sure loved void, even when the functions
can fail disastrously!). The explanation is in the source; basically the SysUpdate call
that catches Escape presses is deep within the emulation code itself, so it tries to StartGui
after closing the plugins and the psx core... then the emulation that was in progress tries to
continue, since it returns no indication of a stop!
Fri Apr 14 14:29:03 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* remove some more path length limits
Thu Apr 6 17:40:56 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
UNDO: remove redundant RunGui, SysRunGui functions for StartGui
Thu Apr 13 19:17:56 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* fix save/load state functionality
Wed Apr 12 21:00:11 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* remove files that shouldn't be in repo
Wed Apr 12 20:57:46 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add AM_PO_SUBDIRS
Wed Apr 12 20:49:01 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* docs and support files tinkering
Wed Apr 12 20:17:01 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* update interface for PSX Input plugin
Tue Apr 11 19:34:25 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* set window icon
Tue Apr 11 19:23:52 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* move a bunch of files around in plugins/
Tue Apr 11 19:22:55 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* fix segfault in PSX input, possibly breaking other things -- untested
Tue Apr 11 16:02:45 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* heh, switch was more needed than i thought, revert that
Tue Apr 11 15:57:16 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* remove unneeded switch to dotdir
Tue Apr 11 15:56:51 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* some string fixes
Tue Apr 11 15:54:44 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* make certain that plugin functions only happen when plugins are available, and prevent the emulator core from attempting to start without having all plugins loaded
Fri Apr 7 17:41:33 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* choose default plugins if none are set when a new directory is scanned
Thu Apr 6 17:40:56 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* remove redundant RunGui, SysRunGui functions for StartGui
Thu Apr 6 17:37:40 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* autoconf bigendian check
Thu Apr 6 17:24:50 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* merge Debian patch from Marcus Comstedt <marcus@mc.pp.se> to fix bigendian compiles
Thu Apr 6 17:19:05 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* switch __MACOSX__ define to __BIGENDIAN__
Tue Apr 4 06:24:39 EDT 2006 adb@iinet.net.au
* GStrings_and_MiscCleanups
Converted a number of C string utility functions to use the GLib string functions, miscellaneous clean ups of redundant code
Fri Mar 24 05:24:14 EST 2006 adb@iinet.net.au
* BIOS_Path_and_CDROM_Plugin
Sun Apr 2 13:35:39 EDT 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add new sound plugin, adapted from PEOpS OSS
Tue Mar 28 15:19:34 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add plugins, some small changes in misc. places; plugins include a nicer omnijoy
Wed Mar 22 16:17:10 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* autotools version note
Wed Mar 22 16:11:37 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* fix manpage
Sun Feb 26 14:33:38 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add keyboard accelerators for main interface
Sat Jan 28 19:40:19 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* adjust main window size slightly
Sun Jan 22 14:18:13 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add trivial autogen.sh script
Sun Jan 22 14:14:39 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add support for instant autoconfiguration on first launch if plugins are available
Sun Jan 22 14:13:37 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* split UpdatePluginsBIOS into two functions, one for GUI and one for not
Sun Jan 22 14:12:40 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* fix splash install directory
Sun Jan 22 13:51:03 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* remove some more Glade cruft
Sun Jan 22 13:47:04 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* kill Glade in Makefile.am
Sat Jan 21 18:29:22 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* beginnings of quiet autoconfiguration
Sat Jan 21 18:28:31 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* build fix on non-x86 arches
Sat Jan 21 05:09:54 EST 2006 adb@iinet.net.au
* Die-Glade-Generated-Code
Fri Jan 20 23:31:02 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add desktop file
Sun Jan 15 15:47:39 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* more woo for the po makefile :- )
Wed Jan 11 20:56:41 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add a desktop file, add automagic for icons and desktop file
Mon Jan 9 12:11:35 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add include/config.h.in *duh*
Sun Jan 8 11:23:54 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add config.rpath to quiet an error in configure
Sun Jan 8 11:03:04 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* minor changes to the style of the memcard dialog
Sun Jan 8 10:52:14 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* merge fixes for patch conflicts
Sun Jan 8 05:26:09 EST 2006 adb@iinet.net.au
* MemCards
Sun Jan 8 02:53:13 EST 2006 adb@iinet.net.au
* Automake
Sun Jan 8 02:31:03 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* replace crummy icon with more colorful one
Sun Jan 8 02:10:12 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add fake rules to temp po/Makefile to stop senseless msgmerges
Sun Jan 8 02:07:24 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add autoheader magic, cleanup autotools structure a little
Sat Jan 7 02:14:42 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* fixes to automake/autoconf setup, update some docs
Sat Jan 7 01:10:34 EST 2006 adb@iinet.net.au
* Automake2
Fri Jan 6 21:20:47 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* automatically create default memcards during startup config
Fri Jan 6 17:54:26 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add ScanPlugins to OnPluginsPath_Changed
Thu Jan 5 22:38:30 EST 2006 adb@iinet.net.au
* Config
Wed Jan 4 18:23:05 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add Swedish translation by Daniel Nylander <yeager@lidkoping.net> along with Makefile rules
Tue Jan 3 19:55:34 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* slight tweak to icons, install the really ugly one only now
Tue Jan 3 19:52:15 EST 2006 Ryan Schultz <schultz.ryan@gmail.com>
* add crappy preliminary icons and install rules for them
Mon Jan 2 21:20:20 EST 2006 adb@iinet.net.au
* UseExistingDialogs
Thu Dec 29 23:16:29 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add little image to netplay dialog
Thu Dec 29 23:12:02 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add desktop file and associated install rules
Thu Dec 29 23:05:56 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add install/uninstall support to makefile
Thu Dec 29 22:39:31 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* update some of the path variables to MAXPATHLEN
Wed Dec 28 04:00:25 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* set current folder to home before calling file choosers
Tue Dec 27 17:34:03 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* fix conflicts
Tue Dec 27 17:15:17 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* try to get archives synced
Tue Dec 27 17:09:43 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* touch up new configure, cpu, and net dialogs
Tue Dec 27 17:14:19 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* merge fixes for PATCHConfDlg etc
Mon Dec 26 18:11:48 EST 2005 adb@iinet.net.au
* PATCHConfDlgNetDlg
Mon Dec 26 15:28:50 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* remove unnecessary signal
Mon Dec 26 15:21:39 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* small modifications to CpuDlg patch
Mon Dec 26 03:20:06 EST 2005 adb@iinet.net.au
* PATCHCpuDlg
Sat Dec 24 01:19:32 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* remove window sensitivity switching, set children dialogs to die with parent
Sat Dec 24 00:45:42 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add broken symlink handling to scan code
Fri Dec 23 23:38:26 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* make gtk2 check have teeth (error when not found)
Fri Dec 23 23:15:04 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* pixmaps search change
Fri Dec 23 23:12:51 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add autoconf/makefile crossbreed... PCSX does not get along with automake
Fri Dec 23 18:28:52 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* fix silly mistakes with file chooser
Fri Dec 23 17:27:30 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* more glade updates
Fri Dec 23 17:26:34 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add new splash
Fri Dec 23 16:07:44 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* more gui tweaking, move buttons around in glade
Fri Dec 23 15:48:36 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* more cleanup, remove unneeded files and strings
Fri Dec 23 15:08:34 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* update all file selectors to file choosers
Fri Dec 23 14:33:07 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* modern GTK about dialog
Fri Dec 23 13:24:08 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* revert CPU config dialog changes (the more advanced glade stuff)
Fri Dec 23 12:46:08 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* completely rework how plugins are handled, initial commit, needs cleanup
The new plugin handling system uses symlinks to store plugins in ~/.pcsx/plugins, along with their config tools. This way, plugins can be in multiple directories. Config.PluginsDir is removed. The Plugins & BIOS configuring interface now has an option to choose the directory to scan. Much cleanup is needed, though, as FindPlugins vs ScanPlugins, etc. cruft abounds.
Fri Dec 23 00:36:45 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add start of unified makefile for plugins
Fri Dec 23 00:21:04 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* remove some old/invalid docs
Fri Dec 23 00:16:38 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add stub README
Fri Dec 23 00:14:41 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add some common files (INSTALL, COPYING, AUTHORS, etc)
Thu Dec 22 23:43:26 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add file that were missed
Thu Dec 22 23:21:29 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* fix NLS and gettext support!! WOO
Thu Dec 22 23:20:36 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* some defines in the makefile for temporary prefix support
Thu Dec 22 23:20:11 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* remove more
Thu Dec 22 23:19:42 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* remove empty files
Thu Dec 22 21:55:59 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* completely refactor directory layout, remove imaginary autotooling
Thu Dec 22 21:37:49 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* more string cleanups, path to sane languages begins
Thu Dec 22 21:14:32 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* remove broken lang support from base code
Thu Dec 22 21:10:47 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* remove broken language support from GUI, GUI cleanup, fix pixmap location routine, revert pcsx.glade
Thu Dec 22 20:28:29 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* turn off emuLog debug recording
Thu Dec 22 20:24:21 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* incorporate free plugins into pcsx-df source
I think this is a good idea. It makes my life easier, for sure, and
will let me keep the PCSX-df modified plugins with pcsx-df.
Thu Dec 22 11:53:46 EST 2005 Ryan Schultz <schultz.ryan@gmail.com>
* incorporate patches for file chooser, glade
Sun Oct 16 16:30:40 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* change mind about splash, add install/uninstall routines
Sun Oct 16 15:30:58 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* new splash screen, small changes towards release
Sun Oct 16 14:37:30 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* remove dreamcast support, less retarded sed
I forgot to remove the sh4 dir for the Dreamcast. I also did the sed in the Makefile in a very dumb way. Small changelog update too.
Sun Oct 16 14:19:09 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* remove hardcoded directories
Sat Oct 15 22:16:32 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* fix dumb gcc4 mistake
Sat Oct 15 21:17:48 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* gcc 4 compatibility!!
This patch adds gcc 4.0 compatibility at last! The fix was to mangle the lvalue casts into a form gcc would accept. It's ugly, but it works.
example:
(u8*)ptr = (u8*)(psxM + psxRu32(base));
becomes
*(u8*)&ptr = (u8*)(psxM + psxRu32(base));
gcc is perfectly fine with this. For now.
There are also some minor Makefile updates, removing gcc-3.4 specifics.
Mon Oct 3 22:25:07 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* add slightly better install routine, temp hack until I reautotool
Mon Oct 3 22:07:19 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* remove Gtk1 GUI code and support, rewrite makefiles and configure.in to use more user opts
Sun Oct 2 21:26:31 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* fix potential crash (strcpy vs strncpy)
Sun Oct 2 21:19:13 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* finish up dotfile support for everything but cfg
Dotfile support is now complete, except for running the cfg programs. This
is hardcoded into the plugins, and cannot be fixed in PCSX proper.
Sun Oct 2 15:55:34 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* memcard note
Sun Oct 2 14:18:40 EDT 2005 Ryan Schultz <schultz.ryan@gmail.com>
* intial revision
From PCSX 1.6 beta

291
INSTALL Normal file
View File

@ -0,0 +1,291 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007, 2008 Free Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
6. Often, you can also type `make uninstall' to remove the installed
files again.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
`--help=short'
`--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *Note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
`--no-create'
`-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

4
Makefile.am Normal file
View File

@ -0,0 +1,4 @@
SUBDIRS = data doc po libpcsxcore gui pixmaps plugins/dfinput plugins/dfsound plugins/dfxvideo plugins/dfcdrom plugins/dfnet
SUBDIRS += $(PEOPSXGL)
EXTRA_DIST = AUTHORS COPYING INSTALL NEWS README ChangeLog ChangeLog.df

682
Makefile.in Normal file
View File

@ -0,0 +1,682 @@
# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/configure \
$(top_srcdir)/include/config.h.in ABOUT-NLS AUTHORS COPYING \
ChangeLog INSTALL NEWS compile config.guess config.rpath \
config.sub depcomp install-sh ltmain.sh missing mkinstalldirs
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
install-html-recursive install-info-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
ALSA_CFLAGS = @ALSA_CFLAGS@
ALSA_LIBS = @ALSA_LIBS@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
GLADE2_CFLAGS = @GLADE2_CFLAGS@
GLADE2_LIBS = @GLADE2_LIBS@
GLIB2_CFLAGS = @GLIB2_CFLAGS@
GLIB2_LIBS = @GLIB2_LIBS@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GREP = @GREP@
GTK2_CFLAGS = @GTK2_CFLAGS@
GTK2_LIBS = @GTK2_LIBS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBCDIO_CFLAGS = @LIBCDIO_CFLAGS@
LIBCDIO_LIBS = @LIBCDIO_LIBS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NASM = @NASM@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PEOPSXGL = @PEOPSXGL@
PKG_CONFIG = @PKG_CONFIG@
POSUB = @POSUB@
PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@
PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@
RANLIB = @RANLIB@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_LIBS = @SDL_LIBS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = data doc po libpcsxcore gui pixmaps plugins/dfinput \
plugins/dfsound plugins/dfxvideo plugins/dfcdrom plugins/dfnet \
$(PEOPSXGL)
EXTRA_DIST = AUTHORS COPYING INSTALL NEWS README ChangeLog ChangeLog.df
all: all-recursive
.SUFFIXES:
am--refresh:
@:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
cd $(srcdir) && $(AUTOMAKE) --gnu \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
include/config.h: include/stamp-h1
@if test ! -f $@; then \
rm -f include/stamp-h1; \
$(MAKE) $(AM_MAKEFLAGS) include/stamp-h1; \
else :; fi
include/stamp-h1: $(top_srcdir)/include/config.h.in $(top_builddir)/config.status
@rm -f include/stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status include/config.h
$(top_srcdir)/include/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f include/stamp-h1
touch $@
distclean-hdr:
-rm -f include/config.h include/stamp-h1
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool config.lt
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d $(distdir) || mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$top_distdir" \
distdir="$$distdir/$$subdir" \
am__remove_distdir=: \
am__skip_length_check=: \
distdir) \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-lzma: distdir
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
$(am__remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lzma*) \
unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr \
distclean-libtool distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-exec-am:
install-html: install-html-recursive
install-info: install-info-recursive
install-man:
install-pdf: install-pdf-recursive
install-ps: install-ps-recursive
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
install-strip
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-am clean clean-generic \
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \
distclean distclean-generic distclean-hdr distclean-libtool \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-recursive uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

5
NEWS Normal file
View File

@ -0,0 +1,5 @@
PCSX-Reloaded: Bringing clarity, joy, and a nice GUI to PCSX.
You should remove your old ~/.pcsx directory before using PCSX-Reloaded, to
avoid any possible compatibility issues, such as missing folders. Remember
that memcards and savestates are kept there, so be sure to copy them out first!

20
README Normal file
View File

@ -0,0 +1,20 @@
PCSX-Reloaded
-------------------------------
PCSX-Reloaded is a forked version of the dead PCSX emulator, with a nicer
interface and several improvements to stability and functionality.
PCSX-Reloaded uses the PSEMU plugin interface to provide most functionality;
without them, you will not be able to use it to play games. PCSX-Reloaded
provides a number of plugins to provide basic functionality out of the box.
PCSX-Reloaded has a very capable Internal HLE BIOS that can run many games
without problems. It is recommended that you use it. However, if you own a
real PlayStation, you may be able to use your own BIOS image. PCSX-Reloaded
will find it in ~/.pcsx/bios/ or /usr/share/psemu/bios/ if you place it there.
This can improve compatibility, especially with certain games and with the
use of memory cards.
See the doc/ folder in the source, or /usr/share/doc/pcsx/ on Debian systems,
for more detailed information on PCSX-Reloaded. A UNIX manpage is also
available.

11427
aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

12
autogen.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
# Additional options go to configure.
echo "Rebuilding ./configure with autoreconf..."
autoreconf -f -i
if [ $? -ne 0 ]; then
echo "autoreconf failed"
exit $?
fi
./configure --enable-maintainer-mode "$@"

142
compile Executable file
View File

@ -0,0 +1,142 @@
#! /bin/sh
# Wrapper for compilers which do not understand `-c -o'.
scriptversion=2005-05-14.22
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand `-c -o'.
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file `INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
esac
ofile=
cfile=
eat=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as `compile cc -o foo foo.c'.
# So we strip `-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no `-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
# Create the lock directory.
# Note: use `[/.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

1526
config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

666
config.rpath Executable file
View File

@ -0,0 +1,666 @@
#! /bin/sh
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2007 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
# should be set by the caller.
#
# The set of defined variables is at the end of this script.
# Known limitations:
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
# than 256 bytes, otherwise the compiler driver will dump core. The only
# known workaround is to choose shorter directory names for the build
# directory and/or the installation directory.
# All known linkers require a `.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a
shrext=.so
host="$1"
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
# Code taken from libtool.m4's _LT_CC_BASENAME.
for cc_temp in $CC""; do
case $cc_temp in
compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
\-*) ;;
*) break;;
esac
done
cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
wl=
if test "$GCC" = yes; then
wl='-Wl,'
else
case "$host_os" in
aix*)
wl='-Wl,'
;;
darwin*)
case $cc_basename in
xlc*)
wl='-Wl,'
;;
esac
;;
mingw* | cygwin* | pw32* | os2*)
;;
hpux9* | hpux10* | hpux11*)
wl='-Wl,'
;;
irix5* | irix6* | nonstopux*)
wl='-Wl,'
;;
newsos6)
;;
linux* | k*bsd*-gnu)
case $cc_basename in
icc* | ecc*)
wl='-Wl,'
;;
pgcc | pgf77 | pgf90)
wl='-Wl,'
;;
ccc*)
wl='-Wl,'
;;
como)
wl='-lopt='
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ C*)
wl='-Wl,'
;;
esac
;;
esac
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
rdos*)
;;
solaris*)
wl='-Wl,'
;;
sunos4*)
wl='-Qoption ld '
;;
sysv4 | sysv4.2uw2* | sysv4.3*)
wl='-Wl,'
;;
sysv4*MP*)
;;
sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
wl='-Wl,'
;;
unicos*)
wl='-Wl,'
;;
uts4*)
;;
esac
fi
# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
hardcode_libdir_flag_spec=
hardcode_libdir_separator=
hardcode_direct=no
hardcode_minus_L=no
case "$host_os" in
cygwin* | mingw* | pw32*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
if test "$GCC" != yes; then
with_gnu_ld=no
fi
;;
interix*)
# we just hope/assume this is gcc and not c89 (= MSVC++)
with_gnu_ld=yes
;;
openbsd*)
with_gnu_ld=no
;;
esac
ld_shlibs=yes
if test "$with_gnu_ld" = yes; then
# Set some defaults for GNU ld with shared library support. These
# are reset later if shared libraries are not supported. Putting them
# here allows them to be overridden if necessary.
# Unlike libtool, we use -rpath here, not --rpath, since the documented
# option of GNU ld is called -rpath, not --rpath.
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
case "$host_os" in
aix3* | aix4* | aix5*)
# On AIX/PPC, the GNU linker is very broken
if test "$host_cpu" != ia64; then
ld_shlibs=no
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
# that the semantics of dynamic libraries on AmigaOS, at least up
# to version 4, is to share data among multiple programs linked
# with the same dynamic library. Since this doesn't match the
# behavior of shared libraries on other platforms, we cannot use
# them.
ld_shlibs=no
;;
beos*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
cygwin* | mingw* | pw32*)
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir'
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
interix[3-9]*)
hardcode_direct=no
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
gnu* | linux* | k*bsd*-gnu)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
netbsd*)
;;
solaris*)
if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
ld_shlibs=no
elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
case `$LD -v 2>&1` in
*\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
ld_shlibs=no
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
else
ld_shlibs=no
fi
;;
esac
;;
sunos4*)
hardcode_direct=yes
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
esac
if test "$ld_shlibs" = no; then
hardcode_libdir_flag_spec=
fi
else
case "$host_os" in
aix3*)
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
hardcode_minus_L=yes
if test "$GCC" = yes; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
hardcode_direct=unsupported
fi
;;
aix4* | aix5*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[23]|aix4.[23].*|aix5*)
for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes
break
fi
done
;;
esac
fi
hardcode_direct=yes
hardcode_libdir_separator=':'
if test "$GCC" = yes; then
case $host_os in aix4.[012]|aix4.[012].*)
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" && \
strings "$collect2name" | grep resolve_lib_name >/dev/null
then
# We have reworked collect2
:
else
# We have old collect2
hardcode_direct=unsupported
hardcode_minus_L=yes
hardcode_libdir_flag_spec='-L$libdir'
hardcode_libdir_separator=
fi
;;
esac
fi
# Begin _LT_AC_SYS_LIBPATH_AIX.
echo 'int main () { return 0; }' > conftest.c
${CC} ${LDFLAGS} conftest.c -o conftest
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
if test -z "$aix_libpath"; then
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
fi
if test -z "$aix_libpath"; then
aix_libpath="/usr/lib:/lib"
fi
rm -f conftest.c conftest
# End _LT_AC_SYS_LIBPATH_AIX.
if test "$aix_use_runtimelinking" = yes; then
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
else
if test "$host_cpu" = ia64; then
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
else
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
fi
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# see comment about different semantics on the GNU ld section
ld_shlibs=no
;;
bsdi[45]*)
;;
cygwin* | mingw* | pw32*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec=' '
libext=lib
;;
darwin* | rhapsody*)
hardcode_direct=no
if test "$GCC" = yes ; then
:
else
case $cc_basename in
xlc*)
;;
*)
ld_shlibs=no
;;
esac
fi
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
freebsd1*)
ld_shlibs=no
;;
freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
freebsd2*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
freebsd* | dragonfly*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
hpux9*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
hpux10*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
fi
;;
hpux11*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
case $host_cpu in
hppa*64*|ia64*)
hardcode_direct=no
;;
*)
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
esac
fi
;;
irix5* | irix6* | nonstopux*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
netbsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
newsos6)
hardcode_direct=yes
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
openbsd*)
if test -f /usr/libexec/ld.so; then
hardcode_direct=yes
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
else
case "$host_os" in
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi
else
ld_shlibs=no
fi
;;
os2*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
osf3*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
osf4* | osf5*)
if test "$GCC" = yes; then
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
else
# Both cc and cxx compiler support -rpath directly
hardcode_libdir_flag_spec='-rpath $libdir'
fi
hardcode_libdir_separator=:
;;
solaris*)
hardcode_libdir_flag_spec='-R$libdir'
;;
sunos4*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=yes
hardcode_minus_L=yes
;;
sysv4)
case $host_vendor in
sni)
hardcode_direct=yes # is this really true???
;;
siemens)
hardcode_direct=no
;;
motorola)
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
;;
esac
;;
sysv4.3*)
;;
sysv4*MP*)
if test -d /usr/nec; then
ld_shlibs=yes
fi
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
;;
sysv5* | sco3.2v5* | sco5v6*)
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
hardcode_libdir_separator=':'
;;
uts4*)
hardcode_libdir_flag_spec='-L$libdir'
;;
*)
ld_shlibs=no
;;
esac
fi
# Check dynamic linker characteristics
# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
# Unlike libtool.m4, here we don't care about _all_ names of the library, but
# only about the one the linker finds when passed -lNAME. This is the last
# element of library_names_spec in libtool.m4, or possibly two of them if the
# linker has special search rules.
library_names_spec= # the last element of library_names_spec in libtool.m4
libname_spec='lib$name'
case "$host_os" in
aix3*)
library_names_spec='$libname.a'
;;
aix4* | aix5*)
library_names_spec='$libname$shrext'
;;
amigaos*)
library_names_spec='$libname.a'
;;
beos*)
library_names_spec='$libname$shrext'
;;
bsdi[45]*)
library_names_spec='$libname$shrext'
;;
cygwin* | mingw* | pw32*)
shrext=.dll
library_names_spec='$libname.dll.a $libname.lib'
;;
darwin* | rhapsody*)
shrext=.dylib
library_names_spec='$libname$shrext'
;;
dgux*)
library_names_spec='$libname$shrext'
;;
freebsd1*)
;;
freebsd* | dragonfly*)
case "$host_os" in
freebsd[123]*)
library_names_spec='$libname$shrext$versuffix' ;;
*)
library_names_spec='$libname$shrext' ;;
esac
;;
gnu*)
library_names_spec='$libname$shrext'
;;
hpux9* | hpux10* | hpux11*)
case $host_cpu in
ia64*)
shrext=.so
;;
hppa*64*)
shrext=.sl
;;
*)
shrext=.sl
;;
esac
library_names_spec='$libname$shrext'
;;
interix[3-9]*)
library_names_spec='$libname$shrext'
;;
irix5* | irix6* | nonstopux*)
library_names_spec='$libname$shrext'
case "$host_os" in
irix5* | nonstopux*)
libsuff= shlibsuff=
;;
*)
case $LD in
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
*) libsuff= shlibsuff= ;;
esac
;;
esac
;;
linux*oldld* | linux*aout* | linux*coff*)
;;
linux* | k*bsd*-gnu)
library_names_spec='$libname$shrext'
;;
knetbsd*-gnu)
library_names_spec='$libname$shrext'
;;
netbsd*)
library_names_spec='$libname$shrext'
;;
newsos6)
library_names_spec='$libname$shrext'
;;
nto-qnx*)
library_names_spec='$libname$shrext'
;;
openbsd*)
library_names_spec='$libname$shrext$versuffix'
;;
os2*)
libname_spec='$name'
shrext=.dll
library_names_spec='$libname.a'
;;
osf3* | osf4* | osf5*)
library_names_spec='$libname$shrext'
;;
rdos*)
;;
solaris*)
library_names_spec='$libname$shrext'
;;
sunos4*)
library_names_spec='$libname$shrext$versuffix'
;;
sysv4 | sysv4.3*)
library_names_spec='$libname$shrext'
;;
sysv4*MP*)
library_names_spec='$libname$shrext'
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
library_names_spec='$libname$shrext'
;;
uts4*)
library_names_spec='$libname$shrext'
;;
esac
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
# How to pass a linker flag through the compiler.
wl="$escaped_wl"
# Static library suffix (normally "a").
libext="$libext"
# Shared library suffix (normally "so").
shlibext="$shlibext"
# Format of library name prefix.
libname_spec="$escaped_libname_spec"
# Library names that the linker finds when passed -lNAME.
library_names_spec="$escaped_library_names_spec"
# Flag to hardcode \$libdir into a binary during linking.
# This must work even if \$libdir does not exist.
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
# Whether we need a single -rpath flag with a separated argument.
hardcode_libdir_separator="$hardcode_libdir_separator"
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
# resulting binary.
hardcode_direct="$hardcode_direct"
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
# resulting binary.
hardcode_minus_L="$hardcode_minus_L"
EOF

1658
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

19356
configure vendored Executable file

File diff suppressed because it is too large Load Diff

214
configure.ac Normal file
View File

@ -0,0 +1,214 @@
AC_INIT(pcsx, 1.9)
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(pcsx, 1.9)
AM_MAINTAINER_MODE
AC_CONFIG_HEADERS([include/config.h:include/config.h.in])
AC_PROG_CC
AC_PROG_RANLIB
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PROG_INSTALL
AC_STDC_HEADERS
AM_PROG_AS
AM_GNU_GETTEXT([external])
GETTEXT_PACKAGE=pcsx
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["${GETTEXT_PACKAGE}"], [gettext domain])
PKG_CHECK_MODULES(GLIB2, glib-2.0, [], AC_MSG_ERROR([*** glib2 not found!]))
PKG_CHECK_MODULES(GTK2, gtk+-2.0, [], AC_MSG_ERROR([*** libgtk2 not found!]))
PKG_CHECK_MODULES(GLADE2, libglade-2.0, [], AC_MSG_ERROR([*** libglade2 not found!]))
AM_PATH_SDL(1.2.0, :, AC_MSG_ERROR([*** SDL not found!]))
AC_SUBST(GLIB2_CFLAGS)
AC_SUBST(GLIB2_LIBS)
AC_SUBST(GTK2_CFLAGS)
AC_SUBST(GTK2_LIBS)
AC_SUBST(GLADE2_CFLAGS)
AC_SUBST(GLADE2_LIBS)
AC_CONFIG_FILES([Makefile data/Makefile doc/Makefile libpcsxcore/Makefile gui/Makefile plugins/dfinput/Makefile plugins/dfsound/Makefile plugins/dfxvideo/Makefile plugins/dfcdrom/Makefile plugins/dfnet/Makefile pixmaps/Makefile po/Makefile.in])
AC_CHECK_LIB(dl, dlsym, [LDFLAGS="$LDFLAGS -ldl"], [])
AC_CHECK_LIB(socket, socket, [LDFLAGS="$LDFLAGS -lsocket"], [])
AC_CHECK_LIB(nsl, gethostbyname, [LDFLAGS="$LDFLAGS -lnsl"], [])
AC_CHECK_LIB(umem, umem_alloc, [LDFLAGS="$LDFLAGS -lumem"], [])
AM_CONDITIONAL(SOUND_OSS, false)
AM_CONDITIONAL(SOUND_SDL, false)
AM_CONDITIONAL(SOUND_NULL, false)
dnl Check for ALSA 1.x, OSS, or PulseAudio
AC_ARG_ENABLE(sound, [ --enable-sound=... force selection of sound backend (alsa/null/oss/pulseaudio/sdl) (default: sdl)],
[ SOUND="$enableval" ],[ SOUND="sdl" ])
if test "x$SOUND" = xalsa; then
PKG_CHECK_MODULES(ALSA, alsa >= 1.0.0, have_alsa=yes, have_alsa=no)
elif test "x$SOUND" = xpulseaudio; then
PKG_CHECK_MODULES(PULSEAUDIO, libpulse >= 0.9.16, have_pulseaudio=yes)
elif test "x$SOUND" = xoss; then
AC_CHECK_HEADER(sys/soundcard.h, have_oss=yes, have_oss=no)
if test "x$have_oss" = xno; then
AC_MSG_ERROR([sys/soundcard.h not found!])
else
AM_CONDITIONAL(SOUND_OSS, true)
fi
elif test "x$SOUND" = xno; then
AM_CONDITIONAL(SOUND_NULL, true)
elif test "x$SOUND" = xnull; then
AM_CONDITIONAL(SOUND_NULL, true)
else
AM_CONDITIONAL(SOUND_SDL, true)
fi
AM_CONDITIONAL(SOUND_ALSA, test "x$have_alsa" = xyes)
AC_SUBST(ALSA_LIBS)
AM_CONDITIONAL(SOUND_PULSEAUDIO, test "x$have_pulseaudio" = xyes)
AC_SUBST(PULSEAUDIO_CFLAGS)
AC_SUBST(PULSEAUDIO_LIBS)
AC_CHECK_HEADER(zlib.h, have_zlib=yes, have_zlib=no)
if test "x$have_zlib" = xno; then
AC_MSG_ERROR([unable to find libz headers])
fi
AC_CHECK_HEADER(X11/extensions/Xv.h, have_xv=yes, have_xv=no)
if test "x$have_xv" = xno; then
AC_MSG_ERROR([unable to find xv headers])
fi
AC_CHECK_HEADER(X11/extensions/XTest.h, have_xtest=yes, have_xtest=no)
if test "x$have_xtest" = xno; then
AC_MSG_ERROR([unable to find xtest headers])
fi
AM_CONDITIONAL(USE_LIBCDIO, false)
AC_ARG_ENABLE(libcdio, [ --enable-libcdio use GNU libcdio for CD-ROM support (default=no)],
[ BUILD_LIBCDIO="$enableval" ],[ BUILD_LIBCDIO="no" ])
if test "$BUILD_LIBCDIO" = "yes"; then
PKG_CHECK_MODULES(LIBCDIO, libcdio, [], AC_MSG_ERROR([*** libcdio not found!]))
AM_CONDITIONAL(USE_LIBCDIO, true)
fi
AC_SUBST(LIBCDIO_CFLAGS)
AC_SUBST(LIBCDIO_LIBS)
AC_ARG_ENABLE(opengl, [ --enable-opengl build OpenGL plugin (default=no)],
[ BUILD_OPENGL="$enableval" ],[ BUILD_OPENGL="no" ])
PEOPSXGL=""
if test "$BUILD_OPENGL" = "yes"; then
AC_CHECK_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
if test "x$have_gl" = xno; then
AC_MSG_ERROR([unable to find OpenGL headers])
fi
AC_CHECK_HEADER(GL/glx.h, have_glx=yes, have_glx=no)
if test "x$have_glx" = xno; then
AC_MSG_ERROR([unable to find GLX headers])
fi
AC_CHECK_HEADER(X11/extensions/xf86vmode.h, have_vmode=yes, have_vmode=no,
[[#include <GL/gl.h>
#include <GL/glx.h>
]])
if test "x$have_vmode" = xno; then
AC_MSG_ERROR([unable to find xf86vmode headers])
fi
PEOPSXGL="plugins/peopsxgl"
AC_SUBST(PEOPSXGL)
AC_CONFIG_FILES([plugins/peopsxgl/Makefile])
fi
AM_CONDITIONAL(X86_NASM, false)
if expr x"$target_cpu" : 'xi.86' > /dev/null; then
if expr x"$target_os" : 'x.*linux.*' > /dev/null; then
AC_PATH_PROG([NASM],[nasm],[missing])
if test "$NASM" = "missing"; then
AC_MSG_WARN([unable to find nasm, needed to build dfx11video])
AM_CONDITIONAL(X86_NASM, false)
else
AM_CONDITIONAL(X86_NASM, true)
fi
fi
fi
AM_CONDITIONAL(ARCH_X86, false)
AM_CONDITIONAL(ARCH_X86_64, false)
AM_CONDITIONAL(ARCH_PPC, false)
AC_ARG_ENABLE(dynarec, [ --enable-dynarec=... force selection of dynamic recompiler platform (auto/no/x86/x86_64/ppc) (default: auto)],
[ DYNAREC="$enableval" ],[ DYNAREC="auto" ])
if test "x$DYNAREC" = xauto; then
DYNARECSEL="auto"
else if test "x$DYNAREC" = xx86; then
DYNARECSEL="x86"
else if test "x$DYNAREC" = xx86_64; then
DYNARECSEL="x86_64"
else if test "x$DYNAREC" = xppc; then
DYNARECSEL="ppc"
else if test "x$DYNAREC" = xno; then
DYNARECSEL="no"
else
AC_MSG_WARN([Dynamic Recompiler "$DYNAREC" not found. Autodetecting...])
DYNARECSEL="auto"
fi
fi
fi
fi
fi
if test "x$DYNARECSEL" = xauto; then
if expr x"$target_cpu" : 'xi.86' > /dev/null; then
DYNARECSEL="x86"
fi
if expr x"$target_cpu" : 'xx86_64' > /dev/null; then
DYNARECSEL="x86_64"
fi
if expr x"$target_cpu" : 'xpowerpc' > /dev/null; then
DYNARECSEL="ppc"
fi
fi
if test "x$DYNARECSEL" = xno; then
AC_DEFINE([NOPSXREC], [1], [Define if we are compiling without dynamic recompiler.])
fi
if test "x$DYNARECSEL" = xx86; then
AC_DEFINE([__i386__], [1], [Define if we are compiling for x86 architectures.])
AM_CONDITIONAL(ARCH_X86, true)
AC_MSG_RESULT([Dynamic Recompiler selected: x86])
fi
if test "x$DYNARECSEL" = xx86_64; then
AC_DEFINE([__x86_64__], [1], [Define if we are compiling for x86_64 architectures.])
AM_CONDITIONAL(ARCH_X86_64, true)
dnl CFLAGS+=" -m64 "
dnl AC_COMPILE_IFELSE(AC_LANG_PROGRAM,,AC_MSG_ERROR([Cannot compile with -m64]))
AC_MSG_RESULT([Dynamic Recompiler selected: x86_64])
fi
if test "x$DYNARECSEL" = xppc; then
AC_DEFINE([__ppc__], [1], [Define if we are compiling for powerpc architectures.])
AM_CONDITIONAL(ARCH_PPC, true)
AC_MSG_RESULT([Dynamic Recompiler selected: ppc])
fi
AC_C_BIGENDIAN(AC_DEFINE([__BIGENDIAN__],[],[define on a big endian system]))
AC_DEFINE([__LINUX__], [1], [Define if building on a GNU/Linux system.])
AC_DEFINE([MAXPATHLEN], [4096], [Define to the maximum length of any path.])
AC_OUTPUT

7
data/Makefile.am Normal file
View File

@ -0,0 +1,7 @@
glade_DATA = pcsx.glade2
gladedir = $(datadir)/pcsx
desktopdir = $(datadir)/applications
desktop_DATA = pcsx.desktop
EXTRA_DIST = $(glade_DATA) pcsx.desktop

424
data/Makefile.in Normal file
View File

@ -0,0 +1,424 @@
# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = data
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(desktopdir)" "$(DESTDIR)$(gladedir)"
desktopDATA_INSTALL = $(INSTALL_DATA)
gladeDATA_INSTALL = $(INSTALL_DATA)
DATA = $(desktop_DATA) $(glade_DATA)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALSA_CFLAGS = @ALSA_CFLAGS@
ALSA_LIBS = @ALSA_LIBS@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
GLADE2_CFLAGS = @GLADE2_CFLAGS@
GLADE2_LIBS = @GLADE2_LIBS@
GLIB2_CFLAGS = @GLIB2_CFLAGS@
GLIB2_LIBS = @GLIB2_LIBS@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GREP = @GREP@
GTK2_CFLAGS = @GTK2_CFLAGS@
GTK2_LIBS = @GTK2_LIBS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBCDIO_CFLAGS = @LIBCDIO_CFLAGS@
LIBCDIO_LIBS = @LIBCDIO_LIBS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NASM = @NASM@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PEOPSXGL = @PEOPSXGL@
PKG_CONFIG = @PKG_CONFIG@
POSUB = @POSUB@
PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@
PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@
RANLIB = @RANLIB@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_LIBS = @SDL_LIBS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
glade_DATA = pcsx.glade2
gladedir = $(datadir)/pcsx
desktopdir = $(datadir)/applications
desktop_DATA = pcsx.desktop
EXTRA_DIST = $(glade_DATA) pcsx.desktop
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu data/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu data/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-desktopDATA: $(desktop_DATA)
@$(NORMAL_INSTALL)
test -z "$(desktopdir)" || $(MKDIR_P) "$(DESTDIR)$(desktopdir)"
@list='$(desktop_DATA)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(desktopDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(desktopdir)/$$f'"; \
$(desktopDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(desktopdir)/$$f"; \
done
uninstall-desktopDATA:
@$(NORMAL_UNINSTALL)
@list='$(desktop_DATA)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(desktopdir)/$$f'"; \
rm -f "$(DESTDIR)$(desktopdir)/$$f"; \
done
install-gladeDATA: $(glade_DATA)
@$(NORMAL_INSTALL)
test -z "$(gladedir)" || $(MKDIR_P) "$(DESTDIR)$(gladedir)"
@list='$(glade_DATA)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(gladeDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(gladedir)/$$f'"; \
$(gladeDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(gladedir)/$$f"; \
done
uninstall-gladeDATA:
@$(NORMAL_UNINSTALL)
@list='$(glade_DATA)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(gladedir)/$$f'"; \
rm -f "$(DESTDIR)$(gladedir)/$$f"; \
done
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(DATA)
installdirs:
for dir in "$(DESTDIR)$(desktopdir)" "$(DESTDIR)$(gladedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-desktopDATA install-gladeDATA
install-dvi: install-dvi-am
install-exec-am:
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-desktopDATA uninstall-gladeDATA
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-desktopDATA install-dvi \
install-dvi-am install-exec install-exec-am install-gladeDATA \
install-html install-html-am install-info install-info-am \
install-man install-pdf install-pdf-am install-ps \
install-ps-am install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am uninstall uninstall-am uninstall-desktopDATA \
uninstall-gladeDATA
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

14
data/pcsx.desktop Normal file
View File

@ -0,0 +1,14 @@
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Name=PCSX
GenericName=PlayStation Emulator
GenericName[zh_CN]=PlayStation
GenericName[zh_TW]=PlayStation
Comment=Sony PlayStation emulator
Comment[zh_CN]=Sony PlayStation
Comment[zh_TW]=Sony PlayStation
Exec=pcsx
Icon=pcsx-icon
Categories=Game;

3376
data/pcsx.glade2 Normal file

File diff suppressed because it is too large Load Diff

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
pcsxr (2:1.9.92-1) unstable; urgency=low
* Initial Release.
-- Wei Mingzhi <whistler_wmz@users.sf.net> Fri, 15 Sep 2009 21:15:32 +0800

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
5

20
debian/control vendored Normal file
View File

@ -0,0 +1,20 @@
Source: pcsxr
Section: otherosfs
Priority: extra
Maintainer: Wei Mingzhi <whistler@openoffice.org>
Build-Depends: debhelper (>= 5), libgtk2.0-dev, libglade2-dev, zlib1g-dev | libz-dev, libxv-dev, libxtst-dev, nasm, libgl1-mesa-dev, libxxf86vm-dev, libsdl1.2-dev
Standards-Version: 3.7.3
Package: pcsxr
Architecture: any
Depends: ${shlibs:Depends}
Replaces: pcsx, pcsx-bin, pcsx-i18n, psemu-drive-cdrmooby, psemu-input-omnijoy, psemu-input-padjoy, psemu-sound-alsa, psemu-sound-oss, psemu-video-x11, pcsx-df
Conflicts: pcsx (<= 1:1.699df-rc3-1), pcsx-bin (<= 1:1.699df-rc3-1), pcsx-i18n (<= 1:1.699df-rc3-1), pcsx-df (<= 1:1.999)
Description: Sony PlayStation emulator -- binary
PCSX is an advanced PlayStation (PSX) emulator, which uses a plugin
architecture to provide full support for all components of the PSX.
It has full emulation support for gamepads, videos, sound, memory cards,
and other important PSX components, and is able to play many games
without problems.
.
This package provides the main PCSX binary, library, and support files.

61
debian/copyright vendored Normal file
View File

@ -0,0 +1,61 @@
This package was debianized by Wei Mingzhi <whistler@openoffice.org> on
Fri, 16 Jan 2009 13:32:52 +0800.
It was downloaded from <http://www.codeplex.com/pcsxr>
Upstream Authors:
PCSX-Reloaded:
Wei Mingzhi <weimingzhi@gmail.com>
PCSX-df:
Stephen Chao <stephen@digitalnexus.org>
Ryan Schultz <schultz.ryan@gmail.com>
Andrew Burton <adb@iinet.net.au>
Stefan Sikora <hoshy@schrauberstube.de>
Marcus Comstedt <marcus@mc.pp.se>
PCSX Team
Linuzappz <linuzappz@pcsx.net>
Shadow <shadow@pcsx.net>
Pete Bernett <psswitch@online.de>
NoComp <NoComp@mailcity.com>
Nik3d
Akumax <akumax@pcsx.net>
Copyright: (C) 2008-2009 Wei Mingzhi
(C) 2005-2007 Ryan Schultz
(C) 2005-2007 Andrew Burton
(C) 2007 Stephen Chao
(C) 2007 Stefan Sikora
(C) 1999-2003 Pcsx Team
(C) 1998 Vision Thing
License:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA
02111-1307 USA.
On Debian GNU/Linux systems, the complete text of the GNU General
Public License can be found in `/usr/share/common-licenses/GPL'.
The file 'PSEmu_Plugin_Defs.h' is released to the public domain, contrary
to its headers. This is an excerpt from a forum, by Pete Bernert (who wrote
many of the plugins and was a PCSX contributor):
"The "PSEmu Plugin Def.h" header file is very old (1998) and (as you
have noticed) contains just a few basic defines. When PSemu Pro died in
early 1999, and new psx emus showed up, the Vision Thing crew allowed
free usage/enhancements of the interface. Sure, nobody ever updated the
header file to state something new, but Duddie gave his agreement, as
well as Kazz with his XA audio defines (used in the spu plugin
interface). So, there is nothing to worry about using the headers."

5
debian/docs vendored Normal file
View File

@ -0,0 +1,5 @@
doc/keys.txt
doc/tweaks.txt
README
NEWS
ChangeLog.df

5
debian/pcsxr.menu vendored Normal file
View File

@ -0,0 +1,5 @@
?package(pcsxr): \
needs="X11" \
section="Applications/Emulators" \
title="PCSX PlayStation Emulator" \
command="/usr/games/pcsx"

75
debian/rules vendored Executable file
View File

@ -0,0 +1,75 @@
#!/usr/bin/make -f
# -*- makefile -*-
#export DH_VERBOSE=1
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2 -fomit-frame-pointer
endif
CONFIGURE_PARAM = \
--host=$(DEB_HOST_GNU_TYPE) \
--build=$(DEB_BUILD_GNU_TYPE) \
--prefix=/usr \
--bindir=/usr/games \
--mandir=\$${prefix}/share/man \
--infodir=\$${prefix}/share/info \
--enable-opengl
config.status: configure
dh_testdir
CFLAGS="$(CFLAGS)" ./configure $(CONFIGURE_PARAM)
build: build-stamp
build-stamp: config.status
dh_testdir
$(MAKE)
touch build-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp
[ ! -f Makefile ] || make distclean
dh_clean config.status config.log po/stamp-po
install: build
dh_testdir
dh_testroot
dh_installdirs
$(MAKE) install DESTDIR=$(CURDIR)/debian/pcsxr
# Remove useless files
rm -f $(CURDIR)/debian/pcsxr/usr/lib/games/psemu/*.la
binary-indep: build install
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs ChangeLog
dh_installdocs
dh_installmenu
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_makeshlibs
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

589
depcomp Executable file
View File

@ -0,0 +1,589 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2007-03-29.01
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
# Add `dependent.h:' lines.
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mechanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

3
doc/Makefile.am Normal file
View File

@ -0,0 +1,3 @@
EXTRA_DIST = keys.txt tweaks.txt
man_MANS = pcsx.1

426
doc/Makefile.in Normal file
View File

@ -0,0 +1,426 @@
# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = doc
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
man1dir = $(mandir)/man1
am__installdirs = "$(DESTDIR)$(man1dir)"
NROFF = nroff
MANS = $(man_MANS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALSA_CFLAGS = @ALSA_CFLAGS@
ALSA_LIBS = @ALSA_LIBS@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
GLADE2_CFLAGS = @GLADE2_CFLAGS@
GLADE2_LIBS = @GLADE2_LIBS@
GLIB2_CFLAGS = @GLIB2_CFLAGS@
GLIB2_LIBS = @GLIB2_LIBS@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GREP = @GREP@
GTK2_CFLAGS = @GTK2_CFLAGS@
GTK2_LIBS = @GTK2_LIBS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBCDIO_CFLAGS = @LIBCDIO_CFLAGS@
LIBCDIO_LIBS = @LIBCDIO_LIBS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NASM = @NASM@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PEOPSXGL = @PEOPSXGL@
PKG_CONFIG = @PKG_CONFIG@
POSUB = @POSUB@
PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@
PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@
RANLIB = @RANLIB@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_LIBS = @SDL_LIBS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = keys.txt tweaks.txt
man_MANS = pcsx.1
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu doc/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-man1: $(man1_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $$i; then file=$$i; \
else file=$(srcdir)/$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
done
uninstall-man1:
@$(NORMAL_UNINSTALL)
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
done
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(MANS)
installdirs:
for dir in "$(DESTDIR)$(man1dir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-man
install-dvi: install-dvi-am
install-exec-am:
install-html: install-html-am
install-info: install-info-am
install-man: install-man1
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-man
uninstall-man: uninstall-man1
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-man1 \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
uninstall uninstall-am uninstall-man uninstall-man1
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

19
doc/keys.txt Normal file
View File

@ -0,0 +1,19 @@
You should configure the PSX Input plugin -- it supports gamepads, joysticks,
and keyboards, and will work with any of those that are recognized as input
devices by your OS.
There are also some quick keyboard commands to access emulator functions:
F1: Save state
F2: Switch to next save slot
F3: Load state
F4: Display state screenshot
F5: Toggle SIO IRQ
F6: Toggle Black & White decoders
F7: Toggle XA
F8: Take a game screenshot
ESC: Return to the main window
Ctrl 1 to 5: Save state 1 to 5
Alt 1 to 5: Load state 1 to 5
Alt 0: Load state from last ESC quit

35
doc/pcsx.1 Normal file
View File

@ -0,0 +1,35 @@
.\" Hey, EMACS: -*- nroff -*-
.TH PCSX 1 "October 01, 2005"
.SH NAME
pcsx - Playstation emulator
.SH SYPNOSIS
.B pcsx
.I [options] [file]
.SH DESCRIPTION
PCSX is a plugin-based Playstation emulator able to play most PSX games. It provides CPU, BIOS, and basic system emulation and relies on plugins for sound, input, and graphics emulation.
.PP
.SH OPTIONS
.B -runcd
Runs CD-ROM from drive
.TP
.B -cdfile FILE
Runs a CD image file
.TP
.B -nogui
Don't load the GUI
.TP
.B -cfg FILE
Specify a different config file
.TP
.B -psxout
Enable PSX output
.TP
.B -load STATENUM
Loads savestate STATENUM
.TP
.B -help (-h)
Display help message
.TP
.SH AUTHOR
pcsx was written by Linuzappz <linuzappz@pcsx.net>. PCSX-df was written by Ryan Schultz <schultz.ryan@gmail.com> and Andrew Burton <adb@iinet.net.au>.
This manual page was written by Ryan Schultz <schultz.ryan@gmail.com> for the Debian Project.

25
doc/tweaks.txt Normal file
View File

@ -0,0 +1,25 @@
There are several toggles in PCSX to allow you to modify emulation
behavior; this may allow certain games to work that would not otherwise
function. These can all be found at Configuration -> CPU.
* Disable XA Decoding:
Disables XA sound, which can improve game speed.
* SIO IRQ Always Enabled:
This should be enabled for certain memcards/gamepads.
* SPU IRQ Always Enabled:
Compatibility tweak; should probably be left off.
* Black & White Movies:
Allows movies to be shown faster on slower systems.
* Disable CD Audio:
Disable CD Audio for a performance boost.
* Enable Console Output:
Dumps the PSX emulator output to the console.
* Enable Interpreter CPU:
Enables interpretive emulation.
This is often more compatible, but at the price of emulation speed.

109
gui/AboutDlg.c Normal file
View File

@ -0,0 +1,109 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#include "Linux.h"
#include <gtk/gtk.h>
#if GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION < 12
#define gtk_about_dialog_set_program_name gtk_about_dialog_set_name
#endif
#define ABOUT_VERSION "1.9.92"
void RunAboutDialog(void) {
GtkWidget *AboutDlg;
const gchar *authors[] = {
"PCSX-Reloaded Team:",
"edgbla <edgbla@yandex.ru>",
"Wei Mingzhi <whistler_wmz@users.sf.net>",
"",
"Contributors:",
"Dario",
"Firnis",
"Gabriele Gorla",
"Peter Collingbourne",
"shalma",
"Tristin Celestin",
"(See the included AUTHORS file for more details.)",
"",
"PCSX-df Team:",
"Ryan Schultz <schultz.ryan@gmail.com>",
"Andrew Burton <adb@iinet.net.au>",
"Stephen Chao <stephen@digitalnexus.org>",
"Stefan Sikora <hoshy[AT]schrauberstube.de>",
"",
"PCSX Team:",
"Linuzappz <linuzappz@hotmail.com>",
"Shadow",
"Pete Bernert",
"NoComp",
"Nik3d",
NULL
};
const gchar *artists[] = {
"Ryan Schultz <schultz.ryan@gmail.com>",
"",
"Icon Design:",
"Romain Lafourcade",
NULL
};
const gchar *documenters[] = {
"Ryan Schultz <schultz.ryan@gmail.com>",
NULL
};
const gchar *copyright = N_(
"(C) 1999-2003 PCSX Team\n"
"(C) 2005-2009 PCSX-df Team\n"
"(C) 2009-2010 PCSX-Reloaded Team");
const gchar *license = N_(
"This program is free software; you can redistribute it and/or modify "
"it under the terms of the GNU General Public License as published by "
"the Free Software Foundation; either version 2 of the License, or "
"(at your option) any later version.\n"
"\n"
"This program is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License "
"along with this program; if not, write to the Free Software "
"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA.");
AboutDlg = gtk_about_dialog_new();
gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(AboutDlg), "PCSX-Reloaded");
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(AboutDlg), ABOUT_VERSION);
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(AboutDlg), "http://pcsxr.codeplex.com/");
gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(AboutDlg), "http://pcsxr.codeplex.com/");
gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(AboutDlg), authors);
gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(AboutDlg), _(copyright));
gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(AboutDlg), documenters);
gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(AboutDlg), artists);
gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(AboutDlg), _("translator-credits"));
gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG (AboutDlg), _("A PlayStation emulator."));
gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(AboutDlg), _(license));
gtk_about_dialog_set_wrap_license(GTK_ABOUT_DIALOG(AboutDlg), TRUE);
gtk_dialog_run(GTK_DIALOG(AboutDlg));
gtk_widget_destroy(AboutDlg);
}

24
gui/AboutDlg.h Normal file
View File

@ -0,0 +1,24 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#ifndef ABOUTDLG_H
#define ABOUTDLG_H
void RunAboutDialog(void);
#endif

1176
gui/Cheat.c Normal file

File diff suppressed because it is too large Load Diff

25
gui/Cheat.h Normal file
View File

@ -0,0 +1,25 @@
/* Cheat Support for PCSX-Reloaded
* Copyright (C) 2009, Wei Mingzhi <whistler@openoffice.org>.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#ifndef GUI_CHEAT_H
#define GUI_CHEAT_H
void RunCheatListDialog();
void RunCheatSearchDialog();
#endif

889
gui/ConfDlg.c Normal file
View File

@ -0,0 +1,889 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <dirent.h>
#include <dlfcn.h>
#include <sys/stat.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <signal.h>
#include <sys/time.h>
#include <regex.h>
#include "Linux.h"
#include "ConfDlg.h"
#include "../libpcsxcore/plugins.h"
static void OnBiosPath_Changed(GtkWidget *wdg, gpointer data);
static void OnConf_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data);
static void OnPluginPath_Changed(GtkWidget *wdg, gpointer data);
static void OnConfConf_Pad1About(GtkWidget *widget, gpointer user_data);
static void OnConfConf_Pad2About(GtkWidget *widget, gpointer user_data);
static void OnConfConf_Pad1Conf(GtkWidget *widget, gpointer user_data);
static void OnConfConf_Pad2Conf(GtkWidget *widget, gpointer user_data);
static void OnNet_Conf(GtkWidget *widget, gpointer user_data);
static void OnNet_About(GtkWidget *widget, gpointer user_data);
static void on_configure_plugin(GtkWidget *widget, gpointer user_data);
static void on_about_plugin(GtkWidget *widget, gpointer user_data);
static void UpdatePluginsBIOS_UpdateGUI(GladeXML *xml);
static void FindNetPlugin(GladeXML *xml);
PSEgetLibType PSE_getLibType = NULL;
PSEgetLibVersion PSE_getLibVersion = NULL;
PSEgetLibName PSE_getLibName = NULL;
GtkWidget *ConfDlg = NULL;
GtkWidget *NetDlg = NULL;
GtkWidget *controlwidget = NULL;
PluginConf GpuConfS;
PluginConf SpuConfS;
PluginConf CdrConfS;
PluginConf Pad1ConfS;
PluginConf Pad2ConfS;
PluginConf NetConfS;
PluginConf BiosConfS;
#define FindComboText(combo, list, conf) \
if (strlen(conf) > 0) { \
int i; \
for (i = 2; i < 255; i += 2) { \
if (!strcmp(conf, list[i - 2])) { \
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i / 2 - 1); \
break; \
} \
} \
}
#define GetComboText(combo, list, conf) \
{ \
int row; \
row = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)); \
strcpy(conf, (char *)list[row * 2]); \
}
void ConfigurePlugins() {
if (!UseGui) {
/* How do we get here if we're not running the GUI? */
/* Ryan: we're going to imagine that someday, there will be a way
* to configure plugins from the commandline */
printf("ERROR: Plugins cannot be configured without the GUI.");
return;
}
GladeXML *xml;
GtkWidget *widget;
gchar *path;
UpdatePluginsBIOS();
xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "ConfDlg", NULL);
if (!xml) {
g_warning(_("Error: Glade interface could not be loaded!"));
return;
}
UpdatePluginsBIOS_UpdateGUI(xml);
ConfDlg = glade_xml_get_widget(xml, "ConfDlg");
gtk_window_set_title(GTK_WINDOW(ConfDlg), _("Configure PCSX"));
/* Set the paths in the file choosers to be based on the saved configurations */
widget = glade_xml_get_widget(xml, "GtkFileChooser_Bios");
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget), Config.BiosDir);
widget = glade_xml_get_widget(xml, "GtkFileChooser_Plugin");
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget), Config.PluginsDir);
if (strlen(Config.PluginsDir) == 0) {
if((path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget))) != NULL) {
strcpy(Config.PluginsDir, path);
g_free(path);
}
}
widget = glade_xml_get_widget(xml, "btn_ConfGpu");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(on_configure_plugin), (gpointer) PSE_LT_GPU, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_ConfSpu");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(on_configure_plugin), (gpointer) PSE_LT_SPU, NULL, G_CONNECT_AFTER);
/* ADB TODO Does pad 1 and 2 need to be different? */
widget = glade_xml_get_widget(xml, "btn_ConfPad1");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnConfConf_Pad1Conf), xml, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_ConfPad2");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnConfConf_Pad2Conf), xml, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_ConfCdr");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(on_configure_plugin), (gpointer) PSE_LT_CDR, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_AboutGpu");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(on_about_plugin), (gpointer) PSE_LT_GPU, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_AboutSpu");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(on_about_plugin), (gpointer) PSE_LT_SPU, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_AboutPad1");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnConfConf_Pad1About), xml, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_AboutPad2");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnConfConf_Pad2About), xml, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_AboutCdr");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(on_about_plugin), (gpointer) PSE_LT_CDR, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkFileChooser_Bios");
g_signal_connect_data(GTK_OBJECT(widget), "current_folder_changed",
GTK_SIGNAL_FUNC(OnBiosPath_Changed), xml, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkFileChooser_Plugin");
g_signal_connect_data(GTK_OBJECT(widget), "current_folder_changed",
GTK_SIGNAL_FUNC(OnPluginPath_Changed), xml, NULL, G_CONNECT_AFTER);
g_signal_connect_data(GTK_OBJECT(ConfDlg), "response",
GTK_SIGNAL_FUNC(OnConf_Clicked), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
}
void OnNet_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data) {
GetComboText(NetConfS.Combo, NetConfS.plist, Config.Net);
SaveConfig();
gtk_widget_destroy(GTK_WIDGET(dialog));
NetDlg = NULL;
}
void OnConf_Net() {
GladeXML *xml;
GtkWidget *widget;
if (NetDlg != NULL) {
gtk_window_present (GTK_WINDOW (NetDlg));
return;
}
xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "NetDlg", NULL);
if (!xml) {
g_warning(_("Error: Glade interface could not be loaded!"));
return;
}
NetDlg = glade_xml_get_widget(xml, "NetDlg");
FindNetPlugin(xml);
/* Setup a handler for when Close or Cancel is clicked */
g_signal_connect_data(GTK_OBJECT(NetDlg), "response",
GTK_SIGNAL_FUNC(OnNet_Clicked), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_ConfNet");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnNet_Conf), xml, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_AboutNet");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnNet_About), xml, NULL, G_CONNECT_AFTER);
}
void OnConf_Graphics() {
void *drv;
GPUconfigure conf;
char Plugin[MAXPATHLEN];
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Gpu);
drv = SysLoadLibrary(Plugin);
if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
while (gtk_events_pending()) gtk_main_iteration();
conf = (GPUconfigure)SysLoadSym(drv, "GPUconfigure");
if (conf != NULL) {
conf();
}
else
SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
SysCloseLibrary(drv);
}
void OnConf_Sound() {
void *drv;
SPUconfigure conf;
char Plugin[MAXPATHLEN];
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Spu);
drv = SysLoadLibrary(Plugin);
if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
while (gtk_events_pending()) gtk_main_iteration();
conf = (GPUconfigure)SysLoadSym(drv, "SPUconfigure");
if (conf != NULL) {
conf();
}
else
SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
SysCloseLibrary(drv);
}
void OnConf_CdRom() {
void *drv;
CDRconfigure conf;
char Plugin[MAXPATHLEN];
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr);
drv = SysLoadLibrary(Plugin);
if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
while (gtk_events_pending()) gtk_main_iteration();
conf = (GPUconfigure)SysLoadSym(drv, "CDRconfigure");
if (conf != NULL) {
conf();
}
else
SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
SysCloseLibrary(drv);
}
void OnConf_Pad() {
void *drv;
PADconfigure conf;
char Plugin[MAXPATHLEN];
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad1);
drv = SysLoadLibrary(Plugin);
if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
while (gtk_events_pending()) gtk_main_iteration();
conf = (GPUconfigure)SysLoadSym(drv, "PADconfigure");
if (conf != NULL) {
conf();
}
else
SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured."));
SysCloseLibrary(drv);
if (strcmp(Config.Pad1, Config.Pad2) != 0) {
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad2);
drv = SysLoadLibrary(Plugin);
if (drv == NULL) { printf("Error with file %s\n", Plugin); return; }
while (gtk_events_pending()) gtk_main_iteration();
conf = (GPUconfigure)SysLoadSym(drv, "PADconfigure");
if (conf != NULL) {
conf();
}
SysCloseLibrary(drv);
}
}
static int all_config_set() {
int retval;
if ((strlen(Config.Gpu) != 0) &&
(strlen(Config.Spu) != 0) &&
(strlen(Config.Cdr) != 0) &&
(strlen(Config.Pad1) != 0) &&
(strlen(Config.Pad2) != 0))
retval = TRUE;
else
retval = FALSE;
return retval;
}
/* TODO Check whether configuration is required when we choose the plugin, and set the state of the
button appropriately. New gtk tooltip API should allow us to put a tooltip explanation for
disabled widgets */
/* TODO If combo screen hasn't been opened and the user chooses the menu config option, confs.Combo will be null and cause a segfault */
#define ConfPlugin(src, confs, plugin, name, parent) { \
void *drv; \
src conf; \
gchar *filename; \
\
GetComboText(confs.Combo, confs.plist, plugin); \
filename = g_build_filename (getenv("HOME"), PLUGINS_DIR, plugin, NULL); \
/*printf("Configuring plugin %s\n", filename);*/ \
drv = SysLoadLibrary(filename); \
if (drv == NULL) {printf("Error with file %s\n", filename);return; } \
\
while (gtk_events_pending()) gtk_main_iteration(); \
conf = (src) SysLoadSym(drv, name); \
if (conf) { \
conf(); \
} else \
SysInfoMessage (_("No configuration required"), _("This plugin doesn't need to be configured.")); \
SysCloseLibrary(drv); \
g_free (filename); \
}
static void on_configure_plugin(GtkWidget *widget, gpointer user_data) {
gint plugin_type = (int) user_data;
while (gtk_events_pending())
gtk_main_iteration();
if (all_config_set() == TRUE) {
switch (plugin_type) {
case PSE_LT_GPU:
ConfPlugin(GPUconfigure, GpuConfS, Config.Gpu, "GPUconfigure", ConfDlg);
break;
case PSE_LT_SPU:
ConfPlugin(SPUconfigure, SpuConfS, Config.Spu, "SPUconfigure", ConfDlg);
break;
case PSE_LT_CDR:
ConfPlugin(CDRconfigure, CdrConfS, Config.Cdr, "CDRconfigure", ConfDlg);
break;
}
} else
ConfigurePlugins();
}
static void on_about_plugin(GtkWidget *widget, gpointer user_data) {
gint plugin_type = (int) user_data;
while (gtk_events_pending())
gtk_main_iteration();
if (all_config_set() == TRUE) {
switch (plugin_type) {
case PSE_LT_GPU:
ConfPlugin(GPUconfigure, GpuConfS, Config.Gpu, "GPUabout", ConfDlg);
break;
case PSE_LT_SPU:
ConfPlugin(SPUconfigure, SpuConfS, Config.Spu, "SPUabout", ConfDlg);
break;
case PSE_LT_CDR:
ConfPlugin(CDRconfigure, CdrConfS, Config.Cdr, "CDRabout", ConfDlg);
break;
}
} else
ConfigurePlugins();
}
static void OnConfConf_Pad1About(GtkWidget *widget, gpointer user_data) {
ConfPlugin(PADabout, Pad1ConfS, Config.Pad1, "PADabout", ConfDlg);
}
static void OnConfConf_Pad2About(GtkWidget *widget, gpointer user_data) {
ConfPlugin(PADabout, Pad2ConfS, Config.Pad2, "PADabout", ConfDlg);
}
static void OnConfConf_Pad1Conf(GtkWidget *widget, gpointer user_data) {
ConfPlugin(PADabout, Pad1ConfS, Config.Pad1, "PADconfigure", ConfDlg);
}
static void OnConfConf_Pad2Conf(GtkWidget *widget, gpointer user_data) {
ConfPlugin(PADabout, Pad2ConfS, Config.Pad2, "PADconfigure", ConfDlg);
}
static void OnNet_Conf(GtkWidget *widget, gpointer user_data) {
ConfPlugin(NETconfigure, NetConfS, Config.Net, "NETconfigure", NetDlg);
}
static void OnNet_About(GtkWidget *widget, gpointer user_data) {
ConfPlugin(NETabout, NetConfS, Config.Net, "NETabout", NetDlg);
}
static void OnPluginPath_Changed(GtkWidget *wdg, gpointer data) {
gchar *path;
path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (wdg));
strcpy(Config.PluginsDir, path);
UpdatePluginsBIOS();
UpdatePluginsBIOS_UpdateGUI(data);
g_free(path);
}
static void OnBiosPath_Changed(GtkWidget *wdg, gpointer data) {
gchar *foldername;
foldername = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (wdg));
strcpy(Config.BiosDir, foldername);
UpdatePluginsBIOS();
UpdatePluginsBIOS_UpdateGUI(data);
g_free(foldername);
}
void OnConf_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data) {
GetComboText(GpuConfS.Combo, GpuConfS.plist, Config.Gpu);
GetComboText(SpuConfS.Combo, SpuConfS.plist, Config.Spu);
GetComboText(CdrConfS.Combo, CdrConfS.plist, Config.Cdr);
GetComboText(Pad1ConfS.Combo, Pad1ConfS.plist, Config.Pad1);
GetComboText(Pad2ConfS.Combo, Pad2ConfS.plist, Config.Pad2);
GetComboText(BiosConfS.Combo, BiosConfS.plist, Config.Bios);
SaveConfig();
gtk_widget_destroy(ConfDlg);
ConfDlg = NULL;
}
#define ComboAddPlugin(type) { \
type##ConfS.plugins += 2; \
strcpy(type##ConfS.plist[type##ConfS.plugins - 1], name); \
strcpy(type##ConfS.plist[type##ConfS.plugins - 2], ent->d_name); \
type##ConfS.glist = g_list_append(type##ConfS.glist, type##ConfS.plist[type##ConfS.plugins-1]); \
}
void populate_combo_box(GtkWidget *widget, GList *list) {
GtkListStore *store;
GtkCellRenderer *renderer;
store = gtk_list_store_new(1, G_TYPE_STRING);
// Clear existing data from combo box
gtk_cell_layout_clear(GTK_CELL_LAYOUT(widget));
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, FALSE);
gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(widget), renderer, "text", 0);
while (list != NULL) {
GtkTreeIter iter;
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, (char *)list->data, -1);
list = list->next;
}
gtk_combo_box_set_model(GTK_COMBO_BOX(widget), GTK_TREE_MODEL(store));
}
#define ConfCreatePConf(name, type) \
/* Populate the relevant combo widget with the list of plugins. \
If no plugins available, disable the combo and its controls. \
Note that the Bios plugin has no About/Conf control. */ \
type##ConfS.Combo = glade_xml_get_widget(xml, "GtkCombo_" name); \
if (type##ConfS.glist != NULL) { \
populate_combo_box (type##ConfS.Combo, type##ConfS.glist); \
FindComboText(type##ConfS.Combo, type##ConfS.plist, Config.type); \
gtk_widget_set_sensitive (type##ConfS.Combo, TRUE); \
if (g_ascii_strcasecmp (name, "Bios") != 0) { \
controlwidget = glade_xml_get_widget(xml, "btn_Conf" name); \
gtk_widget_set_sensitive (controlwidget, TRUE); \
controlwidget = glade_xml_get_widget(xml, "btn_About" name); \
gtk_widget_set_sensitive (controlwidget, TRUE); \
} \
} else { \
if (g_ascii_strcasecmp (name, "Bios") != 0) { \
gtk_cell_layout_clear (GTK_CELL_LAYOUT (type##ConfS.Combo)); \
gtk_widget_set_sensitive (type##ConfS.Combo, FALSE); \
controlwidget = glade_xml_get_widget(xml, "btn_Conf" name); \
gtk_widget_set_sensitive (controlwidget, FALSE); \
controlwidget = glade_xml_get_widget(xml, "btn_About" name); \
gtk_widget_set_sensitive (controlwidget, FALSE); \
} \
}
int plugin_is_available(gchar *plugin) {
int retval;
gchar *pluginfile;
struct stat stbuf;
pluginfile = g_strconcat(getenv("HOME"), PLUGINS_DIR, plugin, NULL);
if (stat(pluginfile, &stbuf) == -1)
retval = FALSE;
else
retval = TRUE;
g_free(pluginfile);
return retval;
}
int plugins_configured() {
// make sure there are choices for all of the plugins!!
if (all_config_set() == FALSE)
return FALSE;
// and make sure they can all be accessed
// if they can't be, wipe the variable and return FALSE
if (plugin_is_available (Config.Gpu) == FALSE) { Config.Gpu[0] = '\0'; return FALSE; }
if (plugin_is_available (Config.Spu) == FALSE) { Config.Spu[0] = '\0'; return FALSE; }
if (plugin_is_available (Config.Cdr) == FALSE) { Config.Cdr[0] = '\0'; return FALSE; }
if (plugin_is_available (Config.Pad1) == FALSE) { Config.Pad1[0] = '\0'; return FALSE; }
if (plugin_is_available (Config.Pad2) == FALSE) { Config.Pad2[0] = '\0'; return FALSE; }
// if everything is happy, return TRUE
return TRUE;
}
int is_valid_bios_file(gchar *filename) {
int valid;
struct stat buf;
if ((stat(filename, &buf) == -1) || (buf.st_size != (1024*512)))
valid = FALSE;
else {
valid = TRUE;
}
return valid;
}
// Add the name of the BIOS file to the drop-down list. This will
// be the filename, not the full path to the file
void add_bios_to_list(gchar *bios_name, gchar *internal_name) {
BiosConfS.plugins += 2;
strcpy(BiosConfS.plist[BiosConfS.plugins - 1], bios_name);
strcpy(BiosConfS.plist[BiosConfS.plugins - 2], internal_name);
BiosConfS.glist = g_list_append(BiosConfS.glist, BiosConfS.plist[BiosConfS.plugins - 1]);
}
void scan_bios_dir(gchar *dirname) {
DIR *dir;
struct dirent *ent;
gchar *filename;
dir = opendir(dirname);
if (dir == NULL) {
SysMessage(_("Could not open BIOS directory: '%s'\n"), dirname);
return;
}
while ((ent = readdir(dir)) != NULL) {
filename = g_build_filename(dirname, ent->d_name, NULL);
if (is_valid_bios_file(filename))
add_bios_to_list(g_path_get_basename(filename), g_path_get_basename (filename));
g_free(filename);
}
closedir(dir);
}
void UpdatePluginsBIOS() {
DIR *dir;
struct dirent *ent;
void *Handle;
char name[256];
gchar *linkname;
GpuConfS.plugins = 0; SpuConfS.plugins = 0; CdrConfS.plugins = 0;
Pad1ConfS.plugins = 0; Pad2ConfS.plugins = 0; BiosConfS.plugins = 0;
GpuConfS.glist = NULL; SpuConfS.glist = NULL; CdrConfS.glist = NULL;
Pad1ConfS.glist = NULL; Pad2ConfS.glist = NULL; BiosConfS.glist = NULL;
GpuConfS.plist[0][0] = '\0'; SpuConfS.plist[0][0] = '\0'; CdrConfS.plist[0][0] = '\0';
Pad1ConfS.plist[0][0] = '\0'; Pad2ConfS.plist[0][0] = '\0'; BiosConfS.plist[0][0] = '\0';
// Load and get plugin info
dir = opendir(Config.PluginsDir);
if (dir == NULL) {
printf(_("Could not open directory: '%s'\n"), Config.PluginsDir);
return;
}
while ((ent = readdir(dir)) != NULL) {
long type, v;
linkname = g_build_filename(Config.PluginsDir, ent->d_name, NULL);
// only libraries past this point, not config tools
if (strstr(linkname, ".so") == NULL && strstr(linkname, ".dylib") == NULL)
continue;
Handle = dlopen(linkname, RTLD_NOW);
if (Handle == NULL) {
printf("%s\n", dlerror());
g_free(linkname);
continue;
}
PSE_getLibType = (PSEgetLibType)dlsym(Handle, "PSEgetLibType");
if (PSE_getLibType == NULL) {
if (strstr(linkname, "gpu") != NULL) type = PSE_LT_GPU;
else if (strstr(linkname, "cdr") != NULL) type = PSE_LT_CDR;
else if (strstr(linkname, "spu") != NULL) type = PSE_LT_SPU;
else if (strstr(linkname, "pad") != NULL) type = PSE_LT_PAD;
else { g_free(linkname); continue; }
}
else type = PSE_getLibType();
PSE_getLibName = (PSEgetLibName) dlsym(Handle, "PSEgetLibName");
if (PSE_getLibName != NULL) {
sprintf(name, "%s", PSE_getLibName());
PSE_getLibVersion = (PSEgetLibVersion) dlsym(Handle, "PSEgetLibVersion");
if (PSE_getLibVersion != NULL) {
char ver[32];
v = PSE_getLibVersion();
sprintf(ver, " %ld.%ld.%ld", v >> 16, (v >> 8) & 0xff, v & 0xff);
strcat(name, ver);
}
}
else strcpy(name, ent->d_name);
if (type & PSE_LT_CDR)
ComboAddPlugin(Cdr);
if (type & PSE_LT_GPU)
ComboAddPlugin(Gpu);
if (type & PSE_LT_SPU)
ComboAddPlugin(Spu);
if (type & PSE_LT_PAD) {
PADquery query = (PADquery)dlsym(Handle, "PADquery");
if (query() & 0x1) {
ComboAddPlugin(Pad1);
}
if (query() & 0x2) {
ComboAddPlugin(Pad2);
}
}
g_free(linkname);
}
closedir(dir);
scan_bios_dir(Config.BiosDir);
// The BIOS list always contains the PCSX internal BIOS
add_bios_to_list(_("Simulate PSX BIOS"), "HLE");
}
static void UpdatePluginsBIOS_UpdateGUI(GladeXML *xml) {
// Populate the plugin combo boxes
ConfCreatePConf("Gpu", Gpu);
ConfCreatePConf("Spu", Spu);
ConfCreatePConf("Pad1", Pad1);
ConfCreatePConf("Pad2", Pad2);
ConfCreatePConf("Cdr", Cdr);
ConfCreatePConf("Bios", Bios);
}
static void FindNetPlugin(GladeXML *xml) {
DIR *dir;
struct dirent *ent;
void *Handle;
char plugin[MAXPATHLEN],name[MAXPATHLEN];
NetConfS.plugins = 0;
NetConfS.glist = NULL;
NetConfS.plugins += 2;
strcpy(NetConfS.plist[NetConfS.plugins - 1], "Disabled");
strcpy(NetConfS.plist[NetConfS.plugins - 2], "Disabled");
NetConfS.glist = g_list_append(NetConfS.glist, NetConfS.plist[NetConfS.plugins - 1]);
dir = opendir(Config.PluginsDir);
if (dir == NULL)
SysMessage(_("Could not open directory: '%s'\n"), Config.PluginsDir);
else {
/* ADB TODO Replace the following with a function */
while ((ent = readdir(dir)) != NULL) {
long type, v;
sprintf(plugin, "%s/%s", Config.PluginsDir, ent->d_name);
if (strstr(plugin, ".so") == NULL && strstr(plugin, ".dylib") == NULL)
continue;
Handle = dlopen(plugin, RTLD_NOW);
if (Handle == NULL) continue;
PSE_getLibType = (PSEgetLibType) dlsym(Handle, "PSEgetLibType");
if (PSE_getLibType == NULL) {
if (strstr(plugin, "net") != NULL) type = PSE_LT_NET;
else continue;
}
else type = PSE_getLibType();
PSE_getLibName = (PSEgetLibName) dlsym(Handle, "PSEgetLibName");
if (PSE_getLibName != NULL) {
sprintf(name, "%s", PSE_getLibName());
PSE_getLibVersion = (PSEgetLibVersion) dlsym(Handle, "PSEgetLibVersion");
if (PSE_getLibVersion != NULL) {
char ver[32];
v = PSE_getLibVersion();
sprintf(ver, " %ld.%ld.%ld",v>>16,(v>>8)&0xff,v&0xff);
strcat(name, ver);
}
}
else strcpy(name, ent->d_name);
if (type & PSE_LT_NET) {
ComboAddPlugin(Net);
}
}
closedir(dir);
ConfCreatePConf("Net", Net);
}
}
GtkWidget *CpuDlg;
GtkWidget *PsxCombo;
GList *psxglist;
char *psxtypes[] = {
"NTSC",
"PAL"
};
// When the auto-detect CPU type is selected, disable the NTSC/PAL selection
static void OnCpu_PsxAutoClicked (GtkWidget *widget, gpointer user_data) {
GtkWidget *combo;
GladeXML *xml = user_data;
combo = glade_xml_get_widget(xml, "GtkCombo_PsxType");
gtk_widget_set_sensitive (combo,
!(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))));
}
// When the interpreter core is deselected, disable the debugger checkbox
static void OnCpu_CpuClicked(GtkWidget *widget, gpointer user_data) {
GtkWidget *check;
GladeXML *xml = user_data;
check = glade_xml_get_widget(xml, "GtkCheckButton_Dbg");
// Debugger is only working with interpreter not recompiler, so let's set it
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), FALSE);
gtk_widget_set_sensitive (check,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
}
void OnCpu_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data) {
GtkWidget *widget;
GladeXML *xml = user_data;
int tmp;
long t;
widget = glade_xml_get_widget(xml, "GtkCombo_PsxType");
// If nothing chosen, default to NTSC
tmp = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
if (tmp == -1)
tmp = PSX_TYPE_NTSC;
if (!strcmp("NTSC", psxtypes[tmp]))
Config.PsxType = PSX_TYPE_NTSC;
else
Config.PsxType = PSX_TYPE_PAL;
Config.Xa = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Xa")));
Config.Sio = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Sio")));
Config.Mdec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Mdec")));
Config.Cdda = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_CDDA")));
Config.PsxAuto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_PsxAuto")));
t = Config.Debug;
Config.Debug = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Dbg")));
if (t != Config.Debug) {
if (Config.Debug) StartDebugger();
else StopDebugger();
}
t = Config.Cpu;
Config.Cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Cpu")));
if (t != Config.Cpu) {
psxCpu->Shutdown();
#ifdef PSXREC
if (Config.Cpu == CPU_INTERPRETER) {
psxCpu = &psxInt;
}
else psxCpu = &psxRec;
#else
psxCpu = &psxInt;
#endif
if (psxCpu->Init() == -1) {
SysClose();
exit(1);
}
psxCpu->Reset();
}
Config.PsxOut = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_PsxOut")));
Config.SpuIrq = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_SpuIrq")));
Config.RCntFix = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_RCntFix")));
Config.VSyncWA = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_VSyncWA")));
SaveConfig();
gtk_widget_destroy(CpuDlg);
CpuDlg = NULL;
}
void OnConf_Cpu() {
GladeXML *xml;
xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "CpuDlg", NULL);
if (!xml) {
g_warning("We could not load the interface!");
return;
}
CpuDlg = glade_xml_get_widget(xml, "CpuDlg");
PsxCombo = glade_xml_get_widget(xml, "GtkCombo_PsxType");
gtk_combo_box_set_active(GTK_COMBO_BOX (PsxCombo), Config.PsxType);
gtk_widget_set_sensitive(GTK_WIDGET (PsxCombo), !Config.PsxAuto);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Xa")), Config.Xa);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Sio")), Config.Sio);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_Mdec")), Config.Mdec);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_CDDA")), Config.Cdda);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_PsxAuto")), Config.PsxAuto);
g_signal_connect_data(GTK_OBJECT(glade_xml_get_widget(xml, "GtkCheckButton_PsxAuto")), "toggled",
GTK_SIGNAL_FUNC(OnCpu_PsxAutoClicked), xml, NULL, G_CONNECT_AFTER);
#ifdef PSXREC
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), Config.Cpu);
g_signal_connect_data(GTK_OBJECT(glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), "toggled",
GTK_SIGNAL_FUNC(OnCpu_CpuClicked), xml, NULL, G_CONNECT_AFTER);
#else
Config.Cpu = CPU_INTERPRETER;
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), FALSE);
#endif
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Dbg")), Config.Cpu && Config.Debug);
gtk_widget_set_sensitive(GTK_WIDGET (glade_xml_get_widget(xml, "GtkCheckButton_Dbg")), Config.Cpu);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_PsxOut")), Config.PsxOut);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_SpuIrq")), Config.SpuIrq);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_RCntFix")), Config.RCntFix);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(glade_xml_get_widget(xml, "GtkCheckButton_VSyncWA")), Config.VSyncWA);
// Setup a handler for when Close or Cancel is clicked
g_signal_connect_data(GTK_OBJECT(CpuDlg), "response",
GTK_SIGNAL_FUNC(OnCpu_Clicked), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
}

50
gui/ConfDlg.h Normal file
View File

@ -0,0 +1,50 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#ifndef CONFDLG_H
#define CONFDLG_H
// Helper Functions
void UpdatePluginsBIOS();
// Functions Callbacks
void OnConf_Graphics();
void OnConf_Sound();
void OnConf_CdRom();
void OnConf_Pad();
void OnConf_Cpu();
void OnConf_Net();
void ConfigurePlugins();
typedef struct {
GtkWidget *Combo;
GList *glist;
char plist[255][255]; /* TODO Comment this out */
int plugins; /* TODO Comment this out and replace with glist count */
} PluginConf;
extern PluginConf GpuConfS;
extern PluginConf SpuConfS;
extern PluginConf CdrConfS;
extern PluginConf Pad1ConfS;
extern PluginConf Pad2ConfS;
extern PluginConf NetConfS;
extern PluginConf BiosConfS;
#endif

180
gui/Config.c Normal file
View File

@ -0,0 +1,180 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "Linux.h"
/* TODO escaping/unescaping would be nice, as would maxchars */
static void GetValue(char *src, char *name, char *outvar) {
char *tmp;
*outvar = 0;
tmp = strstr(src, name);
if (tmp == NULL) return;
tmp += strlen(name);
while ((*tmp == ' ') || (*tmp == '=')) tmp++;
while (*tmp != '\n' && *tmp != 0)
*outvar++ = *tmp++;
*outvar = 0;
return;
}
static long GetValuel(char *src, char *name) {
char *tmp = strstr(src, name);
if (tmp != NULL) {
tmp += strlen(name);
while ((*tmp == ' ') || (*tmp == '=')) tmp++;
if (*tmp != '\n') return atol(tmp);
}
return 0;
}
static boolean GetValueb(char *src, char *name) {
char *tmp = strstr(src, name);
if (tmp != NULL) {
tmp += strlen(name);
while ((*tmp == ' ') || (*tmp == '=')) tmp++;
if (*tmp != '\n') return (atoi(tmp) != 0);
}
return FALSE;
}
#define SetValue(name, var) \
fprintf(f, "%s = %s\n", name, var);
#define SetValuel(name, var) \
fprintf(f, "%s = %x\n", name, var);
#define SetValueb(name, var) \
fprintf(f, "%s = %d\n", name, (var) ? 1 : 0);
int LoadConfig(PcsxConfig *Conf) {
struct stat buf;
FILE *f;
int size;
char *data;
/* TODO local var called cfgfile */
// Ryan says: use dotdir, dotdir is GOOD
// No giant homedir names
strncpy(cfgfile, getenv("HOME"), 200);
strcat(cfgfile, PCSX_DOT_DIR);
// proceed to load the cfg file
// append its name
strcat(cfgfile, cfgfile_basename);
// file is now ~/.pcsx/pcsx.cfg (or whatever cfgfile_basename is)
if (stat(cfgfile, &buf) == -1) {
// the config file doesn't exist!
/* TODO Error checking? */
printf("Configuration file %s couldn't be found\n", cfgfile);
return -1;
}
size = buf.st_size;
/* TODO Error checking for the next two lines, and at least log failures */
f = fopen(cfgfile, "r");
if (f == NULL) return -1;
data = (char *)malloc(size + 1);
if (data == NULL) return -1;
fread(data, 1, buf.st_size, f);
fclose(f);
data[size] = '\0';
GetValue(data, "Bios", Config.Bios);
GetValue(data, "Gpu", Config.Gpu);
GetValue(data, "Spu", Config.Spu);
GetValue(data, "Cdr", Config.Cdr);
GetValue(data, "Pad1", Config.Pad1);
GetValue(data, "Pad2", Config.Pad2);
GetValue(data, "Net", Config.Net);
GetValue(data, "Mcd1", Config.Mcd1);
GetValue(data, "Mcd2", Config.Mcd2);
GetValue(data, "BiosDir", Config.BiosDir);
GetValue(data, "PluginsDir", Config.PluginsDir);
Config.Xa = GetValueb(data, "Xa");
Config.Sio = GetValueb(data, "Sio");
Config.Mdec = GetValueb(data, "Mdec");
Config.PsxAuto = GetValueb(data, "PsxAuto");
Config.Cdda = GetValueb(data, "Cdda");
Config.Debug = GetValueb(data, "Dbg");
Config.PsxOut = GetValueb(data, "PsxOut");
Config.SpuIrq = GetValueb(data, "SpuIrq");
Config.RCntFix = GetValueb(data, "RCntFix");
Config.VSyncWA = GetValueb(data, "VSyncWA");
Config.Cpu = GetValuel(data, "Cpu");
Config.PsxType = GetValuel(data, "PsxType");
free(data);
return 0;
}
void SaveConfig() {
FILE *f;
/* TODO Error checking for the next two lines, and at least log
failures - suggest a file dialog to specify a new file or
create a new file */
f = fopen(cfgfile, "w");
if (f == NULL) return;
SetValue("Bios", Config.Bios);
SetValue("Gpu", Config.Gpu);
SetValue("Spu", Config.Spu);
SetValue("Cdr", Config.Cdr);
SetValue("Net", Config.Net);
SetValue("Pad1", Config.Pad1);
SetValue("Pad2", Config.Pad2);
SetValue("Mcd1", Config.Mcd1);
SetValue("Mcd2", Config.Mcd2);
SetValue("BiosDir", Config.BiosDir);
SetValue("PluginsDir", Config.PluginsDir);
SetValueb("Xa", Config.Xa);
SetValueb("Sio", Config.Sio);
SetValueb("Mdec", Config.Mdec);
SetValueb("PsxAuto", Config.PsxAuto);
SetValueb("Cdda", Config.Cdda);
SetValueb("Dbg", Config.Debug);
SetValueb("PsxOut", Config.PsxOut);
SetValueb("SpuIrq", Config.SpuIrq);
SetValueb("RCntFix", Config.RCntFix);
SetValueb("VSyncWA", Config.VSyncWA);
SetValuel("Cpu", Config.Cpu);
SetValuel("PsxType", Config.PsxType);
fclose(f);
}

312
gui/DebugMemory.c Normal file
View File

@ -0,0 +1,312 @@
/* Memory Viewer/Dumper for PCSX-Reloaded
* Copyright (C) 2010, Wei Mingzhi <whistler_wmz@users.sf.net>.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#include "Linux.h"
#include "../libpcsxcore/psxmem.h"
#include <glade/glade.h>
#define MEMVIEW_MAX_LINES 256
static GtkWidget *MemViewDlg = NULL;
static u32 MemViewAddress = 0;
static void UpdateMemViewDlg() {
s32 start, end;
int i;
char bufaddr[9], bufdata[16][3], buftext[17];
GtkListStore *store = gtk_list_store_new(18, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING);
GtkTreeIter iter;
GtkWidget *widget;
GladeXML *xml;
xml = glade_get_widget_tree(MemViewDlg);
MemViewAddress &= 0x1fffff;
sprintf(buftext, "%.8X", MemViewAddress | 0x80000000);
widget = glade_xml_get_widget(xml, "entry_address");
gtk_entry_set_text(GTK_ENTRY(widget), buftext);
start = MemViewAddress & 0x1ffff0;
end = start + MEMVIEW_MAX_LINES * 16;
if (end > 0x1fffff) end = 0x1fffff;
widget = glade_xml_get_widget(xml, "GtkCList_MemView");
buftext[16] = '\0';
while (start < end) {
sprintf(bufaddr, "%.8X", start | 0x80000000);
for (i = 0; i < 16; i++) {
buftext[i] = psxMs8(start + i);
sprintf(bufdata[i], "%.2X", (u8)buftext[i]);
if ((u8)buftext[i] < 32 || (u8)buftext[i] >= 127)
buftext[i] = '.';
}
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, bufaddr, 1, bufdata[0],
2, bufdata[1], 3, bufdata[2], 4, bufdata[3], 5, bufdata[4],
6, bufdata[5], 7, bufdata[6], 8, bufdata[7], 9, bufdata[8],
10, bufdata[9], 11, bufdata[10], 12, bufdata[11], 13, bufdata[12],
14, bufdata[13], 15, bufdata[14], 16, bufdata[15], 17, buftext, -1);
start += 16;
}
gtk_tree_view_set_model(GTK_TREE_VIEW(widget), GTK_TREE_MODEL(store));
g_object_unref(G_OBJECT(store));
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(widget), TRUE);
gtk_widget_show(widget);
}
static void MemView_Go() {
GtkWidget *widget;
GladeXML *xml;
xml = glade_get_widget_tree(MemViewDlg);
widget = glade_xml_get_widget(xml, "entry_address");
sscanf(gtk_entry_get_text(GTK_ENTRY(widget)), "%x", &MemViewAddress);
UpdateMemViewDlg();
}
static void MemView_Dump() {
GtkWidget *dlg;
GtkWidget *box, *table, *label, *start_edit, *length_edit;
char buf[10];
dlg = gtk_dialog_new_with_buttons(_("Memory Dump"), GTK_WINDOW(MemViewDlg),
GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
box = GTK_WIDGET(GTK_DIALOG(dlg)->vbox);
table = gtk_table_new(2, 2, FALSE);
label = gtk_label_new(_("Start Address (Hexadecimal):"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, 0, 0, 5, 5);
gtk_widget_show(label);
start_edit = gtk_entry_new_with_max_length(8);
sprintf(buf, "%.8X", MemViewAddress | 0x80000000);
gtk_entry_set_text(GTK_ENTRY(start_edit), buf);
gtk_table_attach(GTK_TABLE(table), start_edit, 1, 2, 0, 1, 0, 0, 5, 5);
gtk_widget_show(start_edit);
label = gtk_label_new(_("Length (Decimal):"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, 0, 0, 5, 5);
gtk_widget_show(label);
length_edit = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), length_edit, 1, 2, 1, 2, 0, 0, 5, 5);
gtk_widget_show(length_edit);
gtk_box_pack_start(GTK_BOX(box), table, FALSE, FALSE, 5);
gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
gtk_widget_show_all(dlg);
if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_ACCEPT) {
s32 start = 0, length = 0;
sscanf(gtk_entry_get_text(GTK_ENTRY(start_edit)), "%x", &start);
sscanf(gtk_entry_get_text(GTK_ENTRY(length_edit)), "%d", &length);
start &= 0x1fffff;
if (start + length > 0x1fffff) {
length = 0x1fffff - start;
}
if (length > 0) {
GtkWidget *file_chooser = gtk_file_chooser_dialog_new(_("Dump to File"),
NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_chooser), getenv("HOME"));
if (gtk_dialog_run(GTK_DIALOG(file_chooser)) == GTK_RESPONSE_ACCEPT) {
gchar *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser));
FILE *fp = fopen(file, "wb");
if (fp != NULL) {
fwrite(&psxM[start], 1, length, fp);
fclose(fp);
} else {
SysMessage(_("Error writing to %s!"), file);
}
g_free(file);
}
gtk_widget_destroy(file_chooser);
}
}
gtk_widget_destroy(dlg);
}
static void MemView_Patch() {
GtkWidget *dlg;
GtkWidget *box, *table, *label, *addr_edit, *val_edit;
char buf[10];
dlg = gtk_dialog_new_with_buttons(_("Memory Patch"), GTK_WINDOW(MemViewDlg),
GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
box = GTK_WIDGET(GTK_DIALOG(dlg)->vbox);
table = gtk_table_new(2, 2, FALSE);
label = gtk_label_new(_("Address (Hexadecimal):"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, 0, 0, 5, 5);
gtk_widget_show(label);
addr_edit = gtk_entry_new_with_max_length(8);
sprintf(buf, "%.8X", MemViewAddress | 0x80000000);
gtk_entry_set_text(GTK_ENTRY(addr_edit), buf);
gtk_table_attach(GTK_TABLE(table), addr_edit, 1, 2, 0, 1, 0, 0, 5, 5);
gtk_widget_show(addr_edit);
label = gtk_label_new(_("Value (Hexa string):"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, 0, 0, 5, 5);
gtk_widget_show(label);
val_edit = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), val_edit, 1, 2, 1, 2, 0, 0, 5, 5);
gtk_widget_show(val_edit);
gtk_box_pack_start(GTK_BOX(box), table, FALSE, FALSE, 5);
gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
gtk_widget_show_all(dlg);
if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_ACCEPT) {
u32 addr = 0xffffffff, val = 0;
const char *p = gtk_entry_get_text(GTK_ENTRY(val_edit));
int r = strlen(p);
sscanf(gtk_entry_get_text(GTK_ENTRY(addr_edit)), "%x", &addr);
if (r > 0 && addr != 0xffffffff) {
addr &= 0x1fffff;
MemViewAddress = addr;
while (r > 0 && addr <= 0x1fffff) {
sscanf(p, "%2x", &val);
p += 2;
r -= 2;
while (r > 0 && (*p == '\t' || *p == ' ')) {
p++;
r--;
}
psxMemWrite8(addr, (u8)val);
addr++;
}
UpdateMemViewDlg();
}
}
gtk_widget_destroy(dlg);
}
// close the memory viewer window
static void MemView_Close(GtkWidget *widget, gpointer user_data) {
gtk_widget_destroy(MemViewDlg);
MemViewDlg = NULL;
}
void RunDebugMemoryDialog() {
GladeXML *xml;
GtkWidget *widget;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
PangoFontDescription *pfd;
int i;
xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "MemViewDlg", NULL);
if (!xml) {
g_warning(_("Error: Glade interface could not be loaded!"));
return;
}
MemViewDlg = glade_xml_get_widget(xml, "MemViewDlg");
gtk_window_set_title(GTK_WINDOW(MemViewDlg), _("Memory Viewer"));
widget = glade_xml_get_widget(xml, "GtkCList_MemView");
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(_("Address"),
renderer, "text", 0, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
for (i = 0; i < 16; i++) {
const char *p = "0123456789ABCDEF";
char buf[2];
buf[0] = p[i];
buf[1] = '\0';
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(buf,
renderer, "text", i + 1, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
}
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(_("Text"),
renderer, "text", 17, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
pfd = pango_font_description_from_string("Bitstream Vera Sans Mono, "
"DejaVu Sans Mono, Liberation Mono, FreeMono, Sans Mono 9");
gtk_widget_modify_font(widget, pfd);
pango_font_description_free(pfd);
UpdateMemViewDlg();
widget = glade_xml_get_widget(xml, "btn_dump");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(MemView_Dump), xml, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_patch");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(MemView_Patch), xml, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "btn_go");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(MemView_Go), xml, NULL, G_CONNECT_AFTER);
g_signal_connect_data(GTK_OBJECT(MemViewDlg), "response",
GTK_SIGNAL_FUNC(MemView_Close), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
}

24
gui/DebugMemory.h Normal file
View File

@ -0,0 +1,24 @@
/* Memory Viewer/Dumper for PCSX-Reloaded
* Copyright (C) 2010, Wei Mingzhi <whistler_wmz@users.sf.net>.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#ifndef DEBUGMEMORY_H
#define DEBUGMEMORY_H
void RunDebugMemoryDialog();
#endif

944
gui/Gtk2Gui.c Normal file
View File

@ -0,0 +1,944 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <dirent.h>
#include <dlfcn.h>
#include <sys/stat.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <signal.h>
#include <sys/time.h>
#include <regex.h>
#include "Linux.h"
#include "../libpcsxcore/plugins.h"
#include "../libpcsxcore/cheat.h"
#include "MemcardDlg.h"
#include "ConfDlg.h"
#include "DebugMemory.h"
#include "AboutDlg.h"
// Functions Callbacks
void OnFile_RunCd();
void OnFile_RunBios();
void OnFile_RunExe();
void OnFile_RunImage();
void OnEmu_Run();
void OnEmu_Reset();
void OnEmu_SwitchImage();
void OnHelp_Help();
void OnHelp_About();
void OnDestroy();
void OnFile_Exit();
void on_states_load(GtkWidget *widget, gpointer user_data);
void on_states_load_other();
void on_states_save(GtkWidget *widget, gpointer user_data);
void on_states_save_other();
GtkWidget *Window = NULL;
int destroy = 0;
#define MAX_SLOTS 5
/* TODO - If MAX_SLOTS changes, need to find a way to automatically set all positions */
int Slots[MAX_SLOTS] = { -1, -1, -1, -1, -1 };
void ResetMenuSlots(GladeXML *xml) {
GtkWidget *widget;
gchar *str;
int i;
if (CdromId[0] == '\0') {
// disable state saving/loading if no CD is loaded
for (i = 0; i < MAX_SLOTS; i++) {
str = g_strdup_printf("GtkMenuItem_SaveSlot%d", i+1);
widget = glade_xml_get_widget(xml, str);
g_free(str);
gtk_widget_set_sensitive(widget, FALSE);
str = g_strdup_printf("GtkMenuItem_LoadSlot%d", i+1);
widget = glade_xml_get_widget(xml, str);
g_free(str);
gtk_widget_set_sensitive(widget, FALSE);
}
// also disable certain menu/toolbar items
widget = glade_xml_get_widget(xml, "other1");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "other2");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "run1");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "reset1");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "search1");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "SwitchImage");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "memorydump1");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "toolbutton_run");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "toolbutton_switchimage");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "statusbar");
gtk_statusbar_pop(GTK_STATUSBAR(widget), 1);
gtk_statusbar_push(GTK_STATUSBAR(widget), 1, _("Ready"));
}
else {
for (i = 0; i < MAX_SLOTS; i++) {
str = g_strdup_printf("GtkMenuItem_LoadSlot%d", i+1);
widget = glade_xml_get_widget (xml, str);
g_free (str);
if (Slots[i] == -1)
gtk_widget_set_sensitive(widget, FALSE);
else
gtk_widget_set_sensitive(widget, TRUE);
}
widget = glade_xml_get_widget(xml, "plugins_bios");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "graphics1");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "sound1");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "cdrom1");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "pad1");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "net1");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "SwitchImage");
gtk_widget_set_sensitive(widget, UsingIso());
widget = glade_xml_get_widget(xml, "toolbutton_switchimage");
gtk_widget_set_sensitive(widget, UsingIso());
widget = glade_xml_get_widget(xml, "toolbutton_graphics");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "toolbutton_sound");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "toolbutton_cdrom");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "toolbutton_controllers");
gtk_widget_set_sensitive(widget, FALSE);
widget = glade_xml_get_widget(xml, "statusbar");
gtk_statusbar_pop(GTK_STATUSBAR(widget), 1);
gtk_statusbar_push(GTK_STATUSBAR(widget), 1, _("Emulation Paused."));
}
}
int match(const char *string, char *pattern) {
int status;
regex_t re;
if (regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB) != 0) {
return 0;
}
status = regexec(&re, string, (size_t) 0, NULL, 0);
regfree(&re);
if (status != 0) {
return 0;
}
return 1;
}
gchar* get_state_filename(int i) {
gchar *state_filename;
char SStateFile[64];
char trimlabel[33];
int j;
strncpy(trimlabel, CdromLabel, 32);
trimlabel[32] = 0;
for (j = 31; j >= 0; j--)
if (trimlabel[j] == ' ')
trimlabel[j] = 0;
else
continue;
sprintf(SStateFile, "%.32s-%.9s.%3.3d", trimlabel, CdromId, i);
state_filename = g_build_filename (getenv("HOME"), STATES_DIR, SStateFile, NULL);
return state_filename;
}
void UpdateMenuSlots() {
gchar *str;
int i;
for (i = 0; i < MAX_SLOTS; i++) {
str = get_state_filename (i);
Slots[i] = CheckState(str);
g_free (str);
}
}
void StartGui() {
GladeXML *xml;
GtkWidget *widget;
/* If a plugin fails, the Window is not NULL, but is not initialised,
so the following causes a segfault
if (Window != NULL) {
gtk_window_present (GTK_WINDOW (Window));
return;
}*/
xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "MainWindow", NULL);
if (!xml) {
g_warning("We could not load the interface!");
return;
}
Window = glade_xml_get_widget(xml, "MainWindow");
gtk_window_set_title(GTK_WINDOW(Window), "PCSX");
gtk_window_set_icon_from_file(GTK_WINDOW(Window), PIXMAPDIR "pcsx-icon.png", NULL);
gtk_window_set_default_icon_from_file(PIXMAPDIR "pcsx-icon.png", NULL);
ResetMenuSlots(xml);
// Set up callbacks
g_signal_connect_data(GTK_OBJECT(Window), "delete-event",
GTK_SIGNAL_FUNC(OnDestroy), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
// File menu
widget = glade_xml_get_widget(xml, "RunCd");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnFile_RunCd), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "RunBios");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnFile_RunBios), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "RunExe");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnFile_RunExe), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "RunImage");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnFile_RunImage), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "exit2");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnFile_Exit), NULL, NULL, G_CONNECT_AFTER);
// States
widget = glade_xml_get_widget(xml, "GtkMenuItem_LoadSlot1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_load), (gpointer) 0, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkMenuItem_LoadSlot2");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_load), (gpointer) 1, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkMenuItem_LoadSlot3");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_load), (gpointer) 2, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkMenuItem_LoadSlot4");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_load), (gpointer) 3, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkMenuItem_LoadSlot5");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_load), (gpointer) 4, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "other1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_load_other), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkMenuItem_SaveSlot1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_save), (gpointer) 0, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkMenuItem_SaveSlot2");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_save), (gpointer) 1, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkMenuItem_SaveSlot3");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_save), (gpointer) 2, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkMenuItem_SaveSlot4");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_save), (gpointer) 3, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkMenuItem_SaveSlot5");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_save), (gpointer) 4, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "other2");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(on_states_save_other), NULL, NULL, G_CONNECT_AFTER);
// Emulation menu
widget = glade_xml_get_widget(xml, "run1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnEmu_Run), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "reset1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnEmu_Reset), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "SwitchImage");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnEmu_SwitchImage), NULL, NULL, G_CONNECT_AFTER);
// Configuration menu
widget = glade_xml_get_widget(xml, "plugins_bios");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(ConfigurePlugins), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "graphics1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnConf_Graphics), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "sound1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnConf_Sound), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "cdrom1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnConf_CdRom), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "pad1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnConf_Pad), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "cpu1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnConf_Cpu), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "memory_cards1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnConf_Mcds), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "net1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnConf_Net), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "memorydump1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(RunDebugMemoryDialog), NULL, NULL, G_CONNECT_AFTER);
// Cheat menu
widget = glade_xml_get_widget(xml, "browse1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(RunCheatListDialog), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "search1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(RunCheatSearchDialog), NULL, NULL, G_CONNECT_AFTER);
// Help menu
widget = glade_xml_get_widget(xml, "about_pcsx1");
g_signal_connect_data(GTK_OBJECT(widget), "activate",
GTK_SIGNAL_FUNC(OnHelp_About), NULL, NULL, G_CONNECT_AFTER);
// Toolbar
widget = glade_xml_get_widget(xml, "toolbutton_runcd");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnFile_RunCd), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "toolbutton_runimage");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnFile_RunImage), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "toolbutton_run");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnEmu_Run), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "toolbutton_switchimage");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnEmu_SwitchImage), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "toolbutton_memcards");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnConf_Mcds), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "toolbutton_graphics");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnConf_Graphics), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "toolbutton_sound");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnConf_Sound), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "toolbutton_cdrom");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnConf_CdRom), NULL, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "toolbutton_controllers");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnConf_Pad), NULL, NULL, G_CONNECT_AFTER);
gtk_main();
}
void OnDestroy() {
if (!destroy) OnFile_Exit();
}
void destroy_main_window () {
destroy = 1;
gtk_widget_destroy(Window);
Window = NULL;
destroy = 0;
gtk_main_quit();
while (gtk_events_pending()) gtk_main_iteration();
}
void OnFile_RunExe() {
GtkWidget *file_chooser;
if (plugins_configured() == FALSE) {
ConfigurePlugins();
} else {
file_chooser = gtk_file_chooser_dialog_new(_("Select PSX EXE File"),
NULL, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
// Add file filters
GtkFileFilter *exefilter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (exefilter, "*.exe");
gtk_file_filter_add_pattern (exefilter, "*.psx");
gtk_file_filter_add_pattern (exefilter, "*.cpe");
gtk_file_filter_add_pattern (exefilter, "*.EXE");
gtk_file_filter_add_pattern (exefilter, "*.PSX");
gtk_file_filter_add_pattern (exefilter, "*.CPE");
gtk_file_filter_set_name (exefilter, _("PlayStation Executable Files"));
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_chooser), exefilter);
GtkFileFilter *allfilter = gtk_file_filter_new ();
gtk_file_filter_add_pattern (allfilter, "*");
gtk_file_filter_set_name (allfilter, _("All Files"));
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_chooser), allfilter);
// Set this to the config object and retain it - maybe LastUsedDir
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_chooser), getenv("HOME"));
if (gtk_dialog_run(GTK_DIALOG(file_chooser)) == GTK_RESPONSE_ACCEPT) {
gchar *file;
/* TODO Need to validate the file */
file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser));
gtk_widget_destroy (file_chooser);
destroy_main_window();
SetIsoFile(NULL);
LoadPlugins();
NetOpened = FALSE;
if (OpenPlugins() == -1) {
g_free(file);
SysRunGui();
} else {
SysReset();
if (Load(file) == 0) {
g_free(file);
psxCpu->Execute();
} else {
g_free(file);
ClosePlugins();
SysErrorMessage(_("Not a valid PSX file"), _("The file does not appear to be a valid Playstation executable"));
SysRunGui();
}
}
} else
gtk_widget_destroy(file_chooser);
}
}
void OnFile_RunCd() {
if (plugins_configured() == FALSE) {
ConfigurePlugins();
return;
}
destroy_main_window();
SetIsoFile(NULL);
LoadPlugins();
NetOpened = FALSE;
if (OpenPlugins() == -1) {
SysRunGui();
return;
}
SysReset();
if (CheckCdrom() == -1) {
/* Only check the CD if we are starting the console with a CD */
ClosePlugins();
SysErrorMessage (_("CD ROM failed"), _("The CD does not appear to be a valid Playstation CD"));
SysRunGui();
return;
}
// Read main executable directly from CDRom and start it
if (LoadCdrom() == -1) {
ClosePlugins();
SysErrorMessage(_("Could not load CD-ROM!"), _("The CD-ROM could not be loaded"));
SysRunGui();
}
psxCpu->Execute();
}
void OnFile_RunBios() {
if (plugins_configured() == FALSE) {
ConfigurePlugins();
return;
}
if (strcmp(Config.Bios, "HLE") == 0) {
SysErrorMessage (_("Could not run BIOS"), _("Running BIOS is not supported with Internal HLE BIOS."));
return;
}
destroy_main_window();
SetIsoFile(NULL);
LoadPlugins();
NetOpened = FALSE;
if (OpenPlugins() == -1) {
SysRunGui();
return;
}
SysReset();
CdromId[0] = '\0';
CdromLabel[0] = '\0';
psxCpu->Execute();
}
static gchar *Open_Iso_Proc() {
GtkWidget *chooser;
gchar *filename;
GtkFileFilter *psxfilter, *allfilter;
static char current_folder[MAXPATHLEN] = "";
chooser = gtk_file_chooser_dialog_new (_("Open PSX Disc Image File"),
NULL, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
if (current_folder[0] == '\0') {
strcpy(current_folder, getenv("HOME"));
}
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (chooser), current_folder);
psxfilter = gtk_file_filter_new();
gtk_file_filter_add_pattern(psxfilter, "*.bin");
gtk_file_filter_add_pattern(psxfilter, "*.img");
gtk_file_filter_add_pattern(psxfilter, "*.mdf");
gtk_file_filter_add_pattern(psxfilter, "*.iso");
gtk_file_filter_add_pattern(psxfilter, "*.BIN");
gtk_file_filter_add_pattern(psxfilter, "*.IMG");
gtk_file_filter_add_pattern(psxfilter, "*.MDF");
gtk_file_filter_add_pattern(psxfilter, "*.ISO");
gtk_file_filter_set_name(psxfilter, _("PSX Image Files (*.bin, *.img, *.mdf, *.iso)"));
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (chooser), psxfilter);
allfilter = gtk_file_filter_new();
gtk_file_filter_add_pattern(allfilter, "*");
gtk_file_filter_set_name(allfilter, _("All Files"));
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER (chooser), allfilter);
if (gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_OK) {
gchar *path = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(chooser));
strcpy(current_folder, path);
g_free(path);
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (chooser));
gtk_widget_destroy(GTK_WIDGET(chooser));
while (gtk_events_pending()) gtk_main_iteration();
return filename;
} else {
gtk_widget_destroy (GTK_WIDGET(chooser));
while (gtk_events_pending()) gtk_main_iteration();
return NULL;
}
}
void OnFile_RunImage() {
gchar *filename;
if (plugins_configured() == FALSE) {
ConfigurePlugins();
return;
}
filename = Open_Iso_Proc();
if (filename == NULL) {
return;
}
destroy_main_window();
SetIsoFile(filename);
g_free(filename);
LoadPlugins();
NetOpened = FALSE;
if (OpenPlugins() == -1) {
SysRunGui();
return;
}
SysReset();
if (CheckCdrom() == -1) {
// Only check the CD if we are starting the console with a CD
ClosePlugins();
SysErrorMessage (_("CD ROM failed"), _("The CD does not appear to be a valid Playstation CD"));
SysRunGui();
return;
}
// Read main executable directly from CDRom and start it
if (LoadCdrom() == -1) {
ClosePlugins();
SysErrorMessage(_("Could not load CD-ROM!"), _("The CD-ROM could not be loaded"));
SysRunGui();
}
psxCpu->Execute();
}
void OnEmu_Run() {
if (plugins_configured() == FALSE) {
ConfigurePlugins();
return;
}
destroy_main_window();
if (OpenPlugins() == -1) {
SysRunGui();
return;
}
CheatSearchBackupMemory();
psxCpu->Execute();
}
void OnEmu_Reset() {
if (plugins_configured() == FALSE) {
ConfigurePlugins();
return;
}
destroy_main_window();
if (OpenPlugins() == -1) {
SysRunGui();
return;
}
SysReset();
if (CheckCdrom() != -1) {
LoadCdrom();
}
psxCpu->Execute();
}
void OnEmu_SwitchImage() {
gchar *filename;
if (plugins_configured() == FALSE) {
ConfigurePlugins();
return;
}
filename = Open_Iso_Proc();
if (filename == NULL) {
return;
}
destroy_main_window();
SetIsoFile(filename);
g_free(filename);
if (OpenPlugins() == -1) {
SysRunGui();
return;
}
SetCdOpenCaseTime(time(NULL) + 2);
CheatSearchBackupMemory();
psxCpu->Execute();
}
void OnFile_Exit() {
DIR *dir;
struct dirent *ent;
void *Handle;
gchar *plugin = NULL;
gchar *dotdir;
dotdir = g_build_filename(getenv("HOME"), PLUGINS_DIR, NULL);
// with this the problem with plugins that are linked with the pthread
// library is solved
dir = opendir(dotdir);
if (dir != NULL) {
while ((ent = readdir(dir)) != NULL) {
plugin = g_build_filename(dotdir, ent->d_name, NULL);
if (strstr(plugin, ".so") == NULL && strstr(plugin, ".dylib") == NULL)
continue;
Handle = dlopen(plugin, RTLD_NOW);
if (Handle == NULL)
continue;
g_free(plugin);
}
}
g_free(dotdir);
bind_textdomain_codeset(PACKAGE_NAME, "");
if (UseGui)
gtk_main_quit();
SysClose();
if (UseGui)
gtk_exit (0);
else
exit(0);
}
void state_load(gchar *state_filename) {
int ret;
char Text[MAXPATHLEN + 20];
FILE *fp;
// check if the state file actually exists
fp = fopen(state_filename, "rb");
if (fp == NULL) {
// file does not exist
return;
}
fclose(fp);
// If the window exists, then we are loading the state from within
// within the PCSX GUI. We need to initialise the plugins first
if (Window) {
destroy_main_window();
if (OpenPlugins() == -1) {
SysRunGui();
return;
}
}
ret = CheckState(state_filename);
if (ret == 0) {
SysReset();
ret = LoadState(state_filename);
}
if (ret == 0) {
// Check the CD-ROM is valid
if (CheckCdrom() == -1) {
ClosePlugins();
SysRunGui();
return;
}
sprintf(Text, _("Loaded state %s."), state_filename);
GPU_displayText(Text);
} else {
sprintf(Text, _("Error loading state %s!"), state_filename);
GPU_displayText(Text);
}
}
void state_save(gchar *state_filename) {
char Text[MAXPATHLEN + 20];
GPU_updateLace();
if (SaveState(state_filename) == 0)
sprintf(Text, _("Saved state %s."), state_filename);
else
sprintf(Text, _("Error saving state %s!"), state_filename);
GPU_displayText(Text);
}
void on_states_load (GtkWidget *widget, gpointer user_data) {
gchar *state_filename;
gint state = (int)user_data;
state_filename = get_state_filename(state);
state_load(state_filename);
g_free(state_filename);
psxCpu->Execute();
}
void on_states_save (GtkWidget *widget, gpointer user_data) {
gchar *state_filename;
gint state = (int)user_data;
state_filename = get_state_filename(state);
state_save(state_filename);
g_free(state_filename);
}
void on_states_load_other() {
GtkWidget *file_chooser;
gchar *SStateFile;
SStateFile = g_strconcat(getenv("HOME"), STATES_DIR, NULL);
file_chooser = gtk_file_chooser_dialog_new(_("Select State File"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (file_chooser), SStateFile);
g_free(SStateFile);
if (gtk_dialog_run(GTK_DIALOG(file_chooser)) == GTK_RESPONSE_ACCEPT) {
gchar *filename;
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser));
gtk_widget_destroy(file_chooser);
state_load(filename);
g_free(filename);
psxCpu->Execute();
} else
gtk_widget_destroy(file_chooser);
}
void on_states_save_other() {
GtkWidget *file_chooser;
gchar *SStateFile;
SStateFile = g_strconcat (getenv("HOME"), STATES_DIR, NULL);
file_chooser = gtk_file_chooser_dialog_new(_("Select State File"),
NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
NULL);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_chooser), SStateFile);
g_free(SStateFile);
if (gtk_dialog_run (GTK_DIALOG(file_chooser)) == GTK_RESPONSE_OK) {
gchar *filename;
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (file_chooser));
gtk_widget_destroy(file_chooser);
state_save(filename);
g_free(filename);
}
else
gtk_widget_destroy(file_chooser);
}
void OnHelp_About(GtkWidget *widget, gpointer user_data) {
RunAboutDialog();
}
void SysMessage(const char *fmt, ...) {
GtkWidget *Txt, *MsgDlg;
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg) - 1] == '\n')
msg[strlen(msg) - 1] = 0;
if (!UseGui) {
fprintf(stderr, "%s\n", msg);
return;
}
MsgDlg = gtk_dialog_new_with_buttons(_("Notice"), NULL,
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_NONE, NULL);
gtk_window_set_position (GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
Txt = gtk_label_new (msg);
gtk_label_set_line_wrap(GTK_LABEL(Txt), TRUE);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(MsgDlg)->vbox), Txt);
gtk_widget_show (Txt);
gtk_widget_show_all (MsgDlg);
gtk_dialog_run (GTK_DIALOG(MsgDlg));
gtk_widget_destroy (MsgDlg);
}
void SysErrorMessage(gchar *primary, gchar *secondary) {
GtkWidget *message_dialog;
if (!UseGui)
printf ("%s - %s\n", primary, secondary);
else {
message_dialog = gtk_message_dialog_new(NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
primary,
NULL);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(message_dialog),
secondary);
gtk_dialog_run(GTK_DIALOG(message_dialog));
gtk_widget_destroy(message_dialog);
}
}
void SysInfoMessage(gchar *primary, gchar *secondary) {
GtkWidget *message_dialog;
if (!UseGui)
printf ("%s - %s\n", primary, secondary);
else {
message_dialog = gtk_message_dialog_new(NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
primary,
NULL);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(message_dialog),
secondary);
gtk_dialog_run(GTK_DIALOG(message_dialog));
gtk_widget_destroy(message_dialog);
}
}

67
gui/Linux.h Normal file
View File

@ -0,0 +1,67 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#ifndef __LINUX_H__
#define __LINUX_H__
#include "config.h"
#include "../libpcsxcore/psxcommon.h"
#include <gtk/gtk.h>
#include "Cheat.h"
#define DEFAULT_MEM_CARD_1 "/.pcsx/memcards/card1.mcd"
#define DEFAULT_MEM_CARD_2 "/.pcsx/memcards/card2.mcd"
#define MEMCARD_DIR "/.pcsx/memcards/"
#define PLUGINS_DIR "/.pcsx/plugins/"
#define PLUGINS_CFG_DIR "/.pcsx/plugins/cfg/"
#define PCSX_DOT_DIR "/.pcsx/"
#define BIOS_DIR "/.pcsx/bios/"
#define STATES_DIR "/.pcsx/sstates/"
#define CHEATS_DIR "/.pcsx/cheats/"
#define PATCHES_DIR "/.pcsx/patches/"
extern gboolean UseGui;
extern int StatesC;
char cfgfile[MAXPATHLEN]; /* ADB Comment this out - make a local var, or at least use gchar funcs */
char cfgfile_basename[MAXPATHLEN]; /* ADB Comment this out - make a local var, or at least use gchar funcs */
int LoadConfig();
void SaveConfig();
void StartGui();
void PADhandleKey(int key);
void UpdateMenuSlots();
gchar* get_state_filename(int i);
void state_save(gchar *state_filename);
void state_load(gchar *state_filename);
int match(const char* string, char* pattern);
int plugins_configured();
void UpdatePluginsBIOS();
void SysErrorMessage(gchar *primary, gchar *secondary);
void SysInfoMessage(gchar *primary, gchar *secondary);
#endif /* __LINUX_H__ */

568
gui/LnxMain.c Normal file
View File

@ -0,0 +1,568 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <dlfcn.h>
#include <sys/mman.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <gtk/gtk.h>
#include <pthread.h>
#include <dirent.h>
#include <sys/stat.h>
#include "../libpcsxcore/sio.h"
#include "Linux.h"
#include "ConfDlg.h"
#ifdef ENABLE_NLS
#include <locale.h>
#endif
#include <X11/extensions/XTest.h>
enum {
RUN = 0,
RUN_CD,
};
gboolean UseGui = TRUE;
static void CreateMemcard(char *filename, char *conf_mcd) {
gchar *mcd;
struct stat buf;
mcd = g_build_filename(getenv("HOME"), MEMCARD_DIR, filename, NULL);
strcpy(conf_mcd, mcd);
/* Only create a memory card if an existing one does not exist */
if (stat(mcd, &buf) == -1) {
SysPrintf(_("Creating memory card: %s\n"), mcd);
CreateMcd(mcd);
}
g_free (mcd);
}
/* Create a directory under the $HOME directory, if that directory doesn't already exist */
static void CreateHomeConfigDir(char *directory) {
struct stat buf;
if (stat(directory, &buf) == -1) {
gchar *dir_name = g_build_filename (getenv("HOME"), directory, NULL);
mkdir(dir_name, S_IRWXU | S_IRWXG);
g_free (dir_name);
}
}
static void CheckSubDir() {
// make sure that ~/.pcsx exists
CreateHomeConfigDir(PCSX_DOT_DIR);
CreateHomeConfigDir(BIOS_DIR);
CreateHomeConfigDir(MEMCARD_DIR);
CreateHomeConfigDir(STATES_DIR);
CreateHomeConfigDir(PLUGINS_DIR);
CreateHomeConfigDir(PLUGINS_CFG_DIR);
CreateHomeConfigDir(CHEATS_DIR);
CreateHomeConfigDir(PATCHES_DIR);
}
static void ScanPlugins(gchar* scandir) {
// scan for plugins and configuration tools
DIR *dir;
struct dirent *ent;
gchar *linkname;
gchar *filename;
/* Any plugins found will be symlinked to the following directory */
dir = opendir(scandir);
if (dir != NULL) {
while ((ent = readdir(dir)) != NULL) {
filename = g_build_filename (scandir, ent->d_name, NULL);
if (match(filename, ".*\\.so$") == 0 &&
match(filename, ".*\\.dylib$") == 0 &&
match(filename, "cfg.*") == 0) {
continue; /* Skip this file */
} else {
/* Create a symlink from this file to the directory ~/.pcsx/plugin */
linkname = g_build_filename (getenv("HOME"), PLUGINS_DIR, ent->d_name, NULL);
symlink(filename, linkname);
/* If it's a config tool, make one in the cfg dir as well.
This allows plugins with retarded cfg finding to work :- ) */
if (match(filename, "cfg.*") == 1) {
linkname = g_build_filename (getenv("HOME"), PLUGINS_CFG_DIR, ent->d_name, NULL);
symlink(filename, linkname);
}
g_free (linkname);
}
g_free (filename);
}
closedir(dir);
}
}
static void ScanBios(gchar* scandir) {
// scan for bioses
DIR *dir;
struct dirent *ent;
gchar *linkname;
gchar *filename;
/* Any bioses found will be symlinked to the following directory */
dir = opendir(scandir);
if (dir != NULL) {
while ((ent = readdir(dir)) != NULL) {
filename = g_build_filename(scandir, ent->d_name, NULL);
if (match(filename, ".*\\.bin$") == 0 &&
match(filename, ".*\\.BIN$") == 0) {
continue; /* Skip this file */
} else {
/* Create a symlink from this file to the directory ~/.pcsx/plugin */
linkname = g_build_filename(getenv("HOME"), BIOS_DIR, ent->d_name, NULL);
symlink(filename, linkname);
g_free(linkname);
}
g_free(filename);
}
closedir(dir);
}
}
static void CheckSymlinksInPath(char* dotdir) {
DIR *dir;
struct dirent *ent;
struct stat stbuf;
gchar *linkname;
dir = opendir(dotdir);
if (dir == NULL) {
SysMessage(_("Could not open directory: '%s'\n"), dotdir);
return;
}
/* Check for any bad links in the directory. If the remote
file no longer exists, remove the link */
while ((ent = readdir(dir)) != NULL) {
linkname = g_strconcat (dotdir, ent->d_name, NULL);
if (stat(linkname, &stbuf) == -1) {
/* File link is bad, remove it */
unlink(linkname);
}
g_free (linkname);
}
closedir(dir);
}
static void ScanAllPlugins (void) {
gchar *currentdir;
// scan some default locations to find plugins
ScanPlugins("/usr/lib/games/psemu/");
ScanPlugins("/usr/lib/games/psemu/lib/");
ScanPlugins("/usr/lib/games/psemu/config/");
ScanPlugins("/usr/local/lib/games/psemu/lib/");
ScanPlugins("/usr/local/lib/games/psemu/config/");
ScanPlugins("/usr/local/lib/games/psemu/");
ScanPlugins("/usr/lib64/games/psemu/");
ScanPlugins("/usr/lib64/games/psemu/lib/");
ScanPlugins("/usr/lib64/games/psemu/config/");
ScanPlugins("/usr/local/lib64/games/psemu/lib/");
ScanPlugins("/usr/local/lib64/games/psemu/config/");
ScanPlugins("/usr/local/lib64/games/psemu/");
ScanPlugins("/usr/lib32/games/psemu/");
ScanPlugins("/usr/lib32/games/psemu/lib/");
ScanPlugins("/usr/lib32/games/psemu/config/");
ScanPlugins("/usr/local/lib32/games/psemu/lib/");
ScanPlugins("/usr/local/lib32/games/psemu/config/");
ScanPlugins("/usr/local/lib32/games/psemu/");
ScanPlugins(DEF_PLUGIN_DIR);
ScanPlugins(DEF_PLUGIN_DIR "/lib");
ScanPlugins(DEF_PLUGIN_DIR "/lib64");
ScanPlugins(DEF_PLUGIN_DIR "/lib32");
ScanPlugins(DEF_PLUGIN_DIR "/config");
// scan some default locations to find bioses
ScanBios("/usr/lib/games/psemu");
ScanBios("/usr/lib/games/psemu/bios");
ScanBios("/usr/lib64/games/psemu");
ScanBios("/usr/lib64/games/psemu/bios");
ScanBios("/usr/lib32/games/psemu");
ScanBios("/usr/lib32/games/psemu/bios");
ScanBios("/usr/share/psemu");
ScanBios("/usr/share/psemu/bios");
ScanBios("/usr/share/pcsx");
ScanBios("/usr/share/pcsx/bios");
ScanBios("/usr/local/lib/games/psemu");
ScanBios("/usr/local/lib/games/psemu/bios");
ScanBios("/usr/local/lib64/games/psemu");
ScanBios("/usr/local/lib64/games/psemu/bios");
ScanBios("/usr/local/lib32/games/psemu");
ScanBios("/usr/local/lib32/games/psemu/bios");
ScanBios("/usr/local/share/psemu");
ScanBios("/usr/local/share/psemu/bios");
ScanBios("/usr/local/share/pcsx");
ScanBios("/usr/local/share/pcsx/bios");
ScanBios(PACKAGE_DATA_DIR);
ScanBios(PSEMU_DATA_DIR);
ScanBios(PACKAGE_DATA_DIR "/bios");
ScanBios(PSEMU_DATA_DIR "/bios");
currentdir = g_strconcat(getenv("HOME"), "/.psemu-plugins/", NULL);
ScanPlugins(currentdir);
g_free(currentdir);
currentdir = g_strconcat(getenv("HOME"), "/.psemu/", NULL);
ScanPlugins(currentdir);
g_free(currentdir);
// Check for bad links in ~/.pcsx/plugins/
currentdir = g_build_filename(getenv("HOME"), PLUGINS_DIR, NULL);
CheckSymlinksInPath(currentdir);
g_free(currentdir);
// Check for bad links in ~/.pcsx/plugins/cfg
currentdir = g_build_filename(getenv("HOME"), PLUGINS_CFG_DIR, NULL);
CheckSymlinksInPath(currentdir);
g_free(currentdir);
// Check for bad links in ~/.pcsx/bios
currentdir = g_build_filename(getenv("HOME"), BIOS_DIR, NULL);
CheckSymlinksInPath(currentdir);
g_free(currentdir);
}
// Set the default plugin name
void set_default_plugin(char *plugin_name, char *conf_plugin_name) {
if (strlen(plugin_name) != 0) {
strcpy(conf_plugin_name, plugin_name);
printf("Picking default plugin: %s\n", plugin_name);
} else
printf("No default plugin could be found for %s\n", conf_plugin_name);
}
int main(int argc, char *argv[]) {
char file[MAXPATHLEN] = "";
char path[MAXPATHLEN];
int runcd = RUN;
int loadst = 0;
int i;
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
// what is the name of the config file?
// it may be redefined by -cfg on the command line
strcpy(cfgfile_basename, "pcsx.cfg");
// read command line options
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-runcd")) runcd = RUN_CD;
else if (!strcmp(argv[i], "-nogui")) UseGui = FALSE;
else if (!strcmp(argv[i], "-psxout")) Config.PsxOut = 1;
else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
else if (!strcmp(argv[i], "-cfg")) {
if (i+1 >= argc) break;
strncpy(cfgfile_basename, argv[++i], MAXPATHLEN-100); /* TODO buffer overruns */
printf("Using config file %s.\n", cfgfile_basename);
}
else if (!strcmp(argv[i], "-cdfile")) {
char isofilename[MAXPATHLEN];
if (i+1 >= argc) break;
strncpy(isofilename, argv[++i], MAXPATHLEN);
if (isofilename[0] != '/') {
getcwd(path, MAXPATHLEN);
if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
strcat(path, "/");
strcat(path, isofilename);
strcpy(isofilename, path);
} else
isofilename[0] = 0;
}
SetIsoFile(isofilename);
runcd = RUN_CD;
}
else if (!strcmp(argv[i], "-h") ||
!strcmp(argv[i], "-help") ||
!strcmp(argv[i], "--help")) {
printf(PACKAGE_STRING "\n");
printf("%s\n", _(
" pcsx [options] [file]\n"
"\toptions:\n"
"\t-runcd\t\tRuns CD-ROM\n"
"\t-cdfile FILE\tRuns a CD image file\n"
"\t-nogui\t\tDon't open the GTK GUI\n"
"\t-cfg FILE\tLoads desired configuration file (default: ~/.pcsx/pcsx.cfg)\n"
"\t-psxout\t\tEnable PSX output\n"
"\t-load STATENUM\tLoads savestate STATENUM (1-5)\n"
"\t-h -help\tDisplay this message\n"
"\tfile\t\tLoads file\n"));
return 0;
} else {
strncpy(file, argv[i], MAXPATHLEN);
if (file[0] != '/') {
getcwd(path, MAXPATHLEN);
if (strlen(path) + strlen(file) + 1 < MAXPATHLEN) {
strcat(path, "/");
strcat(path, file);
strcpy(file, path);
} else
file[0] = 0;
}
}
}
memset(&Config, 0, sizeof(PcsxConfig));
strcpy(Config.Net, "Disabled");
if (UseGui) gtk_init(NULL, NULL);
CheckSubDir();
ScanAllPlugins();
// try to load config
// if the config file doesn't exist
if (LoadConfig() == -1) {
if (!UseGui) {
printf(_("PCSX cannot be configured without using the GUI -- you should restart without -nogui.\n"));
return 1;
}
// Uh oh, no config file found, use some defaults
Config.PsxAuto = 1;
gchar *str_bios_dir = g_strconcat(getenv("HOME"), BIOS_DIR, NULL);
strcpy(Config.BiosDir, str_bios_dir);
g_free(str_bios_dir);
gchar *str_plugin_dir = g_strconcat(getenv("HOME"), PLUGINS_DIR, NULL);
strcpy(Config.PluginsDir, str_plugin_dir);
g_free(str_plugin_dir);
gtk_init(NULL, NULL);
// Update available plugins, but not GUI
UpdatePluginsBIOS();
// Pick some defaults, if they're available
set_default_plugin(GpuConfS.plist[0], Config.Gpu);
set_default_plugin(SpuConfS.plist[0], Config.Spu);
set_default_plugin(CdrConfS.plist[0], Config.Cdr);
set_default_plugin(Pad1ConfS.plist[0], Config.Pad1);
set_default_plugin(Pad2ConfS.plist[0], Config.Pad2);
set_default_plugin(BiosConfS.plist[0], Config.Bios);
// create & load default memcards if they don't exist
CreateMemcard("card1.mcd", Config.Mcd1);
CreateMemcard("card2.mcd", Config.Mcd2);
LoadMcds(Config.Mcd1, Config.Mcd2);
SaveConfig();
}
gchar *str_patches_dir = g_strconcat(getenv("HOME"), PATCHES_DIR, NULL);
strcpy(Config.PatchesDir, str_patches_dir);
g_free(str_patches_dir);
// switch to plugin dotdir
// this lets plugins work without modification!
gchar *plugin_default_dir = g_build_filename(getenv("HOME"), PLUGINS_DIR, NULL);
chdir(plugin_default_dir);
g_free(plugin_default_dir);
if (UseGui) SetIsoFile(NULL);
if (SysInit() == -1) return 1;
if (UseGui) {
StartGui();
} else {
// the following only occurs if the gui isn't started
if (LoadPlugins() == -1) {
SysErrorMessage(_("Error"), _("Failed loading plugins!"));
return 1;
}
if (OpenPlugins() == -1 || plugins_configured() == FALSE) {
return 1;
}
SysReset();
CheckCdrom();
if (file[0] != '\0') {
Load(file);
} else {
if (runcd == RUN_CD) {
if (LoadCdrom() == -1) {
ClosePlugins();
printf(_("Could not load CD-ROM!\n"));
return -1;
}
}
}
// If a state has been specified, then load that
if (loadst) {
StatesC = loadst - 1;
gchar *state_filename = get_state_filename(StatesC);
LoadState(state_filename);
g_free(state_filename);
}
psxCpu->Execute();
}
return 0;
}
int SysInit() {
#ifdef EMU_LOG
#ifndef LOG_STDOUT
emuLog = fopen("emuLog.txt","wb");
#else
emuLog = stdout;
#endif
setvbuf(emuLog, NULL, _IONBF, 0);
#endif
if (EmuInit() == -1) {
printf(_("PSX emulator couldn't be initialized.\n"));
return -1;
}
LoadMcds(Config.Mcd1, Config.Mcd2); /* TODO Do we need to have this here, or in the calling main() function?? */
if (Config.Debug) {
StartDebugger();
}
return 0;
}
void SysReset() {
EmuReset();
}
void SysClose() {
EmuShutdown();
ReleasePlugins();
StopDebugger();
if (emuLog != NULL) fclose(emuLog);
}
void SysPrintf(const char *fmt, ...) {
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (Config.PsxOut) {
static char linestart = 1;
int l = strlen(msg);
printf(linestart ? " * %s" : "%s", msg);
if (l > 0 && msg[l - 1] == '\n') {
linestart = 1;
} else {
linestart = 0;
}
}
#ifdef EMU_LOG
#ifndef LOG_STDOUT
fprintf(emuLog, "%s", msg);
#endif
#endif
}
void *SysLoadLibrary(const char *lib) {
return dlopen(lib, RTLD_NOW);
}
void *SysLoadSym(void *lib, const char *sym) {
return dlsym(lib, sym);
}
const char *SysLibError() {
return dlerror();
}
void SysCloseLibrary(void *lib) {
dlclose(lib);
}
static void SysDisableScreenSaver() {
static time_t fake_key_timer = 0;
static char first_time = 1, has_test_ext = 0, t = 1;
Display *display;
extern unsigned long gpuDisp;
display = (Display *)gpuDisp;
if (first_time) {
// check if xtest is available
int a, b, c, d;
has_test_ext = XTestQueryExtension(display, &a, &b, &c, &d);
first_time = 0;
}
if (has_test_ext && fake_key_timer < time(NULL)) {
XTestFakeRelativeMotionEvent(display, t *= -1, 0, 0);
fake_key_timer = time(NULL) + 55;
}
}
void SysUpdate() {
PADhandleKey(PAD1_keypressed());
PADhandleKey(PAD2_keypressed());
SysDisableScreenSaver();
}
/* ADB TODO Replace RunGui() with StartGui ()*/
void SysRunGui() {
StartGui();
}

24
gui/Makefile.am Normal file
View File

@ -0,0 +1,24 @@
INCLUDES = -DPACKAGE_DATA_DIR=\"${datadir}/pcsx/\" \
-DPIXMAPDIR=\"${datadir}/pixmaps/\" \
-DLOCALE_DIR=\"${datadir}/locale/\" \
$(GTK2_CFLAGS) $(GLADE2_CFLAGS) \
-I$(top_srcdir)/libpcsxcore -I$(top_srcdir)/include \
-DPSEMU_DATA_DIR=\"${datadir}/psemu\" \
-DDEF_PLUGIN_DIR=\"${libdir}/games/psemu\"
bin_PROGRAMS = pcsx
pcsx_SOURCES = \
LnxMain.c \
Plugin.c \
Config.c \
Gtk2Gui.c \
MemcardDlg.c \
ConfDlg.c \
Cheat.c \
DebugMemory.c \
AboutDlg.c
pcsx_LDADD = \
$(GTK2_LIBS) $(GLADE2_LIBS) -lpthread -lz -lm -lXext -lXtst \
../libpcsxcore/libpcsxcore.a

538
gui/Makefile.in Normal file
View File

@ -0,0 +1,538 @@
# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
bin_PROGRAMS = pcsx$(EXEEXT)
subdir = gui
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_pcsx_OBJECTS = LnxMain.$(OBJEXT) Plugin.$(OBJEXT) Config.$(OBJEXT) \
Gtk2Gui.$(OBJEXT) MemcardDlg.$(OBJEXT) ConfDlg.$(OBJEXT) \
Cheat.$(OBJEXT) DebugMemory.$(OBJEXT) AboutDlg.$(OBJEXT)
pcsx_OBJECTS = $(am_pcsx_OBJECTS)
am__DEPENDENCIES_1 =
pcsx_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
../libpcsxcore/libpcsxcore.a
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(pcsx_SOURCES)
DIST_SOURCES = $(pcsx_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALSA_CFLAGS = @ALSA_CFLAGS@
ALSA_LIBS = @ALSA_LIBS@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
GLADE2_CFLAGS = @GLADE2_CFLAGS@
GLADE2_LIBS = @GLADE2_LIBS@
GLIB2_CFLAGS = @GLIB2_CFLAGS@
GLIB2_LIBS = @GLIB2_LIBS@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GREP = @GREP@
GTK2_CFLAGS = @GTK2_CFLAGS@
GTK2_LIBS = @GTK2_LIBS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBCDIO_CFLAGS = @LIBCDIO_CFLAGS@
LIBCDIO_LIBS = @LIBCDIO_LIBS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NASM = @NASM@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PEOPSXGL = @PEOPSXGL@
PKG_CONFIG = @PKG_CONFIG@
POSUB = @POSUB@
PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@
PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@
RANLIB = @RANLIB@
SDL_CFLAGS = @SDL_CFLAGS@
SDL_CONFIG = @SDL_CONFIG@
SDL_LIBS = @SDL_LIBS@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
INCLUDES = -DPACKAGE_DATA_DIR=\"${datadir}/pcsx/\" \
-DPIXMAPDIR=\"${datadir}/pixmaps/\" \
-DLOCALE_DIR=\"${datadir}/locale/\" \
$(GTK2_CFLAGS) $(GLADE2_CFLAGS) \
-I$(top_srcdir)/libpcsxcore -I$(top_srcdir)/include \
-DPSEMU_DATA_DIR=\"${datadir}/psemu\" \
-DDEF_PLUGIN_DIR=\"${libdir}/games/psemu\"
pcsx_SOURCES = \
LnxMain.c \
Plugin.c \
Config.c \
Gtk2Gui.c \
MemcardDlg.c \
ConfDlg.c \
Cheat.c \
DebugMemory.c \
AboutDlg.c
pcsx_LDADD = \
$(GTK2_LIBS) $(GLADE2_LIBS) -lpthread -lz -lm -lXext -lXtst \
../libpcsxcore/libpcsxcore.a
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu gui/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu gui/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
|| test -f $$p1 \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
pcsx$(EXEEXT): $(pcsx_OBJECTS) $(pcsx_DEPENDENCIES)
@rm -f pcsx$(EXEEXT)
$(LINK) $(pcsx_OBJECTS) $(pcsx_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AboutDlg.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cheat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfDlg.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Config.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DebugMemory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Gtk2Gui.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LnxMain.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MemcardDlg.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Plugin.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am: install-binPROGRAMS
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic clean-libtool ctags distclean distclean-compile \
distclean-generic distclean-libtool distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am \
uninstall-binPROGRAMS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

755
gui/MemcardDlg.c Normal file
View File

@ -0,0 +1,755 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <signal.h>
#include <sys/time.h>
#include "Linux.h"
#include "../libpcsxcore/sio.h"
#define MAX_MEMCARD_BLOCKS 15
static gboolean quit;
static unsigned int currentIcon;
McdBlock Blocks[2][MAX_MEMCARD_BLOCKS]; // Assuming 2 cards, 15 blocks?
int IconC[2][MAX_MEMCARD_BLOCKS];
enum {
CL_ICON,
CL_TITLE,
CL_STAT,
CL_ID,
CL_NAME,
NUM_CL
};
GtkWidget *GtkCList_McdList1, *GtkCList_McdList2;
static void AddColumns(GtkTreeView *treeview) {
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
// column for icon
renderer = gtk_cell_renderer_pixbuf_new ();
column = gtk_tree_view_column_new_with_attributes(_("Icon"),
renderer, "pixbuf", CL_ICON, NULL);
gtk_tree_view_append_column(treeview, column);
// column for title
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(_("Title"),
renderer, "text", CL_TITLE, NULL);
gtk_tree_view_append_column(treeview, column);
// column for status
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(_("Status"),
renderer, "text", CL_STAT, NULL);
gtk_tree_view_append_column(treeview, column);
// column for id
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(_("ID"),
renderer, "text", CL_ID, NULL);
gtk_tree_view_append_column(treeview, column);
// column for Name
renderer = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes(_("Name"),
renderer, "text", CL_NAME, NULL);
gtk_tree_view_append_column(treeview, column);
}
static GdkPixbuf *SetIcon(GtkWidget *dialog, short *icon, int i) {
GdkPixmap *pixmap;
GdkImage *image;
GdkVisual *visual;
GdkPixbuf *pixbuf;
GdkGC *gc;
int x, y, c;
visual = gdk_window_get_visual(dialog->window);
if (visual->depth == 8) return NULL;
image = gdk_image_new(GDK_IMAGE_NORMAL, visual, 32, 32);
for (y = 0; y < 32; y++) {
for (x = 0; x < 32; x++) {
c = icon[(y>>1) * 16 + (x>>1)];
c = ((c & 0x001f) << 10) | ((c & 0x7c00) >> 10) | (c & 0x03e0);
if (visual->depth == 16)
c = (c & 0x001f) | ((c & 0x7c00) << 1) | ((c & 0x03e0) << 1);
else if (visual->depth == 24 || visual->depth == 32)
c = ((c & 0x001f) << 3) | ((c & 0x03e0) << 6) | ((c & 0x7c00) << 9);
gdk_image_put_pixel(image, x, y, c);
}
}
pixmap = gdk_pixmap_new(dialog->window, 32, 32, visual->depth);
gc = gdk_gc_new(pixmap);
gdk_draw_image(pixmap, gc, image, 0, 0, 0, 0, 32, 32);
gdk_gc_destroy(gc);
gdk_image_destroy(image);
pixbuf = gdk_pixbuf_get_from_drawable(NULL, GDK_PIXMAP (pixmap), NULL,
0, 0, 0, 0, -1, -1);
g_object_unref(pixmap);
return pixbuf;
}
static void LoadListItems(int mcd, GtkWidget *widget) {
int i;
GladeXML *xml;
GtkWidget *List;
GtkWidget *dialog;
GtkListStore *store;
GtkTreeIter iter;
GdkPixbuf *pixbuf;
gchar *title;
store = gtk_list_store_new(NUM_CL, GDK_TYPE_PIXBUF, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
xml = glade_get_widget_tree(widget);
dialog = glade_xml_get_widget(xml, "McdsDlg");
if (mcd == 1) List = glade_xml_get_widget(xml, "GtkCList_McdList1");
else List = glade_xml_get_widget(xml, "GtkCList_McdList2");
for (i = 0; i < MAX_MEMCARD_BLOCKS; i++) {
McdBlock *Info;
gchar *state;
Info = &Blocks[mcd - 1][i];
IconC[mcd - 1][i] = 0;
if ((Info->Flags & 0xF0) == 0xA0) {
if ((Info->Flags & 0xF) >= 1 &&
(Info->Flags & 0xF) <= 3) {
state = _("Deleted");
} else
state = _("Free");
} else if ((Info->Flags & 0xF0) == 0x50)
state = _("Used");
else
state = _("Free");
pixbuf = SetIcon(dialog, Info->Icon, i + 1);
gtk_list_store_append(store, &iter);
title = g_convert(Info->sTitle, strlen(Info->sTitle), "UTF-8",
"Shift-JIS", NULL, NULL, NULL);
gtk_list_store_set(store, &iter,
CL_ICON, pixbuf,
CL_TITLE, title,
CL_STAT, state,
CL_NAME, Info->Name,
CL_ID, Info->ID,
-1);
g_free(title);
g_object_unref(pixbuf);
}
gtk_tree_view_set_model(GTK_TREE_VIEW(List), GTK_TREE_MODEL(store));
g_object_unref(G_OBJECT(store));
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(List), TRUE);
gtk_widget_show(List);
}
static void UpdateFilenameButtons(GtkWidget *widget) {
int i;
GladeXML *xml;
GtkWidget *dialog;
const char *filename;
gchar *p;
xml = glade_get_widget_tree(widget);
dialog = glade_xml_get_widget(xml, "McdsDlg");
for (i = 0; i < 2; i++) {
if (i == 0) {
widget = glade_xml_get_widget(xml, "Mcd1Label");
filename = Config.Mcd1;
} else {
widget = glade_xml_get_widget(xml, "Mcd2Label");
filename = Config.Mcd2;
}
p = g_path_get_basename(filename);
gtk_label_set_text(GTK_LABEL(widget), p);
g_free(p);
}
}
static void LoadMcdDlg(GtkWidget *widget) {
int i;
for (i = 0; i < MAX_MEMCARD_BLOCKS; i++) {
GetMcdBlockInfo(1, i + 1, &Blocks[0][i]);
GetMcdBlockInfo(2, i + 1, &Blocks[1][i]);
}
LoadListItems(1, widget);
LoadListItems(2, widget);
UpdateFilenameButtons(widget);
}
static void OnTreeSelectionChanged(GtkTreeSelection *selection, gpointer user_data);
static void UpdateListItems(int mcd, GtkWidget *widget) {
GladeXML *xml;
GtkWidget *List;
GtkWidget *dialog;
GtkListStore *store;
GtkTreeIter iter;
GdkPixbuf *pixbuf;
short *pIcon;
int i;
gchar *title;
xml = glade_get_widget_tree(widget);
dialog = glade_xml_get_widget(xml, "McdsDlg");
if (mcd == 1) List = glade_xml_get_widget(xml, "GtkCList_McdList1");
else List = glade_xml_get_widget(xml, "GtkCList_McdList2");
store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(List)));
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
for (i = 0; i < MAX_MEMCARD_BLOCKS; i++) {
McdBlock *Info;
gchar *state;
Info = &Blocks[mcd - 1][i];
IconC[mcd - 1][i] = 0;
if ((Info->Flags & 0xF0) == 0xA0) {
if ((Info->Flags & 0xF) >= 1 &&
(Info->Flags & 0xF) <= 3) {
state = _("Deleted");
} else
state = _("Free");
} else if ((Info->Flags & 0xF0) == 0x50)
state = _("Used");
else
state = _("Free");
if (Info->IconCount > 0) {
pIcon = &Info->Icon[(currentIcon % Info->IconCount) * 16 * 16];
} else {
pIcon = Info->Icon;
}
pixbuf = SetIcon(dialog, pIcon, i + 1);
title = g_convert(Info->sTitle, strlen(Info->sTitle), "UTF-8",
"Shift-JIS", NULL, NULL, NULL);
gtk_list_store_set(store, &iter,
CL_ICON, pixbuf,
CL_TITLE, title,
CL_STAT, state,
CL_NAME, Info->Name,
CL_ID, Info->ID,
-1);
g_free(title);
g_object_unref(pixbuf);
gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
}
gtk_widget_show(List);
OnTreeSelectionChanged(gtk_tree_view_get_selection(GTK_TREE_VIEW(List)), (gpointer)mcd);
}
static void UpdateMcdDlg(GtkWidget *widget) {
int i;
for (i = 0; i < MAX_MEMCARD_BLOCKS; i++) {
GetMcdBlockInfo(1, i + 1, &Blocks[0][i]);
GetMcdBlockInfo(2, i + 1, &Blocks[1][i]);
}
UpdateListItems(1, widget);
UpdateListItems(2, widget);
UpdateFilenameButtons(widget);
}
static void OnMcd_Close(GtkDialog *dialog, gint arg1, gpointer user_data) {
quit = TRUE;
SaveConfig();
gtk_widget_destroy(GTK_WIDGET(dialog));
}
static void OnMcd_FileChange(GtkWidget *widget, gpointer user_data) {
gint memcard = (int)user_data;
gchar *filename;
GtkWidget *chooser;
// Ask for name of memory card
chooser = gtk_file_chooser_dialog_new(_("Select A File"),
NULL, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_OK,
NULL);
if (memcard == 1)
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser), Config.Mcd1);
else
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser), Config.Mcd2);
if (gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_OK) {
gtk_widget_hide(chooser);
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
if (filename != NULL) {
if (memcard == 1) strncpy(Config.Mcd1, filename, MAXPATHLEN);
else strncpy(Config.Mcd2, filename, MAXPATHLEN);
LoadMcd(memcard, filename);
LoadMcdDlg(widget);
g_free(filename);
}
}
gtk_widget_destroy(chooser);
}
// format a memory card
static void OnMcd_Format(GtkWidget *widget, gpointer user_data) {
GladeXML *xml;
GtkWidget *message_dialog;
gint result;
char *str;
gint memcard = (int)user_data;
message_dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
_("Format this Memory Card?"));
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(message_dialog),
_("If you format the memory card, the card will be empty, and any existing data overwritten."));
gtk_dialog_add_buttons(GTK_DIALOG(message_dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("Format card"), GTK_RESPONSE_YES, NULL);
result = gtk_dialog_run(GTK_DIALOG(message_dialog));
gtk_widget_destroy(message_dialog);
if (result == GTK_RESPONSE_YES) {
xml = glade_get_widget_tree(widget);
if (memcard == 1) str = Config.Mcd1;
else str = Config.Mcd2;
CreateMcd(str);
LoadMcd(memcard, str);
UpdateMcdDlg(widget);
}
}
// create a new, formatted memory card
static void OnMcd_New(GtkWidget *widget, gpointer user_data) {
GtkWidget *chooser;
gchar *path;
// Ask for name of new memory card
chooser = gtk_file_chooser_dialog_new(_("Create a new Memory Card"),
NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
NULL);
// Card should be put into $HOME/.pcsx/memcards
path = g_build_filename(g_get_home_dir(), ".pcsx", "memcards", NULL);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), path);
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(chooser), _("New Memory Card.mcd"));
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(chooser), TRUE);
if (gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_OK) {
gchar *name;
gtk_widget_hide(chooser);
name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
CreateMcd(name);
if ((int)user_data == 1) strncpy(Config.Mcd1, name, MAXPATHLEN);
else strncpy(Config.Mcd2, name, MAXPATHLEN);
LoadMcd((int)user_data, name);
LoadMcdDlg(widget);
g_free(name);
}
gtk_widget_destroy(chooser);
g_free(path);
}
static int copy = 0, copymcd = 0;
static int GetFreeMemcardSlot(int target_card) {
McdBlock *Info;
gboolean found = FALSE;
int i = 0;
while (i < 15 && found == FALSE) {
Info = &Blocks[target_card][i];
if (g_ascii_strcasecmp(Info->Title, "") == 0) {
found = TRUE;
} else {
i++;
}
}
if (found == TRUE)
return i;
// no free slots, try to find a deleted one
i = 0;
while (i < 15 && found == FALSE) {
Info = &Blocks[target_card][i];
if ((Info->Flags & 0xF0) != 0x50) {
found = TRUE;
} else {
i++;
}
}
if (found == TRUE)
return i;
return -1;
}
static void CopyMemcardData(char *from, char *to, gint *i, gchar *str) {
memcpy(to + (*i + 1) * 128, from + (copy + 1) * 128, 128);
SaveMcd((char *)str, to, (*i + 1) * 128, 128);
memcpy(to + (*i + 1) * 1024 * 8, from + (copy+1) * 1024 * 8, 1024 * 8);
SaveMcd((char *)str, to, (*i + 1) * 1024 * 8, 1024 * 8);
}
static void OnMcd_CopyTo(GtkWidget *widget, gpointer user_data) {
gint mcd = (gint)user_data;
GtkTreeIter iter;
GtkTreeModel *model;
GtkTreePath *path;
gint *i;
GladeXML *xml;
GtkTreeSelection *treesel;
gchar *str;
char *source, *destination;
int first_free_slot;
xml = glade_get_widget_tree(widget);
if (mcd == 1)
treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(GtkCList_McdList2));
else
treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(GtkCList_McdList1));
// If the item selected is not reported as a 'Free' slot
if (gtk_tree_selection_get_selected(treesel, &model, &iter)) {
path = gtk_tree_model_get_path(model, &iter);
i = gtk_tree_path_get_indices(path);
copy = *i;
copymcd = mcd;
gtk_tree_path_free(path);
}
// Determine the first free slot in the target memory card
first_free_slot = GetFreeMemcardSlot(mcd - 1);
if (first_free_slot == -1) {
// No free slots available on the destination card
SysErrorMessage(_("No free space on memory card"),
_("There are no free slots available on the target memory card. Please delete a slot first."));
return;
}
xml = glade_get_widget_tree(GtkCList_McdList1);
if (mcd == 1) {
str = Config.Mcd1;
source = Mcd2Data;
destination = Mcd1Data;
} else {
str = Config.Mcd2;
source = Mcd1Data;
destination = Mcd2Data;
}
CopyMemcardData(source, destination, &first_free_slot, str);
UpdateMcdDlg(widget);
}
static void OnMemcardDelete(GtkWidget *widget, gpointer user_data) {
McdBlock *Info;
int i, xor = 0, j;
char *data, *ptr;
GtkTreeIter iter;
GtkTreeModel *model;
GtkTreePath *path;
gchar *filename;
GladeXML *xml;
gboolean selected;
GtkWidget *tree;
GtkTreeSelection *sel;
gint memcard = (int)user_data;
xml = glade_get_widget_tree(widget);
if (memcard == 1) {
tree = glade_xml_get_widget(xml, "GtkCList_McdList1");
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW (tree));
selected = gtk_tree_selection_get_selected (sel, &model, &iter);
data = Mcd1Data;
filename = Config.Mcd1;
} else {
tree = glade_xml_get_widget(xml, "GtkCList_McdList2");
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW (tree));
selected = gtk_tree_selection_get_selected(sel, &model, &iter);
data = Mcd2Data;
filename = Config.Mcd2;
}
if (selected) {
path = gtk_tree_model_get_path(model, &iter);
i = *gtk_tree_path_get_indices(path);
i++;
ptr = data + i * 128;
Info = &Blocks[memcard - 1][i - 1];
if ((Info->Flags & 0xF0) == 0xA0) {
if ((Info->Flags & 0xF) >= 1 &&
(Info->Flags & 0xF) <= 3) { // deleted
*ptr = 0x50 | (Info->Flags & 0xF);
} else return;
} else if ((Info->Flags & 0xF0) == 0x50) { // used
*ptr = 0xA0 | (Info->Flags & 0xF);
} else { return; }
for (j = 0; j < 127; j++) xor ^= *ptr++;
*ptr = xor;
SaveMcd((char *)filename, data, i * 128, 128);
UpdateMcdDlg(widget);
}
}
static void OnTreeSelectionChanged(GtkTreeSelection *selection, gpointer user_data) {
GladeXML *xml;
GtkTreeIter iter;
GtkTreeModel *model;
GtkTreePath *path;
gboolean selected;
int i;
McdBlock b;
gint memcard = (int)user_data;
xml = glade_get_widget_tree(GtkCList_McdList1);
selected = gtk_tree_selection_get_selected(selection, &model, &iter);
if (selected) {
path = gtk_tree_model_get_path(model, &iter);
i = *gtk_tree_path_get_indices(path);
gtk_tree_path_free(path);
// If a row was selected, and the row is not blank, we can now enable
// some of the disabled widgets
if (memcard == 1) {
GetMcdBlockInfo(1, i + 1, &b);
if ((b.Flags >= 0xA1 && b.Flags <= 0xA3) || ((b.Flags & 0xF0) == 0x50)) {
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_Delete1"), TRUE);
} else {
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_Delete1"), FALSE);
}
if ((b.Flags & 0xF0) == 0x50) {
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_CopyTo2"), TRUE);
} else {
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_CopyTo2"), FALSE);
}
} else {
GetMcdBlockInfo(2, i + 1, &b);
if ((b.Flags >= 0xA1 && b.Flags <= 0xA3) || ((b.Flags & 0xF0) == 0x50)) {
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_Delete2"), TRUE);
} else {
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_Delete2"), FALSE);
}
if ((b.Flags & 0xF0) == 0x50) {
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_CopyTo1"), TRUE);
} else {
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_CopyTo1"), FALSE);
}
}
} else {
if (memcard == 1) {
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_CopyTo2"), FALSE);
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_Delete1"), FALSE);
} else {
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_CopyTo1"), FALSE);
gtk_widget_set_sensitive(glade_xml_get_widget(xml, "GtkButton_Delete2"), FALSE);
}
}
}
gboolean updateFunc(gpointer data) {
if (quit) return FALSE;
currentIcon++;
UpdateListItems(1, GtkCList_McdList1);
UpdateListItems(2, GtkCList_McdList2);
g_timeout_add(333, updateFunc, 0);
return FALSE;
}
void OnConf_Mcds() {
GladeXML *xml;
GtkWidget *dialog;
GtkWidget *widget;
GtkTreeSelection *treesel1, *treesel2;
gchar *str;
xml = glade_xml_new(PACKAGE_DATA_DIR "pcsx.glade2", "McdsDlg", NULL);
if (!xml) {
g_warning("We could not load the interface!");
return;
}
dialog = glade_xml_get_widget(xml, "McdsDlg");
gtk_window_set_title(GTK_WINDOW(dialog), _("Memory Card Manager"));
// Assign default memory cards
if (!strlen(Config.Mcd1)) {
str = g_strconcat(getenv("HOME"), DEFAULT_MEM_CARD_1, NULL);
strcpy(Config.Mcd1, str);
g_free(str);
}
if (!strlen(Config.Mcd2)) {
str = g_strconcat(getenv("HOME"), DEFAULT_MEM_CARD_2, NULL);
strcpy(Config.Mcd2, str);
g_free(str);
}
GtkCList_McdList1 = glade_xml_get_widget(xml, "GtkCList_McdList1");
AddColumns(GTK_TREE_VIEW(GtkCList_McdList1));
GtkCList_McdList2 = glade_xml_get_widget(xml, "GtkCList_McdList2");
AddColumns(GTK_TREE_VIEW(GtkCList_McdList2));
treesel1 = gtk_tree_view_get_selection(GTK_TREE_VIEW (GtkCList_McdList1));
gtk_tree_selection_set_mode(treesel1, GTK_SELECTION_SINGLE);
g_signal_connect_data(G_OBJECT(treesel1), "changed",
G_CALLBACK(OnTreeSelectionChanged),
(gpointer)1, NULL, G_CONNECT_AFTER);
treesel2 = gtk_tree_view_get_selection(GTK_TREE_VIEW (GtkCList_McdList2));
gtk_tree_selection_set_mode(treesel2, GTK_SELECTION_SINGLE);
g_signal_connect_data(G_OBJECT(treesel2), "changed",
G_CALLBACK(OnTreeSelectionChanged),
(gpointer)2, NULL, G_CONNECT_AFTER);
LoadMcdDlg(dialog);
// Setup a handler for when Close or Cancel is clicked
g_signal_connect_data(GTK_OBJECT(dialog), "response",
GTK_SIGNAL_FUNC(OnMcd_Close), xml, (GClosureNotify)g_object_unref, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkButton_Format1");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnMcd_Format), (gpointer)1, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkButton_Format2");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnMcd_Format), (gpointer)2, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "Mcd1Button");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnMcd_FileChange), (gpointer)1, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "Mcd2Button");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnMcd_FileChange), (gpointer)2, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkButton_New1");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnMcd_New), (gpointer)1, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkButton_New2");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnMcd_New), (gpointer)2, NULL, G_CONNECT_AFTER);
widget = glade_xml_get_widget(xml, "GtkButton_CopyTo1");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnMcd_CopyTo), (gpointer)1, NULL, G_CONNECT_AFTER);
gtk_widget_set_sensitive(GTK_WIDGET(widget), FALSE);
widget = glade_xml_get_widget(xml, "GtkButton_CopyTo2");
g_signal_connect_data(GTK_OBJECT(widget), "clicked",
GTK_SIGNAL_FUNC(OnMcd_CopyTo), (gpointer)2, NULL, G_CONNECT_AFTER);
gtk_widget_set_sensitive(GTK_WIDGET(widget), FALSE);
widget = glade_xml_get_widget(xml, "GtkButton_Delete1");
g_signal_connect_data (GTK_OBJECT (widget), "clicked",
GTK_SIGNAL_FUNC(OnMemcardDelete), (gpointer)1, NULL, G_CONNECT_AFTER);
gtk_widget_set_sensitive(GTK_WIDGET(widget), FALSE);
widget = glade_xml_get_widget(xml, "GtkButton_Delete2");
g_signal_connect_data (GTK_OBJECT (widget), "clicked",
GTK_SIGNAL_FUNC(OnMemcardDelete), (gpointer)2, NULL, G_CONNECT_AFTER);
gtk_widget_set_sensitive(GTK_WIDGET(widget), FALSE);
quit = FALSE;
currentIcon = 0;
g_timeout_add(1, updateFunc, 0);
while (gtk_events_pending()) { gtk_main_iteration(); }
}

24
gui/MemcardDlg.h Normal file
View File

@ -0,0 +1,24 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#ifndef MEMCARDDLG_H
#define MEMCARDDLG_H
void OnConf_Mcds();
#endif

390
gui/Plugin.c Normal file
View File

@ -0,0 +1,390 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2002 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include <X11/keysym.h>
#include <signal.h>
#include "Linux.h"
#include "../libpcsxcore/plugins.h"
#include "../libpcsxcore/spu.h"
#include "../libpcsxcore/cdriso.h"
#include "nopic.h"
#define MAX_SLOTS 5 /* ADB TODO Same as Gtk2Gui.c */
void OnFile_Exit();
unsigned long gpuDisp;
int StatesC = 0;
extern int UseGui;
int ShowPic = 0;
void gpuShowPic() {
gchar *state_filename;
gzFile f;
if (!ShowPic) {
unsigned char *pMem;
pMem = (unsigned char *) malloc(128*96*3);
if (pMem == NULL) return;
state_filename = get_state_filename (StatesC);
GPU_freeze(2, (GPUFreeze_t *)&StatesC);
f = gzopen(state_filename, "rb");
if (f != NULL) {
gzseek(f, 32, SEEK_SET); // skip header
gzread(f, pMem, 128*96*3);
gzclose(f);
} else {
memcpy(pMem, NoPic_Image.pixel_data, 128*96*3);
DrawNumBorPic(pMem, StatesC+1);
}
GPU_showScreenPic(pMem);
free(pMem);
ShowPic = 1;
g_free (state_filename);
} else {
GPU_showScreenPic(NULL);
ShowPic = 0;
}
}
void KeyStateSave(int i) {
gchar *state_filename;
state_filename = get_state_filename (i);
state_save (state_filename);
g_free (state_filename);
}
void KeyStateLoad(int i) {
gchar *state_filename;
state_filename = get_state_filename (i);
state_load (state_filename);
g_free (state_filename);
// HACKHACK: prevent crash when using recompiler due to execution not
// returned from compiled code. This WILL cause memory leak, however a
// large amount of refactor is needed for a proper fix.
if (Config.Cpu == CPU_DYNAREC) psxCpu->Execute();
}
static short modctrl = 0, modalt = 0;
/* Handle keyboard keystrokes */
void PADhandleKey(int key) {
char Text[MAXPATHLEN];
gchar *state_filename;
short rel = 0; //released key flag
if (key == 0)
return;
if ((key >> 30) & 1) //specific to dfinput (padJoy)
rel = 1;
if (rel) {
switch (key & ~0x40000000) {
case XK_Alt_L:
case XK_Alt_R:
modalt=0;
break;
case XK_Control_L:
case XK_Control_R:
modctrl=0;
break;
}
return;
}
switch (key) {
case XK_Alt_L:
case XK_Alt_R:
modalt=1;
break;
case XK_Control_L:
case XK_Control_R:
modctrl=1;
break;
case XK_0:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(10);
break;
case XK_1:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(0);
if (modctrl) KeyStateSave(0);
break;
case XK_2:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(1);
if (modctrl) KeyStateSave(1);
break;
case XK_3:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(2);
if (modctrl) KeyStateSave(2);
break;
case XK_4:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(3);
if (modctrl) KeyStateSave(3);
break;
case XK_5:
if (modalt && modctrl)
return;
if (modalt) KeyStateLoad(4);
if (modctrl) KeyStateSave(4);
break;
case XK_F1:
GPU_freeze(2, (GPUFreeze_t *)&StatesC);
state_filename = get_state_filename (StatesC);
state_save (state_filename);
g_free (state_filename);
if (ShowPic) { ShowPic = 0; gpuShowPic(); }
break;
case XK_F2:
if (StatesC < (MAX_SLOTS - 1)) StatesC++;
else StatesC = 0;
GPU_freeze(2, (GPUFreeze_t *)&StatesC);
if (ShowPic) { ShowPic = 0; gpuShowPic(); }
break;
case XK_F3:
state_filename = get_state_filename (StatesC);
state_load (state_filename);
g_free (state_filename);
// HACKHACK: prevent crash when using recompiler due to execution not
// returned from compiled code. This WILL cause memory leak, however a
// large amount of refactor is needed for a proper fix.
if (Config.Cpu == CPU_DYNAREC) psxCpu->Execute();
break;
case XK_F4:
gpuShowPic();
break;
case XK_F5:
Config.Sio ^= 0x1;
if (Config.Sio)
sprintf(Text, _("SIO IRQ Always Enabled"));
else sprintf(Text, _("SIO IRQ Not Always Enabled"));
GPU_displayText(Text);
break;
case XK_F6:
Config.Mdec ^= 0x1;
if (Config.Mdec)
sprintf(Text, _("Black & White Mdecs Only Enabled"));
else sprintf(Text, _("Black & White Mdecs Only Disabled"));
GPU_displayText(Text);
break;
case XK_F7:
Config.Xa ^= 0x1;
if (Config.Xa == 0)
sprintf (Text, _("XA Enabled"));
else sprintf (Text, _("XA Disabled"));
GPU_displayText(Text);
break;
case XK_F8:
GPU_makeSnapshot();
break;
case XK_F9:
SetCdOpenCaseTime(-1);
break;
case XK_F10:
SetCdOpenCaseTime(0);
break;
case XK_Escape:
// TODO
// the architecture is too broken to actually restart the GUI
// because SysUpdate is called from deep within the actual
// execution of the emulation code
// Fixing this would probably require a complete reworking of
// all functions, so that they return 0 or 1 for success
// that way, execution wouldn't continue
if (CdromId[0] != '\0')
KeyStateSave(10);
ClosePlugins();
UpdateMenuSlots();
if (!UseGui) OnFile_Exit();
StartGui();
break;
case XK_Return: //0xff0d
if (modalt) //alt-return
//I just made this up: a special sym for fullscreen because the current interface can't handle key mods
//though it can be used in the future as a convention...eg bit 29 for alt, bit 28 for cntl, etc.
GPU_keypressed( (1<<29) | 0xFF0D );
break;
default:
GPU_keypressed(key);
if (Config.UseNet) NET_keypressed(key);
}
}
void OnFile_Exit();
void SignalExit(int sig) {
ClosePlugins();
OnFile_Exit();
}
#define PARSEPATH(dst, src) \
ptr = src + strlen(src); \
while (*ptr != '\\' && ptr != src) ptr--; \
if (ptr != src) { \
strcpy(dst, ptr+1); \
}
int _OpenPlugins() {
int ret;
signal(SIGINT, SignalExit);
signal(SIGPIPE, SignalExit);
GPU_clearDynarec(clearDynarec);
ret = CDR_open();
if (ret < 0) { SysMessage(_("Error opening CD-ROM plugin!")); return -1; }
ret = SPU_open();
if (ret < 0) { SysMessage(_("Error opening SPU plugin!")); return -1; }
SPU_registerCallback(SPUirq);
ret = GPU_open(&gpuDisp, "PCSX", NULL);
if (ret < 0) { SysMessage(_("Error opening GPU plugin!")); return -1; }
ret = PAD1_open(&gpuDisp);
if (ret < 0) { SysMessage(_("Error opening Controller 1 plugin!")); return -1; }
ret = PAD2_open(&gpuDisp);
if (ret < 0) { SysMessage(_("Error opening Controller 2 plugin!")); return -1; }
if (Config.UseNet && !NetOpened) {
netInfo info;
char path[MAXPATHLEN];
char dotdir[MAXPATHLEN];
strncpy(dotdir, getenv("HOME"), MAXPATHLEN-100);
strcat(dotdir, "/.pcsx/plugins/");
strcpy(info.EmuName, "PCSX " PACKAGE_VERSION);
strncpy(info.CdromID, CdromId, 9);
strncpy(info.CdromLabel, CdromLabel, 9);
info.psxMem = psxM;
info.GPU_showScreenPic = GPU_showScreenPic;
info.GPU_displayText = GPU_displayText;
info.GPU_showScreenPic = GPU_showScreenPic;
info.PAD_setSensitive = PAD1_setSensitive;
sprintf(path, "%s%s", Config.BiosDir, Config.Bios);
strcpy(info.BIOSpath, path);
strcpy(info.MCD1path, Config.Mcd1);
strcpy(info.MCD2path, Config.Mcd2);
sprintf(path, "%s%s", dotdir, Config.Gpu);
strcpy(info.GPUpath, path);
sprintf(path, "%s%s", dotdir, Config.Spu);
strcpy(info.SPUpath, path);
sprintf(path, "%s%s", dotdir, Config.Cdr);
strcpy(info.CDRpath, path);
NET_setInfo(&info);
ret = NET_open(&gpuDisp);
if (ret < 0) {
if (ret == -2) {
// -2 is returned when something in the info
// changed and needs to be synced
char *ptr;
PARSEPATH(Config.Bios, info.BIOSpath);
PARSEPATH(Config.Gpu, info.GPUpath);
PARSEPATH(Config.Spu, info.SPUpath);
PARSEPATH(Config.Cdr, info.CDRpath);
strcpy(Config.Mcd1, info.MCD1path);
strcpy(Config.Mcd2, info.MCD2path);
return -2;
} else {
Config.UseNet = FALSE;
}
} else {
if (NET_queryPlayer() == 1) {
if (SendPcsxInfo() == -1) Config.UseNet = FALSE;
} else {
if (RecvPcsxInfo() == -1) Config.UseNet = FALSE;
}
}
NetOpened = TRUE;
} else if (Config.UseNet) {
NET_resume();
}
return 0;
}
int OpenPlugins() {
int ret;
while ((ret = _OpenPlugins()) == -2) {
ReleasePlugins();
LoadMcds(Config.Mcd1, Config.Mcd2);
if (LoadPlugins() == -1) return -1;
}
return ret;
}
void ClosePlugins() {
int ret;
signal(SIGINT, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
ret = CDR_close();
if (ret < 0) { SysMessage(_("Error closing CD-ROM plugin!")); return; }
ret = SPU_close();
if (ret < 0) { SysMessage(_("Error closing SPU plugin!")); return; }
ret = PAD1_close();
if (ret < 0) { SysMessage(_("Error closing Controller 1 Plugin!")); return; }
ret = PAD2_close();
if (ret < 0) { SysMessage(_("Error closing Controller 2 plugin!")); return; }
ret = GPU_close();
if (ret < 0) { SysMessage(_("Error closing GPU plugin!")); return; }
if (Config.UseNet) {
NET_pause();
}
}

1345
gui/nopic.h Normal file

File diff suppressed because it is too large Load Diff

120
include/config.h.in Normal file
View File

@ -0,0 +1,120 @@
/* include/config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
/* gettext domain */
#undef GETTEXT_PACKAGE
/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
CoreFoundation framework. */
#undef HAVE_CFLOCALECOPYCURRENT
/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in
the CoreFoundation framework. */
#undef HAVE_CFPREFERENCESCOPYAPPVALUE
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
#undef HAVE_DCGETTEXT
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define if the GNU gettext() function is already present or preinstalled. */
#undef HAVE_GETTEXT
/* Define if you have the iconv() function and it works. */
#undef HAVE_ICONV
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Define to the maximum length of any path. */
#undef MAXPATHLEN
/* Define if we are compiling without dynamic recompiler. */
#undef NOPSXREC
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* define on a big endian system */
#undef __BIGENDIAN__
/* Define if building on a GNU/Linux system. */
#undef __LINUX__
/* Define if we are compiling for x86 architectures. */
#undef __i386__
/* Define if we are compiling for powerpc architectures. */
#undef __ppc__
/* Define if we are compiling for x86_64 architectures. */
#undef __x86_64__

519
install-sh Executable file
View File

@ -0,0 +1,519 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2006-12-25.00
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
shift;;
-T) no_target_directory=true;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
trap '(exit $?); exit' 1 2 13 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writeable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
-*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set fnord $dstdir
shift
$posix_glob set +f
IFS=$oIFS
prefixes=
for d
do
test -z "$d" && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

84
libpcsxcore/Makefile.am Normal file
View File

@ -0,0 +1,84 @@
INCLUDES = -DLOCALE_DIR=\"${datadir}/locale/\" \
-I$(top_srcdir)/include
noinst_LIBRARIES = libpcsxcore.a
libpcsxcore_a_SOURCES = \
$(top_builddir)/libpcsxcore/psxbios.c \
$(top_builddir)/libpcsxcore/cdrom.c \
$(top_builddir)/libpcsxcore/psxcounters.c \
$(top_builddir)/libpcsxcore/psxdma.c \
$(top_builddir)/libpcsxcore/disr3000a.c \
$(top_builddir)/libpcsxcore/spu.c \
$(top_builddir)/libpcsxcore/sio.c \
$(top_builddir)/libpcsxcore/psxhw.c \
$(top_builddir)/libpcsxcore/mdec.c \
$(top_builddir)/libpcsxcore/psxmem.c \
$(top_builddir)/libpcsxcore/misc.c \
$(top_builddir)/libpcsxcore/plugins.c \
$(top_builddir)/libpcsxcore/decode_xa.c \
$(top_builddir)/libpcsxcore/r3000a.c \
$(top_builddir)/libpcsxcore/psxinterpreter.c \
$(top_builddir)/libpcsxcore/gte.c \
$(top_builddir)/libpcsxcore/psxhle.c \
$(top_builddir)/libpcsxcore/cdrom.h \
$(top_builddir)/libpcsxcore/coff.h \
$(top_builddir)/libpcsxcore/debug.c \
$(top_builddir)/libpcsxcore/debug.h \
$(top_builddir)/libpcsxcore/decode_xa.h \
$(top_builddir)/libpcsxcore/gte.h \
$(top_builddir)/libpcsxcore/gte_divider.h \
$(top_builddir)/libpcsxcore/mdec.h \
$(top_builddir)/libpcsxcore/misc.h \
$(top_builddir)/libpcsxcore/plugins.h \
$(top_builddir)/libpcsxcore/psemu_plugin_defs.h \
$(top_builddir)/libpcsxcore/psxbios.h \
$(top_builddir)/libpcsxcore/psxcommon.c \
$(top_builddir)/libpcsxcore/psxcommon.h \
$(top_builddir)/libpcsxcore/psxcounters.h \
$(top_builddir)/libpcsxcore/psxdma.h \
$(top_builddir)/libpcsxcore/psxhle.h \
$(top_builddir)/libpcsxcore/psxhw.h \
$(top_builddir)/libpcsxcore/psxmem.h \
$(top_builddir)/libpcsxcore/r3000a.h \
$(top_builddir)/libpcsxcore/sio.h \
$(top_builddir)/libpcsxcore/sjisfont.h \
$(top_builddir)/libpcsxcore/spu.h \
$(top_builddir)/libpcsxcore/system.h \
$(top_builddir)/libpcsxcore/cdriso.c \
$(top_builddir)/libpcsxcore/cdriso.h \
$(top_builddir)/libpcsxcore/cheat.c \
$(top_builddir)/libpcsxcore/cheat.h \
$(top_builddir)/libpcsxcore/socket.c \
$(top_builddir)/libpcsxcore/socket.h \
$(top_builddir)/libpcsxcore/ppf.c \
$(top_builddir)/libpcsxcore/ppf.h
if ARCH_X86_64
libpcsxcore_a_SOURCES += \
$(top_builddir)/libpcsxcore/ix86_64/iR3000A-64.c \
$(top_builddir)/libpcsxcore/ix86_64/ix86-64.c \
$(top_builddir)/libpcsxcore/ix86_64/ix86_cpudetect.c \
$(top_builddir)/libpcsxcore/ix86_64/ix86_fpu.c \
$(top_builddir)/libpcsxcore/ix86_64/ix86_3dnow.c \
$(top_builddir)/libpcsxcore/ix86_64/ix86_mmx.c \
$(top_builddir)/libpcsxcore/ix86_64/ix86_sse.c \
$(top_builddir)/libpcsxcore/
else
if ARCH_X86
libpcsxcore_a_SOURCES += \
$(top_builddir)/libpcsxcore/ix86/iR3000A.c \
$(top_builddir)/libpcsxcore/ix86/ix86.c \
$(top_builddir)/libpcsxcore/
endif
endif
if ARCH_PPC
libpcsxcore_a_SOURCES += \
$(top_builddir)/libpcsxcore/ppc/pR3000A.c \
$(top_builddir)/libpcsxcore/ppc/ppc.c \
$(top_builddir)/libpcsxcore/ppc/reguse.c \
$(top_builddir)/libpcsxcore/ppc/pasm.s \
$(top_builddir)/libpcsxcore/
libpcsxcore_a_CCASFLAGS = -x assembler-with-cpp -mregnames
endif

1174
libpcsxcore/Makefile.in Normal file

File diff suppressed because it is too large Load Diff

881
libpcsxcore/cdriso.c Normal file
View File

@ -0,0 +1,881 @@
/***************************************************************************
* Copyright (C) 2007 PCSX-df Team *
* Copyright (C) 2009 Wei Mingzhi *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#include "psxcommon.h"
#include "plugins.h"
#include "cdrom.h"
#include "cdriso.h"
#ifdef _WIN32
#include <process.h>
#include <windows.h>
#else
#include <pthread.h>
#include <sys/time.h>
#endif
static FILE *cdHandle = NULL;
static FILE *cddaHandle = NULL;
static FILE *subHandle = NULL;
static boolean subChanMixed = FALSE;
static boolean subChanRaw = FALSE;
static unsigned char cdbuffer[DATA_SIZE];
static unsigned char subbuffer[SUB_FRAMESIZE];
static unsigned char sndbuffer[CD_FRAMESIZE_RAW * 10];
#define CDDA_FRAMETIME (1000 * (sizeof(sndbuffer) / CD_FRAMESIZE_RAW) / 75)
#ifdef _WIN32
static HANDLE threadid;
#else
static pthread_t threadid;
#endif
static unsigned int initial_offset = 0;
static volatile boolean playing = FALSE;
static boolean cddaBigEndian = FALSE;
static volatile unsigned int cddaCurOffset = 0;
char* CALLBACK CDR__getDriveLetter(void);
long CALLBACK CDR__configure(void);
long CALLBACK CDR__test(void);
void CALLBACK CDR__about(void);
long CALLBACK CDR__setfilename(char *filename);
long CALLBACK CDR__getStatus(struct CdrStat *stat);
extern void *hCDRDriver;
struct trackinfo {
enum {DATA, CDDA} type;
char start[3]; // MSF-format
char length[3]; // MSF-format
};
#define MAXTRACKS 100 /* How many tracks can a CD hold? */
static int numtracks = 0;
static struct trackinfo ti[MAXTRACKS];
// get a sector from a msf-array
static unsigned int msf2sec(char *msf) {
return ((msf[0] * 60 + msf[1]) * 75) + msf[2];
}
static void sec2msf(unsigned int s, char *msf) {
msf[0] = s / 75 / 60;
s = s - msf[0] * 75 * 60;
msf[1] = s / 75;
s = s - msf[1] * 75;
msf[2] = s;
}
// divide a string of xx:yy:zz into m, s, f
static void tok2msf(char *time, char *msf) {
char *token;
token = strtok(time, ":");
if (token) {
msf[0] = atoi(token);
}
else {
msf[0] = 0;
}
token = strtok(NULL, ":");
if (token) {
msf[1] = atoi(token);
}
else {
msf[1] = 0;
}
token = strtok(NULL, ":");
if (token) {
msf[2] = atoi(token);
}
else {
msf[2] = 0;
}
}
#ifndef _WIN32
static long GetTickCount(void) {
static time_t initial_time = 0;
struct timeval now;
gettimeofday(&now, NULL);
if (initial_time == 0) {
initial_time = now.tv_sec;
}
return (now.tv_sec - initial_time) * 1000L + now.tv_usec / 1000L;
}
#endif
// this thread plays audio data
#ifdef _WIN32
static void playthread(void *param)
#else
static void *playthread(void *param)
#endif
{
long d, t, i, s;
unsigned char tmp;
t = GetTickCount();
while (playing) {
d = t - (long)GetTickCount();
if (d <= 0) {
d = 1;
}
else if (d > CDDA_FRAMETIME) {
d = CDDA_FRAMETIME;
}
#ifdef _WIN32
Sleep(d);
#else
usleep(d * 1000);
#endif
t = GetTickCount() + CDDA_FRAMETIME;
if (subChanMixed) {
s = 0;
for (i = 0; i < sizeof(sndbuffer) / CD_FRAMESIZE_RAW; i++) {
// read one sector
d = fread(sndbuffer + CD_FRAMESIZE_RAW * i, 1, CD_FRAMESIZE_RAW, cddaHandle);
if (d < CD_FRAMESIZE_RAW) {
break;
}
s += d;
// skip the subchannel data
fseek(cddaHandle, SUB_FRAMESIZE, SEEK_CUR);
}
}
else {
s = fread(sndbuffer, 1, sizeof(sndbuffer), cddaHandle);
}
if (s == 0) {
playing = FALSE;
fclose(cddaHandle);
cddaHandle = NULL;
initial_offset = 0;
break;
}
if (!cdr.Muted && playing) {
if (cddaBigEndian) {
for (i = 0; i < s / 2; i++) {
tmp = sndbuffer[i * 2];
sndbuffer[i * 2] = sndbuffer[i * 2 + 1];
sndbuffer[i * 2 + 1] = tmp;
}
}
SPU_playCDDAchannel((short *)sndbuffer, s);
}
cddaCurOffset += s;
}
#ifdef _WIN32
_endthread();
#else
pthread_exit(0);
return NULL;
#endif
}
// stop the CDDA playback
static void stopCDDA() {
if (!playing) {
return;
}
playing = FALSE;
#ifdef _WIN32
WaitForSingleObject(threadid, INFINITE);
#else
pthread_join(threadid, NULL);
#endif
if (cddaHandle != NULL) {
fclose(cddaHandle);
cddaHandle = NULL;
}
initial_offset = 0;
}
// start the CDDA playback
static void startCDDA(unsigned int offset) {
if (playing) {
if (initial_offset == offset) {
return;
}
stopCDDA();
}
cddaHandle = fopen(GetIsoFile(), "rb");
if (cddaHandle == NULL) {
return;
}
initial_offset = offset;
cddaCurOffset = initial_offset;
fseek(cddaHandle, initial_offset, SEEK_SET);
playing = TRUE;
#ifdef _WIN32
threadid = (HANDLE)_beginthread(playthread, 0, NULL);
#else
pthread_create(&threadid, NULL, playthread, NULL);
#endif
}
// this function tries to get the .toc file of the given .bin
// the necessary data is put into the ti (trackinformation)-array
static int parsetoc(const char *isofile) {
char tocname[MAXPATHLEN];
FILE *fi;
char linebuf[256], dummy[256], name[256];
char *token;
char time[20], time2[20];
unsigned int t;
numtracks = 0;
// copy name of the iso and change extension from .bin to .toc
strncpy(tocname, isofile, sizeof(tocname));
tocname[MAXPATHLEN - 1] = '\0';
if (strlen(tocname) >= 4) {
strcpy(tocname + strlen(tocname) - 4, ".toc");
}
else {
return -1;
}
if ((fi = fopen(tocname, "r")) == NULL) {
// try changing extension to .cue (to satisfy some stupid tutorials)
strcpy(tocname + strlen(tocname) - 4, ".cue");
if ((fi = fopen(tocname, "r")) == NULL) {
// if filename is image.toc.bin, try removing .bin (for Brasero)
strcpy(tocname, isofile);
t = strlen(tocname);
if (t >= 8 && strcmp(tocname + t - 8, ".toc.bin") == 0) {
tocname[t - 4] = '\0';
if ((fi = fopen(tocname, "r")) == NULL) {
return -1;
}
}
else {
return -1;
}
}
}
memset(&ti, 0, sizeof(ti));
cddaBigEndian = TRUE; // cdrdao uses big-endian for CD Audio
// parse the .toc file
while (fgets(linebuf, sizeof(linebuf), fi) != NULL) {
// search for tracks
strncpy(dummy, linebuf, sizeof(linebuf));
token = strtok(dummy, " ");
if (token == NULL) continue;
if (!strcmp(token, "TRACK")) {
// get type of track
token = strtok(NULL, " ");
numtracks++;
if (!strncmp(token, "MODE2_RAW", 9)) {
ti[numtracks].type = DATA;
sec2msf(2 * 75, ti[numtracks].start); // assume data track on 0:2:0
// check if this image contains mixed subchannel data
token = strtok(NULL, " ");
if (token != NULL && !strncmp(token, "RW_RAW", 6)) {
subChanMixed = TRUE;
subChanRaw = TRUE;
}
}
else if (!strncmp(token, "AUDIO", 5)) {
ti[numtracks].type = CDDA;
}
}
else if (!strcmp(token, "DATAFILE")) {
if (ti[numtracks].type == CDDA) {
sscanf(linebuf, "DATAFILE \"%[^\"]\" #%d %8s", name, &t, time2);
t /= CD_FRAMESIZE_RAW + (subChanMixed ? SUB_FRAMESIZE : 0);
t += 2 * 75;
sec2msf(t, (char *)&ti[numtracks].start);
tok2msf((char *)&time2, (char *)&ti[numtracks].length);
}
else {
sscanf(linebuf, "DATAFILE \"%[^\"]\" %8s", name, time);
tok2msf((char *)&time, (char *)&ti[numtracks].length);
}
}
else if (!strcmp(token, "FILE")) {
sscanf(linebuf, "FILE \"%[^\"]\" #%d %8s %8s", name, &t, time, time2);
tok2msf((char *)&time, (char *)&ti[numtracks].start);
t /= CD_FRAMESIZE_RAW + (subChanMixed ? SUB_FRAMESIZE : 0);
t += msf2sec(ti[numtracks].start) + 2 * 75;
sec2msf(t, (char *)&ti[numtracks].start);
tok2msf((char *)&time2, (char *)&ti[numtracks].length);
}
}
fclose(fi);
return 0;
}
// this function tries to get the .cue file of the given .bin
// the necessary data is put into the ti (trackinformation)-array
static int parsecue(const char *isofile) {
char cuename[MAXPATHLEN];
FILE *fi;
char *token;
char time[20];
char *tmp;
char linebuf[256], dummy[256];
unsigned int t;
numtracks = 0;
// copy name of the iso and change extension from .bin to .cue
strncpy(cuename, isofile, sizeof(cuename));
cuename[MAXPATHLEN - 1] = '\0';
if (strlen(cuename) >= 4) {
strcpy(cuename + strlen(cuename) - 4, ".cue");
}
else {
return -1;
}
if ((fi = fopen(cuename, "r")) == NULL) {
return -1;
}
// Some stupid tutorials wrongly tell users to use cdrdao to rip a
// "bin/cue" image, which is in fact a "bin/toc" image. So let's check
// that...
if (fgets(linebuf, sizeof(linebuf), fi) != NULL) {
if (!strncmp(linebuf, "CD_ROM_XA", 9)) {
// Don't proceed further, as this is actually a .toc file rather
// than a .cue file.
fclose(fi);
return parsetoc(isofile);
}
fseek(fi, 0, SEEK_SET);
}
memset(&ti, 0, sizeof(ti));
while (fgets(linebuf, sizeof(linebuf), fi) != NULL) {
strncpy(dummy, linebuf, sizeof(linebuf));
token = strtok(dummy, " ");
if (token == NULL) {
continue;
}
if (!strcmp(token, "TRACK")){
numtracks++;
if (strstr(linebuf, "AUDIO") != NULL) {
ti[numtracks].type = CDDA;
}
else if (strstr(linebuf, "MODE1/2352") != NULL || strstr(linebuf, "MODE2/2352") != NULL) {
ti[numtracks].type = DATA;
}
}
else if (!strcmp(token, "INDEX")) {
tmp = strstr(linebuf, "INDEX");
if (tmp != NULL) {
tmp += strlen("INDEX") + 3; // 3 - space + numeric index
while (*tmp == ' ') tmp++;
if (*tmp != '\n') sscanf(tmp, "%8s", time);
}
tok2msf((char *)&time, (char *)&ti[numtracks].start);
t = msf2sec(ti[numtracks].start) + 2 * 75;
sec2msf(t, ti[numtracks].start);
// If we've already seen another track, this is its end
if (numtracks > 1) {
t = msf2sec(ti[numtracks].start) - msf2sec(ti[numtracks - 1].start);
sec2msf(t, ti[numtracks - 1].length);
}
}
}
fclose(fi);
// Fill out the last track's end based on size
if (numtracks >= 1) {
fseek(cdHandle, 0, SEEK_END);
t = ftell(cdHandle) / 2352 - msf2sec(ti[numtracks].start) + 2 * 75;
sec2msf(t, ti[numtracks].length);
}
return 0;
}
// this function tries to get the .ccd file of the given .img
// the necessary data is put into the ti (trackinformation)-array
static int parseccd(const char *isofile) {
char ccdname[MAXPATHLEN];
FILE *fi;
char linebuf[256];
unsigned int t;
numtracks = 0;
// copy name of the iso and change extension from .img to .ccd
strncpy(ccdname, isofile, sizeof(ccdname));
ccdname[MAXPATHLEN - 1] = '\0';
if (strlen(ccdname) >= 4) {
strcpy(ccdname + strlen(ccdname) - 4, ".ccd");
}
else {
return -1;
}
if ((fi = fopen(ccdname, "r")) == NULL) {
return -1;
}
memset(&ti, 0, sizeof(ti));
while (fgets(linebuf, sizeof(linebuf), fi) != NULL) {
if (!strncmp(linebuf, "[TRACK", 6)){
numtracks++;
}
else if (!strncmp(linebuf, "MODE=", 5)) {
sscanf(linebuf, "MODE=%d", &t);
ti[numtracks].type = ((t == 0) ? CDDA : DATA);
}
else if (!strncmp(linebuf, "INDEX 1=", 8)) {
sscanf(linebuf, "INDEX 1=%d", &t);
sec2msf(t + 2 * 75, ti[numtracks].start);
// If we've already seen another track, this is its end
if (numtracks > 1) {
t = msf2sec(ti[numtracks].start) - msf2sec(ti[numtracks - 1].start);
sec2msf(t, ti[numtracks - 1].length);
}
}
}
fclose(fi);
// Fill out the last track's end based on size
if (numtracks >= 1) {
fseek(cdHandle, 0, SEEK_END);
t = ftell(cdHandle) / 2352 - msf2sec(ti[numtracks].start) + 2 * 75;
sec2msf(t, ti[numtracks].length);
}
return 0;
}
// this function tries to get the .mds file of the given .mdf
// the necessary data is put into the ti (trackinformation)-array
static int parsemds(const char *isofile) {
char mdsname[MAXPATHLEN];
FILE *fi;
unsigned int offset, extra_offset, l, i;
unsigned short s;
numtracks = 0;
// copy name of the iso and change extension from .mdf to .mds
strncpy(mdsname, isofile, sizeof(mdsname));
mdsname[MAXPATHLEN - 1] = '\0';
if (strlen(mdsname) >= 4) {
strcpy(mdsname + strlen(mdsname) - 4, ".mds");
}
else {
return -1;
}
if ((fi = fopen(mdsname, "rb")) == NULL) {
return -1;
}
memset(&ti, 0, sizeof(ti));
// check if it's a valid mds file
fread(&i, 1, sizeof(unsigned int), fi);
i = SWAP32(i);
if (i != 0x4944454D) {
// not an valid mds file
fclose(fi);
return -1;
}
// get offset to session block
fseek(fi, 0x50, SEEK_SET);
fread(&offset, 1, sizeof(unsigned int), fi);
offset = SWAP32(offset);
// get total number of tracks
offset += 14;
fseek(fi, offset, SEEK_SET);
fread(&s, 1, sizeof(unsigned short), fi);
s = SWAP16(s);
numtracks = s;
// get offset to track blocks
fseek(fi, 4, SEEK_CUR);
fread(&offset, 1, sizeof(unsigned int), fi);
offset = SWAP32(offset);
// skip lead-in data
while (1) {
fseek(fi, offset + 4, SEEK_SET);
if (fgetc(fi) < 0xA0) {
break;
}
offset += 0x50;
}
// check if the image contains mixed subchannel data
fseek(fi, offset + 1, SEEK_SET);
subChanMixed = (fgetc(fi) ? TRUE : FALSE);
// read track data
for (i = 1; i <= numtracks; i++) {
fseek(fi, offset, SEEK_SET);
// get the track type
ti[i].type = ((fgetc(fi) == 0xA9) ? CDDA : DATA);
fseek(fi, 8, SEEK_CUR);
// get the track starting point
ti[i].start[0] = fgetc(fi);
ti[i].start[1] = fgetc(fi);
ti[i].start[2] = fgetc(fi);
if (i > 1) {
l = msf2sec(ti[i].start);
sec2msf(l - 2 * 75, ti[i].start); // ???
}
// get the track length
fread(&extra_offset, 1, sizeof(unsigned int), fi);
extra_offset = SWAP32(extra_offset);
fseek(fi, extra_offset + 4, SEEK_SET);
fread(&l, 1, sizeof(unsigned int), fi);
l = SWAP32(l);
sec2msf(l, ti[i].length);
offset += 0x50;
}
fclose(fi);
return 0;
}
// this function tries to get the .sub file of the given .img
static int opensubfile(const char *isoname) {
char subname[MAXPATHLEN];
// copy name of the iso and change extension from .img to .sub
strncpy(subname, isoname, sizeof(subname));
subname[MAXPATHLEN - 1] = '\0';
if (strlen(subname) >= 4) {
strcpy(subname + strlen(subname) - 4, ".sub");
}
else {
return -1;
}
subHandle = fopen(subname, "rb");
if (subHandle == NULL) {
return -1;
}
return 0;
}
static long CALLBACK ISOinit(void) {
assert(cdHandle == NULL);
assert(subHandle == NULL);
return 0; // do nothing
}
static long CALLBACK ISOshutdown(void) {
if (cdHandle != NULL) {
fclose(cdHandle);
cdHandle = NULL;
}
if (subHandle != NULL) {
fclose(subHandle);
subHandle = NULL;
}
stopCDDA();
return 0;
}
static void PrintTracks(void) {
int i;
for (i = 1; i <= numtracks; i++) {
SysPrintf(_("Track %.2d (%s) - Start %.2d:%.2d:%.2d, Length %.2d:%.2d:%.2d\n"),
i, (ti[i].type == DATA ? "DATA" : "AUDIO"),
ti[i].start[0], ti[i].start[1], ti[i].start[2],
ti[i].length[0], ti[i].length[1], ti[i].length[2]);
}
}
// This function is invoked by the front-end when opening an ISO
// file for playback
static long CALLBACK ISOopen(void) {
if (cdHandle != NULL) {
return 0; // it's already open
}
cdHandle = fopen(GetIsoFile(), "rb");
if (cdHandle == NULL) {
return -1;
}
SysPrintf(_("Loaded CD Image: %s"), GetIsoFile());
cddaBigEndian = FALSE;
subChanMixed = FALSE;
subChanRaw = FALSE;
if (parsecue(GetIsoFile()) == 0) {
SysPrintf("[+cue]");
}
else if (parsetoc(GetIsoFile()) == 0) {
SysPrintf("[+toc]");
}
else if (parseccd(GetIsoFile()) == 0) {
SysPrintf("[+ccd]");
}
else if (parsemds(GetIsoFile()) == 0) {
SysPrintf("[+mds]");
}
if (!subChanMixed && opensubfile(GetIsoFile()) == 0) {
SysPrintf("[+sub]");
}
SysPrintf(".\n");
PrintTracks();
return 0;
}
static long CALLBACK ISOclose(void) {
if (cdHandle != NULL) {
fclose(cdHandle);
cdHandle = NULL;
}
if (subHandle != NULL) {
fclose(subHandle);
subHandle = NULL;
}
stopCDDA();
return 0;
}
// return Starting and Ending Track
// buffer:
// byte 0 - start track
// byte 1 - end track
static long CALLBACK ISOgetTN(unsigned char *buffer) {
buffer[0] = 1;
if (numtracks > 0) {
buffer[1] = numtracks;
}
else {
buffer[1] = 1;
}
return 0;
}
// return Track Time
// buffer:
// byte 0 - frame
// byte 1 - second
// byte 2 - minute
static long CALLBACK ISOgetTD(unsigned char track, unsigned char *buffer) {
if (numtracks > 0 && track <= numtracks) {
buffer[2] = ti[track].start[0];
buffer[1] = ti[track].start[1];
buffer[0] = ti[track].start[2];
}
else {
buffer[2] = 0;
buffer[1] = 2;
buffer[0] = 0;
}
return 0;
}
// decode 'raw' subchannel data ripped by cdrdao
static void DecodeRawSubData(void) {
unsigned char subQData[12];
int i;
memset(subQData, 0, sizeof(subQData));
for (i = 0; i < 8 * 12; i++) {
if (subbuffer[i] & (1 << 6)) { // only subchannel Q is needed
subQData[i >> 3] |= (1 << (7 - (i & 7)));
}
}
memcpy(&subbuffer[12], subQData, 12);
}
// read track
// time: byte 0 - minute; byte 1 - second; byte 2 - frame
// uses bcd format
static long CALLBACK ISOreadTrack(unsigned char *time) {
if (cdHandle == NULL) {
return -1;
}
if (subChanMixed) {
fseek(cdHandle, MSF2SECT(btoi(time[0]), btoi(time[1]), btoi(time[2])) * (CD_FRAMESIZE_RAW + SUB_FRAMESIZE) + 12, SEEK_SET);
fread(cdbuffer, 1, DATA_SIZE, cdHandle);
fread(subbuffer, 1, SUB_FRAMESIZE, cdHandle);
if (subChanRaw) DecodeRawSubData();
}
else {
fseek(cdHandle, MSF2SECT(btoi(time[0]), btoi(time[1]), btoi(time[2])) * CD_FRAMESIZE_RAW + 12, SEEK_SET);
fread(cdbuffer, 1, DATA_SIZE, cdHandle);
if (subHandle != NULL) {
fseek(subHandle, MSF2SECT(btoi(time[0]), btoi(time[1]), btoi(time[2])) * SUB_FRAMESIZE, SEEK_SET);
fread(subbuffer, 1, SUB_FRAMESIZE, subHandle);
if (subChanRaw) DecodeRawSubData();
}
}
return 0;
}
// return readed track
static unsigned char * CALLBACK ISOgetBuffer(void) {
return cdbuffer;
}
// plays cdda audio
// sector: byte 0 - minute; byte 1 - second; byte 2 - frame
// does NOT uses bcd format
static long CALLBACK ISOplay(unsigned char *time) {
if (SPU_playCDDAchannel != NULL) {
if (subChanMixed) {
startCDDA(MSF2SECT(time[0], time[1], time[2]) * (CD_FRAMESIZE_RAW + SUB_FRAMESIZE));
}
else {
startCDDA(MSF2SECT(time[0], time[1], time[2]) * CD_FRAMESIZE_RAW);
}
}
return 0;
}
// stops cdda audio
static long CALLBACK ISOstop(void) {
stopCDDA();
return 0;
}
// gets subchannel data
static unsigned char* CALLBACK ISOgetBufferSub(void) {
if (subHandle != NULL || subChanMixed) {
return subbuffer;
}
return NULL;
}
static long CALLBACK ISOgetStatus(struct CdrStat *stat) {
int sec;
CDR__getStatus(stat);
if (playing) {
stat->Type = 0x02;
stat->Status |= 0x80;
sec = cddaCurOffset / CD_FRAMESIZE_RAW;
sec2msf(sec, (char *)stat->Time);
}
else {
stat->Type = 0x01;
}
return 0;
}
void cdrIsoInit(void) {
CDR_init = ISOinit;
CDR_shutdown = ISOshutdown;
CDR_open = ISOopen;
CDR_close = ISOclose;
CDR_getTN = ISOgetTN;
CDR_getTD = ISOgetTD;
CDR_readTrack = ISOreadTrack;
CDR_getBuffer = ISOgetBuffer;
CDR_play = ISOplay;
CDR_stop = ISOstop;
CDR_getBufferSub = ISOgetBufferSub;
CDR_getStatus = ISOgetStatus;
CDR_getDriveLetter = CDR__getDriveLetter;
CDR_configure = CDR__configure;
CDR_test = CDR__test;
CDR_about = CDR__about;
CDR_setfilename = CDR__setfilename;
numtracks = 0;
}
int cdrIsoActive(void) {
return (cdHandle != NULL);
}

34
libpcsxcore/cdriso.h Normal file
View File

@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (C) 2007 PCSX-df Team *
* Copyright (C) 2009 Wei Mingzhi *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef CDRISO_H
#define CDRISO_H
#ifdef __cplusplus
extern "C" {
#endif
void cdrIsoInit(void);
int cdrIsoActive(void);
#ifdef __cplusplus
}
#endif
#endif

1138
libpcsxcore/cdrom.c Normal file

File diff suppressed because it is too large Load Diff

110
libpcsxcore/cdrom.h Normal file
View File

@ -0,0 +1,110 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __CDROM_H__
#define __CDROM_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "psxcommon.h"
#include "decode_xa.h"
#include "r3000a.h"
#include "plugins.h"
#include "psxmem.h"
#include "psxhw.h"
#define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */
#define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */
#define MSF2SECT(m, s, f) (((m) * 60 + (s) - 2) * 75 + (f))
#define CD_FRAMESIZE_RAW 2352
#define DATA_SIZE (CD_FRAMESIZE_RAW - 12)
#define SUB_FRAMESIZE 96
typedef struct {
unsigned char OCUP;
unsigned char Reg1Mode;
unsigned char Reg2;
unsigned char CmdProcess;
unsigned char Ctrl;
unsigned char Stat;
unsigned char StatP;
unsigned char Transfer[CD_FRAMESIZE_RAW];
unsigned char *pTransfer;
unsigned char Prev[4];
unsigned char Param[8];
unsigned char Result[8];
unsigned char ParamC;
unsigned char ParamP;
unsigned char ResultC;
unsigned char ResultP;
unsigned char ResultReady;
unsigned char Cmd;
unsigned char Readed;
u32 Reading;
unsigned char ResultTN[6];
unsigned char ResultTD[4];
unsigned char SetSector[4];
unsigned char SetSectorSeek[4];
unsigned char Track;
boolean Play, Muted;
int CurTrack;
int Mode, File, Channel;
int Reset;
int RErr;
int FirstSector;
xa_decode_t Xa;
int Init;
unsigned char Irq;
u32 eCycle;
boolean Seeked;
} cdrStruct;
extern cdrStruct cdr;
void cdrReset();
void cdrInterrupt();
void cdrReadInterrupt();
unsigned char cdrRead0(void);
unsigned char cdrRead1(void);
unsigned char cdrRead2(void);
unsigned char cdrRead3(void);
void cdrWrite0(unsigned char rt);
void cdrWrite1(unsigned char rt);
void cdrWrite2(unsigned char rt);
void cdrWrite3(unsigned char rt);
int cdrFreeze(gzFile f, int Mode);
#ifdef __cplusplus
}
#endif
#endif

1024
libpcsxcore/cheat.c Normal file

File diff suppressed because it is too large Load Diff

117
libpcsxcore/cheat.h Normal file
View File

@ -0,0 +1,117 @@
/* Cheat Support for PCSX-Reloaded
* Copyright (C) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#ifndef CHEAT_H
#define CHEAT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
uint32_t Addr;
uint16_t Val;
} CheatCode;
typedef struct {
char *Descr;
int First; // index of the first cheat code
int n; // number of cheat codes for this cheat
int Enabled;
} Cheat;
void ClearAllCheats();
void LoadCheats(const char *filename);
void SaveCheats(const char *filename);
void ApplyCheats();
int AddCheat(const char *descr, char *code);
void RemoveCheat(int index);
int EditCheat(int index, const char *descr, char *code);
void FreeCheatSearchResults();
void FreeCheatSearchMem();
void CheatSearchBackupMemory();
void CheatSearchEqual8(u8 val);
void CheatSearchEqual16(u16 val);
void CheatSearchEqual32(u32 val);
void CheatSearchNotEqual8(u8 val);
void CheatSearchNotEqual16(u16 val);
void CheatSearchNotEqual32(u32 val);
void CheatSearchRange8(u8 min, u8 max);
void CheatSearchRange16(u16 min, u16 max);
void CheatSearchRange32(u32 min, u32 max);
void CheatSearchIncreasedBy8(u8 val);
void CheatSearchIncreasedBy16(u16 val);
void CheatSearchIncreasedBy32(u32 val);
void CheatSearchDecreasedBy8(u8 val);
void CheatSearchDecreasedBy16(u16 val);
void CheatSearchDecreasedBy32(u32 val);
void CheatSearchIncreased8();
void CheatSearchIncreased16();
void CheatSearchIncreased32();
void CheatSearchDecreased8();
void CheatSearchDecreased16();
void CheatSearchDecreased32();
void CheatSearchDifferent8();
void CheatSearchDifferent16();
void CheatSearchDifferent32();
void CheatSearchNoChange8();
void CheatSearchNoChange16();
void CheatSearchNoChange32();
extern Cheat *Cheats;
extern CheatCode *CheatCodes;
extern int NumCheats;
extern int NumCodes;
extern s8 *prevM;
extern u32 *SearchResults;
extern int NumSearchResults;
#define PREVM(mem) (&prevM[mem])
#define PrevMu8(mem) (*(u8 *)PREVM(mem))
#define PrevMu16(mem) (SWAP16(*(u16 *)PREVM(mem)))
#define PrevMu32(mem) (SWAP32(*(u32 *)PREVM(mem)))
// cheat types
#define CHEAT_CONST8 0x30 /* 8-bit Constant Write */
#define CHEAT_CONST16 0x80 /* 16-bit Constant Write */
#define CHEAT_INC16 0x10 /* 16-bit Increment */
#define CHEAT_DEC16 0x11 /* 16-bit Decrement */
#define CHEAT_INC8 0x20 /* 8-bit Increment */
#define CHEAT_DEC8 0x21 /* 8-bit Decrement */
#define CHEAT_SLIDE 0x50 /* Slide Codes */
#define CHEAT_MEMCPY 0xC2 /* Memory Copy */
#define CHEAT_EQU8 0xE0 /* 8-bit Equal To */
#define CHEAT_NOTEQU8 0xE1 /* 8-bit Not Equal To */
#define CHEAT_LESSTHAN8 0xE2 /* 8-bit Less Than */
#define CHEAT_GREATERTHAN8 0xE3 /* 8-bit Greater Than */
#define CHEAT_EQU16 0xD0 /* 16-bit Equal To */
#define CHEAT_NOTEQU16 0xD1 /* 16-bit Not Equal To */
#define CHEAT_LESSTHAN16 0xD2 /* 16-bit Less Than */
#define CHEAT_GREATERTHAN16 0xD3 /* 16-bit Greater Than */
#ifdef __cplusplus
}
#endif
#endif

38
libpcsxcore/coff.h Normal file
View File

@ -0,0 +1,38 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __COFF_H__
#define __COFF_H__
/********************** FILE HEADER **********************/
struct external_filehdr {
unsigned short f_magic; /* magic number */
unsigned short f_nscns; /* number of sections */
unsigned long f_timdat; /* time & date stamp */
unsigned long f_symptr; /* file pointer to symtab */
unsigned long f_nsyms; /* number of symtab entries */
unsigned short f_opthdr; /* sizeof(optional hdr) */
unsigned short f_flags; /* flags */
};
#define FILHDR struct external_filehdr
#define FILHSZ sizeof(FILHDR)
#endif

1145
libpcsxcore/debug.c Normal file

File diff suppressed because it is too large Load Diff

72
libpcsxcore/debug.h Normal file
View File

@ -0,0 +1,72 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __DEBUG_H__
#define __DEBUG_H__
#ifdef __cplusplus
extern "C" {
#endif
enum breakpoint_types {
E, R1, R2, R4, W1, W2, W4
};
void StartDebugger();
void StopDebugger();
void DebugVSync();
void ProcessDebug();
void DebugCheckBP(u32 address, enum breakpoint_types type);
void PauseDebugger();
void ResumeDebugger();
extern char *disRNameCP0[];
char* disR3000AF(u32 code, u32 pc);
/*
* Specficies which logs should be activated.
*/
//#define LOG_STDOUT
//#define PAD_LOG __Log
//#define GTE_LOG __Log
//#define CDR_LOG __Log("%8.8lx %8.8lx: ", psxRegs.pc, psxRegs.cycle); __Log
//#define PSXHW_LOG __Log("%8.8lx %8.8lx: ", psxRegs.pc, psxRegs.cycle); __Log
//#define PSXBIOS_LOG __Log("%8.8lx %8.8lx: ", psxRegs.pc, psxRegs.cycle); __Log
//#define PSXDMA_LOG __Log
//#define PSXMEM_LOG __Log("%8.8lx %8.8lx: ", psxRegs.pc, psxRegs.cycle); __Log
//#define PSXCPU_LOG __Log
//#define CDRCMD_DEBUG
#if defined (PSXCPU_LOG) || defined(PSXDMA_LOG) || defined(CDR_LOG) || defined(PSXHW_LOG) || \
defined(PSXBIOS_LOG) || defined(PSXMEM_LOG) || defined(GTE_LOG) || defined(PAD_LOG)
#define EMU_LOG __Log
#endif
#ifdef __cplusplus
}
#endif
#endif

367
libpcsxcore/decode_xa.c Normal file
View File

@ -0,0 +1,367 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
/*
* XA audio decoding functions (Kazzuya).
*/
#include "decode_xa.h"
#define FIXED
#define NOT(_X_) (!(_X_))
#define XACLAMP(_X_,_MI_,_MA_) {if(_X_<_MI_)_X_=_MI_;if(_X_>_MA_)_X_=_MA_;}
#define SH 4
#define SHC 10
//============================================
//=== ADPCM DECODING ROUTINES
//============================================
#ifndef FIXED
static double K0[4] = {
0.0,
0.9375,
1.796875,
1.53125
};
static double K1[4] = {
0.0,
0.0,
-0.8125,
-0.859375
};
#else
static int K0[4] = {
0.0 * (1<<SHC),
0.9375 * (1<<SHC),
1.796875 * (1<<SHC),
1.53125 * (1<<SHC)
};
static int K1[4] = {
0.0 * (1<<SHC),
0.0 * (1<<SHC),
-0.8125 * (1<<SHC),
-0.859375 * (1<<SHC)
};
#endif
#define BLKSIZ 28 /* block size (32 - 4 nibbles) */
//===========================================
void ADPCM_InitDecode(ADPCM_Decode_t *decp) {
decp->y0 = 0;
decp->y1 = 0;
}
//===========================================
#ifndef FIXED
#define IK0(fid) ((int)((-K0[fid]) * (1<<SHC)))
#define IK1(fid) ((int)((-K1[fid]) * (1<<SHC)))
#else
#define IK0(fid) (-K0[fid])
#define IK1(fid) (-K1[fid])
#endif
static __inline void ADPCM_DecodeBlock16( ADPCM_Decode_t *decp, u8 filter_range, const void *vblockp, short *destp, int inc ) {
int i;
int range, filterid;
s32 fy0, fy1;
const u16 *blockp;
blockp = (const unsigned short *)vblockp;
filterid = (filter_range >> 4) & 0x0f;
range = (filter_range >> 0) & 0x0f;
fy0 = decp->y0;
fy1 = decp->y1;
for (i = BLKSIZ/4; i; --i) {
s32 y;
s32 x0, x1, x2, x3;
y = *blockp++;
x3 = (short)( y & 0xf000) >> range; x3 <<= SH;
x2 = (short)((y << 4) & 0xf000) >> range; x2 <<= SH;
x1 = (short)((y << 8) & 0xf000) >> range; x1 <<= SH;
x0 = (short)((y << 12) & 0xf000) >> range; x0 <<= SH;
x0 -= (IK0(filterid) * fy0 + (IK1(filterid) * fy1)) >> SHC; fy1 = fy0; fy0 = x0;
x1 -= (IK0(filterid) * fy0 + (IK1(filterid) * fy1)) >> SHC; fy1 = fy0; fy0 = x1;
x2 -= (IK0(filterid) * fy0 + (IK1(filterid) * fy1)) >> SHC; fy1 = fy0; fy0 = x2;
x3 -= (IK0(filterid) * fy0 + (IK1(filterid) * fy1)) >> SHC; fy1 = fy0; fy0 = x3;
XACLAMP( x0, -32768<<SH, 32767<<SH ); *destp = x0 >> SH; destp += inc;
XACLAMP( x1, -32768<<SH, 32767<<SH ); *destp = x1 >> SH; destp += inc;
XACLAMP( x2, -32768<<SH, 32767<<SH ); *destp = x2 >> SH; destp += inc;
XACLAMP( x3, -32768<<SH, 32767<<SH ); *destp = x3 >> SH; destp += inc;
}
decp->y0 = fy0;
decp->y1 = fy1;
}
static int headtable[4] = {0,2,8,10};
//===========================================
static void xa_decode_data( xa_decode_t *xdp, unsigned char *srcp ) {
const u8 *sound_groupsp;
const u8 *sound_datap, *sound_datap2;
int i, j, k, nbits;
u16 data[4096], *datap;
short *destp;
destp = xdp->pcm;
nbits = xdp->nbits == 4 ? 4 : 2;
if (xdp->stereo) { // stereo
if ((xdp->nbits == 8) && (xdp->freq == 37800)) { // level A
for (j=0; j < 18; j++) {
sound_groupsp = srcp + j * 128; // sound groups header
sound_datap = sound_groupsp + 16; // sound data just after the header
for (i=0; i < nbits; i++) {
datap = data;
sound_datap2 = sound_datap + i;
for (k=0; k < 14; k++, sound_datap2 += 8) {
*(datap++) = (u16)sound_datap2[0] |
(u16)(sound_datap2[4] << 8);
}
ADPCM_DecodeBlock16( &xdp->left, sound_groupsp[headtable[i]+0], data,
destp+0, 2 );
datap = data;
sound_datap2 = sound_datap + i;
for (k=0; k < 14; k++, sound_datap2 += 8) {
*(datap++) = (u16)sound_datap2[0] |
(u16)(sound_datap2[4] << 8);
}
ADPCM_DecodeBlock16( &xdp->right, sound_groupsp[headtable[i]+1], data,
destp+1, 2 );
destp += 28*2;
}
}
} else { // level B/C
for (j=0; j < 18; j++) {
sound_groupsp = srcp + j * 128; // sound groups header
sound_datap = sound_groupsp + 16; // sound data just after the header
for (i=0; i < nbits; i++) {
datap = data;
sound_datap2 = sound_datap + i;
for (k=0; k < 7; k++, sound_datap2 += 16) {
*(datap++) = (u16)(sound_datap2[ 0] & 0x0f) |
((u16)(sound_datap2[ 4] & 0x0f) << 4) |
((u16)(sound_datap2[ 8] & 0x0f) << 8) |
((u16)(sound_datap2[12] & 0x0f) << 12);
}
ADPCM_DecodeBlock16( &xdp->left, sound_groupsp[headtable[i]+0], data,
destp+0, 2 );
datap = data;
sound_datap2 = sound_datap + i;
for (k=0; k < 7; k++, sound_datap2 += 16) {
*(datap++) = (u16)(sound_datap2[ 0] >> 4) |
((u16)(sound_datap2[ 4] >> 4) << 4) |
((u16)(sound_datap2[ 8] >> 4) << 8) |
((u16)(sound_datap2[12] >> 4) << 12);
}
ADPCM_DecodeBlock16( &xdp->right, sound_groupsp[headtable[i]+1], data,
destp+1, 2 );
destp += 28*2;
}
}
}
} else { // mono
if ((xdp->nbits == 8) && (xdp->freq == 37800)) { // level A
for (j=0; j < 18; j++) {
sound_groupsp = srcp + j * 128; // sound groups header
sound_datap = sound_groupsp + 16; // sound data just after the header
for (i=0; i < nbits; i++) {
datap = data;
sound_datap2 = sound_datap + i;
for (k=0; k < 14; k++, sound_datap2 += 8) {
*(datap++) = (u16)sound_datap2[0] |
(u16)(sound_datap2[4] << 8);
}
ADPCM_DecodeBlock16( &xdp->left, sound_groupsp[headtable[i]+0], data,
destp, 1 );
destp += 28;
datap = data;
sound_datap2 = sound_datap + i;
for (k=0; k < 14; k++, sound_datap2 += 8) {
*(datap++) = (u16)sound_datap2[0] |
(u16)(sound_datap2[4] << 8);
}
ADPCM_DecodeBlock16( &xdp->left, sound_groupsp[headtable[i]+1], data,
destp, 1 );
destp += 28;
}
}
} else { // level B/C
for (j=0; j < 18; j++) {
sound_groupsp = srcp + j * 128; // sound groups header
sound_datap = sound_groupsp + 16; // sound data just after the header
for (i=0; i < nbits; i++) {
datap = data;
sound_datap2 = sound_datap + i;
for (k=0; k < 7; k++, sound_datap2 += 16) {
*(datap++) = (u16)(sound_datap2[ 0] & 0x0f) |
((u16)(sound_datap2[ 4] & 0x0f) << 4) |
((u16)(sound_datap2[ 8] & 0x0f) << 8) |
((u16)(sound_datap2[12] & 0x0f) << 12);
}
ADPCM_DecodeBlock16( &xdp->left, sound_groupsp[headtable[i]+0], data,
destp, 1 );
destp += 28;
datap = data;
sound_datap2 = sound_datap + i;
for (k=0; k < 7; k++, sound_datap2 += 16) {
*(datap++) = (u16)(sound_datap2[ 0] >> 4) |
((u16)(sound_datap2[ 4] >> 4) << 4) |
((u16)(sound_datap2[ 8] >> 4) << 8) |
((u16)(sound_datap2[12] >> 4) << 12);
}
ADPCM_DecodeBlock16( &xdp->left, sound_groupsp[headtable[i]+1], data,
destp, 1 );
destp += 28;
}
}
}
}
}
//============================================
//=== XA SPECIFIC ROUTINES
//============================================
typedef struct {
u8 filenum;
u8 channum;
u8 submode;
u8 coding;
u8 filenum2;
u8 channum2;
u8 submode2;
u8 coding2;
} xa_subheader_t;
#define SUB_SUB_EOF (1<<7) // end of file
#define SUB_SUB_RT (1<<6) // real-time sector
#define SUB_SUB_FORM (1<<5) // 0 form1 1 form2
#define SUB_SUB_TRIGGER (1<<4) // used for interrupt
#define SUB_SUB_DATA (1<<3) // contains data
#define SUB_SUB_AUDIO (1<<2) // contains audio
#define SUB_SUB_VIDEO (1<<1) // contains video
#define SUB_SUB_EOR (1<<0) // end of record
#define AUDIO_CODING_GET_STEREO(_X_) ( (_X_) & 3)
#define AUDIO_CODING_GET_FREQ(_X_) (((_X_) >> 2) & 3)
#define AUDIO_CODING_GET_BPS(_X_) (((_X_) >> 4) & 3)
#define AUDIO_CODING_GET_EMPHASIS(_X_) (((_X_) >> 6) & 1)
#define SUB_UNKNOWN 0
#define SUB_VIDEO 1
#define SUB_AUDIO 2
//============================================
static int parse_xa_audio_sector( xa_decode_t *xdp,
xa_subheader_t *subheadp,
unsigned char *sectorp,
int is_first_sector ) {
if ( is_first_sector ) {
switch ( AUDIO_CODING_GET_FREQ(subheadp->coding) ) {
case 0: xdp->freq = 37800; break;
case 1: xdp->freq = 18900; break;
default: xdp->freq = 0; break;
}
switch ( AUDIO_CODING_GET_BPS(subheadp->coding) ) {
case 0: xdp->nbits = 4; break;
case 1: xdp->nbits = 8; break;
default: xdp->nbits = 0; break;
}
switch ( AUDIO_CODING_GET_STEREO(subheadp->coding) ) {
case 0: xdp->stereo = 0; break;
case 1: xdp->stereo = 1; break;
default: xdp->stereo = 0; break;
}
if ( xdp->freq == 0 )
return -1;
ADPCM_InitDecode( &xdp->left );
ADPCM_InitDecode( &xdp->right );
xdp->nsamples = 18 * 28 * 8;
if (xdp->stereo == 1) xdp->nsamples /= 2;
}
xa_decode_data( xdp, sectorp );
return 0;
}
//================================================================
//=== THIS IS WHAT YOU HAVE TO CALL
//=== xdp - structure were all important data are returned
//=== sectorp - data in input
//=== pcmp - data in output
//=== is_first_sector - 1 if it's the 1st sector of the stream
//=== - 0 for any other successive sector
//=== return -1 if error
//================================================================
s32 xa_decode_sector( xa_decode_t *xdp,
unsigned char *sectorp, int is_first_sector ) {
if (parse_xa_audio_sector(xdp, (xa_subheader_t *)sectorp, sectorp + sizeof(xa_subheader_t), is_first_sector))
return -1;
return 0;
}
/* EXAMPLE:
"nsamples" is the number of 16 bit samples
every sample is 2 bytes in mono and 4 bytes in stereo
xa_decode_t xa;
sectorp = read_first_sector();
xa_decode_sector( &xa, sectorp, 1 );
play_wave( xa.pcm, xa.freq, xa.nsamples );
while ( --n_sectors )
{
sectorp = read_next_sector();
xa_decode_sector( &xa, sectorp, 0 );
play_wave( xa.pcm, xa.freq, xa.nsamples );
}
*/

49
libpcsxcore/decode_xa.h Normal file
View File

@ -0,0 +1,49 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __DECODE_XA_H__
#define __DECODE_XA_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "psxcommon.h"
typedef struct {
s32 y0, y1;
} ADPCM_Decode_t;
typedef struct {
int freq;
int nbits;
int stereo;
int nsamples;
ADPCM_Decode_t left, right;
short pcm[16384];
} xa_decode_t;
s32 xa_decode_sector( xa_decode_t *xdp,
unsigned char *sectorp,
int is_first_sector );
#ifdef __cplusplus
}
#endif
#endif

323
libpcsxcore/disr3000a.c Normal file
View File

@ -0,0 +1,323 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
/*
* R3000A disassembler.
*/
#include "psxcommon.h"
char ostr[256];
// Names of registers
static char *disRNameGPR[] = {
"r0", "at", "v0", "v1", "a0", "a1","a2", "a3",
"t0", "t1", "t2", "t3", "t4", "t5","t6", "t7",
"s0", "s1", "s2", "s3", "s4", "s5","s6", "s7",
"t8", "t9", "k0", "k1", "gp", "sp","fp", "ra"};
char *disRNameCP0[] = {
"Index" , "Random" , "EntryLo0", "EntryLo1", "Context" , "PageMask" , "Wired" , "*Check me*",
"BadVAddr" , "Count" , "EntryHi" , "Compare" , "Status" , "Cause" , "ExceptPC" , "PRevID" ,
"Config" , "LLAddr" , "WatchLo" , "WatchHi" , "XContext", "*RES*" , "*RES*" , "*RES*" ,
"*RES*" , "*RES* " , "PErr" , "CacheErr", "TagLo" , "TagHi" , "ErrorEPC" , "*RES*" };
// Type deffinition of our functions
typedef char* (*TdisR3000AF)(u32 code, u32 pc);
// These macros are used to assemble the disassembler functions
#define MakeDisFg(fn, b) char* fn(u32 code, u32 pc) { b; return ostr; }
#define MakeDisF(fn, b) \
static char* fn(u32 code, u32 pc) { \
sprintf (ostr, "%8.8x %8.8x:", pc, code); \
b; /*ostr[(strlen(ostr) - 1)] = 0;*/ return ostr; \
}
#include "r3000a.h"
#undef _Funct_
#undef _Rd_
#undef _Rt_
#undef _Rs_
#undef _Sa_
#undef _Im_
#undef _Target_
#define _Funct_ ((code ) & 0x3F) // The funct part of the instruction register
#define _Rd_ ((code >> 11) & 0x1F) // The rd part of the instruction register
#define _Rt_ ((code >> 16) & 0x1F) // The rt part of the instruction register
#define _Rs_ ((code >> 21) & 0x1F) // The rs part of the instruction register
#define _Sa_ ((code >> 6) & 0x1F) // The sa part of the instruction register
#define _Im_ ( code & 0xFFFF) // The immediate part of the instruction register
#define _Target_ ((pc & 0xf0000000) + ((code & 0x03ffffff) * 4))
#define _Branch_ (pc + 4 + ((short)_Im_ * 4))
#define _OfB_ _Im_, _nRs_
#define dName(i) sprintf(ostr, "%s %-7s,", ostr, i)
#define dGPR(i) sprintf(ostr, "%s %8.8x (%s),", ostr, psxRegs.GPR.r[i], disRNameGPR[i])
#define dCP0(i) sprintf(ostr, "%s %8.8x (%s),", ostr, psxRegs.CP0.r[i], disRNameCP0[i])
#define dHI() sprintf(ostr, "%s %8.8x (%s),", ostr, psxRegs.GPR.n.hi, "hi")
#define dLO() sprintf(ostr, "%s %8.8x (%s),", ostr, psxRegs.GPR.n.lo, "lo")
#define dImm() sprintf(ostr, "%s %4.4x (%d),", ostr, _Im_, _Im_)
#define dTarget() sprintf(ostr, "%s %8.8x,", ostr, _Target_)
#define dSa() sprintf(ostr, "%s %2.2x (%d),", ostr, _Sa_, _Sa_)
#define dOfB() sprintf(ostr, "%s %4.4x (%8.8x (%s)),", ostr, _Im_, psxRegs.GPR.r[_Rs_], disRNameGPR[_Rs_])
#define dOffset() sprintf(ostr, "%s %8.8x,", ostr, _Branch_)
#define dCode() sprintf(ostr, "%s %8.8x,", ostr, (code >> 6) & 0xffffff)
/*********************************************************
* Arithmetic with immediate operand *
* Format: OP rt, rs, immediate *
*********************************************************/
MakeDisF(disADDI, dName("ADDI"); dGPR(_Rt_); dGPR(_Rs_); dImm();)
MakeDisF(disADDIU, dName("ADDIU"); dGPR(_Rt_); dGPR(_Rs_); dImm();)
MakeDisF(disANDI, dName("ANDI"); dGPR(_Rt_); dGPR(_Rs_); dImm();)
MakeDisF(disORI, dName("ORI"); dGPR(_Rt_); dGPR(_Rs_); dImm();)
MakeDisF(disSLTI, dName("SLTI"); dGPR(_Rt_); dGPR(_Rs_); dImm();)
MakeDisF(disSLTIU, dName("SLTIU"); dGPR(_Rt_); dGPR(_Rs_); dImm();)
MakeDisF(disXORI, dName("XORI"); dGPR(_Rt_); dGPR(_Rs_); dImm();)
/*********************************************************
* Register arithmetic *
* Format: OP rd, rs, rt *
*********************************************************/
MakeDisF(disADD, dName("ADD"); dGPR(_Rd_); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disADDU, dName("ADDU"); dGPR(_Rd_); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disAND, dName("AND"); dGPR(_Rd_); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disNOR, dName("NOR"); dGPR(_Rd_); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disOR, dName("OR"); dGPR(_Rd_); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disSLT, dName("SLT"); dGPR(_Rd_); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disSLTU, dName("SLTU"); dGPR(_Rd_); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disSUB, dName("SUB"); dGPR(_Rd_); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disSUBU, dName("SUBU"); dGPR(_Rd_); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disXOR, dName("XOR"); dGPR(_Rd_); dGPR(_Rs_); dGPR(_Rt_);)
/*********************************************************
* Register arithmetic & Register trap logic *
* Format: OP rs, rt *
*********************************************************/
MakeDisF(disDIV, dName("DIV"); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disDIVU, dName("DIVU"); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disMULT, dName("MULT"); dGPR(_Rs_); dGPR(_Rt_);)
MakeDisF(disMULTU, dName("MULTU"); dGPR(_Rs_); dGPR(_Rt_);)
/*********************************************************
* Register branch logic *
* Format: OP rs, offset *
*********************************************************/
MakeDisF(disBGEZ, dName("BGEZ"); dGPR(_Rs_); dOffset();)
MakeDisF(disBGEZAL, dName("BGEZAL"); dGPR(_Rs_); dOffset();)
MakeDisF(disBGTZ, dName("BGTZ"); dGPR(_Rs_); dOffset();)
MakeDisF(disBLEZ, dName("BLEZ"); dGPR(_Rs_); dOffset();)
MakeDisF(disBLTZ, dName("BLTZ"); dGPR(_Rs_); dOffset();)
MakeDisF(disBLTZAL, dName("BLTZAL"); dGPR(_Rs_); dOffset();)
/*********************************************************
* Shift arithmetic with constant shift *
* Format: OP rd, rt, sa *
*********************************************************/
MakeDisF(disSLL, if (code) { dName("SLL"); dGPR(_Rd_); dGPR(_Rt_); dSa(); } else { dName("NOP"); })
MakeDisF(disSRA, dName("SRA"); dGPR(_Rd_); dGPR(_Rt_); dSa();)
MakeDisF(disSRL, dName("SRL"); dGPR(_Rd_); dGPR(_Rt_); dSa();)
/*********************************************************
* Shift arithmetic with variant register shift *
* Format: OP rd, rt, rs *
*********************************************************/
MakeDisF(disSLLV, dName("SLLV"); dGPR(_Rd_); dGPR(_Rt_); dGPR(_Rs_);)
MakeDisF(disSRAV, dName("SRAV"); dGPR(_Rd_); dGPR(_Rt_); dGPR(_Rs_);)
MakeDisF(disSRLV, dName("SRLV"); dGPR(_Rd_); dGPR(_Rt_); dGPR(_Rs_);)
/*********************************************************
* Load higher 16 bits of the first word in GPR with imm *
* Format: OP rt, immediate *
*********************************************************/
MakeDisF(disLUI, dName("LUI"); dGPR(_Rt_); dImm();)
/*********************************************************
* Move from HI/LO to GPR *
* Format: OP rd *
*********************************************************/
MakeDisF(disMFHI, dName("MFHI"); dGPR(_Rd_); dHI();)
MakeDisF(disMFLO, dName("MFLO"); dGPR(_Rd_); dLO();)
/*********************************************************
* Move from GPR to HI/LO *
* Format: OP rd *
*********************************************************/
MakeDisF(disMTHI, dName("MTHI"); dHI(); dGPR(_Rs_);)
MakeDisF(disMTLO, dName("MTLO"); dLO(); dGPR(_Rs_);)
/*********************************************************
* Special purpose instructions *
* Format: OP *
*********************************************************/
MakeDisF(disBREAK, dName("BREAK"))
MakeDisF(disRFE, dName("RFE"))
MakeDisF(disSYSCALL, dName("SYSCALL"))
MakeDisF(disHLE, dName("HLE"))
MakeDisF(disRTPS, dName("RTPS"))
MakeDisF(disOP , dName("OP"))
MakeDisF(disNCLIP, dName("NCLIP"))
MakeDisF(disDPCS, dName("DPCS"))
MakeDisF(disINTPL, dName("INTPL"))
MakeDisF(disMVMVA, dName("MVMVA"))
MakeDisF(disNCDS , dName("NCDS"))
MakeDisF(disCDP , dName("CDP"))
MakeDisF(disNCDT , dName("NCDT"))
MakeDisF(disNCCS , dName("NCCS"))
MakeDisF(disCC , dName("CC"))
MakeDisF(disNCS , dName("NCS"))
MakeDisF(disNCT , dName("NCT"))
MakeDisF(disSQR , dName("SQR"))
MakeDisF(disDCPL , dName("DCPL"))
MakeDisF(disDPCT , dName("DPCT"))
MakeDisF(disAVSZ3, dName("AVSZ3"))
MakeDisF(disAVSZ4, dName("AVSZ4"))
MakeDisF(disRTPT , dName("RTPT"))
MakeDisF(disGPF , dName("GPF"))
MakeDisF(disGPL , dName("GPL"))
MakeDisF(disNCCT , dName("NCCT"))
MakeDisF(disMFC2, dName("MFC2"); dGPR(_Rt_);)
MakeDisF(disCFC2, dName("CFC2"); dGPR(_Rt_);)
MakeDisF(disMTC2, dName("MTC2"); dGPR(_Rt_);)
MakeDisF(disCTC2, dName("CTC2"); dGPR(_Rt_);)
/*********************************************************
* Register branch logic *
* Format: OP rs, rt, offset *
*********************************************************/
MakeDisF(disBEQ, dName("BEQ"); dGPR(_Rs_); dGPR(_Rt_); dOffset();)
MakeDisF(disBNE, dName("BNE"); dGPR(_Rs_); dGPR(_Rt_); dOffset();)
/*********************************************************
* Jump to target *
* Format: OP target *
*********************************************************/
MakeDisF(disJ, dName("J"); dTarget();)
MakeDisF(disJAL, dName("JAL"); dTarget(); dGPR(31);)
/*********************************************************
* Register jump *
* Format: OP rs, rd *
*********************************************************/
MakeDisF(disJR, dName("JR"); dGPR(_Rs_);)
MakeDisF(disJALR, dName("JALR"); dGPR(_Rs_); dGPR(_Rd_))
/*********************************************************
* Load and store for GPR *
* Format: OP rt, offset(base) *
*********************************************************/
MakeDisF(disLB, dName("LB"); dGPR(_Rt_); dOfB();)
MakeDisF(disLBU, dName("LBU"); dGPR(_Rt_); dOfB();)
MakeDisF(disLH, dName("LH"); dGPR(_Rt_); dOfB();)
MakeDisF(disLHU, dName("LHU"); dGPR(_Rt_); dOfB();)
MakeDisF(disLW, dName("LW"); dGPR(_Rt_); dOfB();)
MakeDisF(disLWL, dName("LWL"); dGPR(_Rt_); dOfB();)
MakeDisF(disLWR, dName("LWR"); dGPR(_Rt_); dOfB();)
MakeDisF(disLWC2, dName("LWC2"); dGPR(_Rt_); dOfB();)
MakeDisF(disSB, dName("SB"); dGPR(_Rt_); dOfB();)
MakeDisF(disSH, dName("SH"); dGPR(_Rt_); dOfB();)
MakeDisF(disSW, dName("SW"); dGPR(_Rt_); dOfB();)
MakeDisF(disSWL, dName("SWL"); dGPR(_Rt_); dOfB();)
MakeDisF(disSWR, dName("SWR"); dGPR(_Rt_); dOfB();)
MakeDisF(disSWC2, dName("SWC2"); dGPR(_Rt_); dOfB();)
/*********************************************************
* Moves between GPR and COPx *
* Format: OP rt, fs *
*********************************************************/
MakeDisF(disMFC0, dName("MFC0"); dGPR(_Rt_); dCP0(_Rd_);)
MakeDisF(disMTC0, dName("MTC0"); dCP0(_Rd_); dGPR(_Rt_);)
MakeDisF(disCFC0, dName("CFC0"); dGPR(_Rt_); dCP0(_Rd_);)
MakeDisF(disCTC0, dName("CTC0"); dCP0(_Rd_); dGPR(_Rt_);)
/*********************************************************
* Unknow instruction (would generate an exception) *
* Format: ? *
*********************************************************/
MakeDisF(disNULL, dName("*** Bad OP ***");)
TdisR3000AF disR3000A_SPECIAL[] = { // Subset of disSPECIAL
disSLL , disNULL , disSRL , disSRA , disSLLV , disNULL , disSRLV , disSRAV ,
disJR , disJALR , disNULL, disNULL, disSYSCALL, disBREAK , disNULL , disNULL ,
disMFHI, disMTHI , disMFLO, disMTLO, disNULL , disNULL , disNULL , disNULL ,
disMULT, disMULTU, disDIV , disDIVU, disNULL , disNULL , disNULL , disNULL ,
disADD , disADDU , disSUB , disSUBU, disAND , disOR , disXOR , disNOR ,
disNULL, disNULL , disSLT , disSLTU, disNULL , disNULL , disNULL , disNULL ,
disNULL, disNULL , disNULL, disNULL, disNULL , disNULL , disNULL , disNULL ,
disNULL, disNULL , disNULL, disNULL, disNULL , disNULL , disNULL , disNULL};
MakeDisF(disSPECIAL, disR3000A_SPECIAL[_Funct_](code, pc))
TdisR3000AF disR3000A_BCOND[] = { // Subset of disBCOND
disBLTZ , disBGEZ , disNULL, disNULL, disNULL, disNULL, disNULL, disNULL,
disNULL , disNULL , disNULL, disNULL, disNULL, disNULL, disNULL, disNULL,
disBLTZAL, disBGEZAL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL,
disNULL , disNULL , disNULL, disNULL, disNULL, disNULL, disNULL, disNULL};
MakeDisF(disBCOND, disR3000A_BCOND[_Rt_](code, pc))
TdisR3000AF disR3000A_COP0[] = { // Subset of disCOP0
disMFC0, disNULL, disCFC0, disNULL, disMTC0, disNULL, disCTC0, disNULL,
disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL,
disRFE , disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL,
disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL};
MakeDisF(disCOP0, disR3000A_COP0[_Rs_](code, pc))
TdisR3000AF disR3000A_BASIC[] = { // Subset of disBASIC (based on rs)
disMFC2, disNULL, disCFC2, disNULL, disMTC2, disNULL, disCTC2, disNULL,
disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL,
disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL,
disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL, disNULL};
MakeDisF(disBASIC, disR3000A_BASIC[_Rs_](code, pc))
TdisR3000AF disR3000A_COP2[] = { // Subset of disR3000F_COP2 (based on funct)
disBASIC, disRTPS , disNULL , disNULL , disNULL, disNULL , disNCLIP, disNULL,
disNULL , disNULL , disNULL , disNULL , disOP , disNULL , disNULL , disNULL,
disDPCS , disINTPL, disMVMVA, disNCDS , disCDP , disNULL , disNCDT , disNULL,
disNULL , disNULL , disNULL , disNCCS , disCC , disNULL , disNCS , disNULL,
disNCT , disNULL , disNULL , disNULL , disNULL, disNULL , disNULL , disNULL,
disSQR , disDCPL , disDPCT , disNULL , disNULL, disAVSZ3, disAVSZ4, disNULL,
disRTPT , disNULL , disNULL , disNULL , disNULL, disNULL , disNULL , disNULL,
disNULL , disNULL , disNULL , disNULL , disNULL, disGPF , disGPL , disNCCT };
MakeDisF(disCOP2, disR3000A_COP2[_Funct_](code, pc))
TdisR3000AF disR3000A[] = {
disSPECIAL , disBCOND , disJ , disJAL , disBEQ , disBNE , disBLEZ , disBGTZ ,
disADDI , disADDIU , disSLTI , disSLTIU, disANDI, disORI , disXORI , disLUI ,
disCOP0 , disNULL , disCOP2 , disNULL , disNULL, disNULL, disNULL , disNULL ,
disNULL , disNULL , disNULL , disNULL , disNULL, disNULL, disNULL , disNULL ,
disLB , disLH , disLWL , disLW , disLBU , disLHU , disLWR , disNULL ,
disSB , disSH , disSWL , disSW , disNULL, disNULL, disSWR , disNULL ,
disNULL , disNULL , disLWC2 , disNULL , disNULL, disNULL, disNULL , disNULL ,
disNULL , disNULL , disSWC2 , disHLE , disNULL, disNULL, disNULL , disNULL };
MakeDisFg(disR3000AF, disR3000A[code >> 26](code, pc))

904
libpcsxcore/gte.c Normal file
View File

@ -0,0 +1,904 @@
/***************************************************************************
* PCSX-Revolution - PlayStation Emulator for Nintendo Wii *
* Copyright (C) 2009-2010 PCSX-Revolution Dev Team *
* <http://code.google.com/p/pcsx-revolution/> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
/*
* GTE functions.
*/
#include "gte.h"
#include "psxmem.h"
#define VX(n) (n < 3 ? psxRegs.CP2D.p[n << 1].sw.l : psxRegs.CP2D.p[9].sw.l)
#define VY(n) (n < 3 ? psxRegs.CP2D.p[n << 1].sw.h : psxRegs.CP2D.p[10].sw.l)
#define VZ(n) (n < 3 ? psxRegs.CP2D.p[(n << 1) + 1].sw.l : psxRegs.CP2D.p[11].sw.l)
#define MX11(n) (n < 3 ? psxRegs.CP2C.p[(n << 3)].sw.l : 0)
#define MX12(n) (n < 3 ? psxRegs.CP2C.p[(n << 3)].sw.h : 0)
#define MX13(n) (n < 3 ? psxRegs.CP2C.p[(n << 3) + 1].sw.l : 0)
#define MX21(n) (n < 3 ? psxRegs.CP2C.p[(n << 3) + 1].sw.h : 0)
#define MX22(n) (n < 3 ? psxRegs.CP2C.p[(n << 3) + 2].sw.l : 0)
#define MX23(n) (n < 3 ? psxRegs.CP2C.p[(n << 3) + 2].sw.h : 0)
#define MX31(n) (n < 3 ? psxRegs.CP2C.p[(n << 3) + 3].sw.l : 0)
#define MX32(n) (n < 3 ? psxRegs.CP2C.p[(n << 3) + 3].sw.h : 0)
#define MX33(n) (n < 3 ? psxRegs.CP2C.p[(n << 3) + 4].sw.l : 0)
#define CV1(n) (n < 3 ? (s32)psxRegs.CP2C.r[(n << 3) + 5] : 0)
#define CV2(n) (n < 3 ? (s32)psxRegs.CP2C.r[(n << 3) + 6] : 0)
#define CV3(n) (n < 3 ? (s32)psxRegs.CP2C.r[(n << 3) + 7] : 0)
#define fSX(n) ((psxRegs.CP2D.p)[((n) + 12)].sw.l)
#define fSY(n) ((psxRegs.CP2D.p)[((n) + 12)].sw.h)
#define fSZ(n) ((psxRegs.CP2D.p)[((n) + 17)].w.l) /* (n == 0) => SZ1; */
#define gteVXY0 (psxRegs.CP2D.r[0])
#define gteVX0 (psxRegs.CP2D.p[0].sw.l)
#define gteVY0 (psxRegs.CP2D.p[0].sw.h)
#define gteVZ0 (psxRegs.CP2D.p[1].sw.l)
#define gteVXY1 (psxRegs.CP2D.r[2])
#define gteVX1 (psxRegs.CP2D.p[2].sw.l)
#define gteVY1 (psxRegs.CP2D.p[2].sw.h)
#define gteVZ1 (psxRegs.CP2D.p[3].sw.l)
#define gteVXY2 (psxRegs.CP2D.r[4])
#define gteVX2 (psxRegs.CP2D.p[4].sw.l)
#define gteVY2 (psxRegs.CP2D.p[4].sw.h)
#define gteVZ2 (psxRegs.CP2D.p[5].sw.l)
#define gteRGB (psxRegs.CP2D.r[6])
#define gteR (psxRegs.CP2D.p[6].b.l)
#define gteG (psxRegs.CP2D.p[6].b.h)
#define gteB (psxRegs.CP2D.p[6].b.h2)
#define gteCODE (psxRegs.CP2D.p[6].b.h3)
#define gteOTZ (psxRegs.CP2D.p[7].w.l)
#define gteIR0 (psxRegs.CP2D.p[8].sw.l)
#define gteIR1 (psxRegs.CP2D.p[9].sw.l)
#define gteIR2 (psxRegs.CP2D.p[10].sw.l)
#define gteIR3 (psxRegs.CP2D.p[11].sw.l)
#define gteSXY0 (psxRegs.CP2D.r[12])
#define gteSX0 (psxRegs.CP2D.p[12].sw.l)
#define gteSY0 (psxRegs.CP2D.p[12].sw.h)
#define gteSXY1 (psxRegs.CP2D.r[13])
#define gteSX1 (psxRegs.CP2D.p[13].sw.l)
#define gteSY1 (psxRegs.CP2D.p[13].sw.h)
#define gteSXY2 (psxRegs.CP2D.r[14])
#define gteSX2 (psxRegs.CP2D.p[14].sw.l)
#define gteSY2 (psxRegs.CP2D.p[14].sw.h)
#define gteSXYP (psxRegs.CP2D.r[15])
#define gteSXP (psxRegs.CP2D.p[15].sw.l)
#define gteSYP (psxRegs.CP2D.p[15].sw.h)
#define gteSZ0 (psxRegs.CP2D.p[16].w.l)
#define gteSZ1 (psxRegs.CP2D.p[17].w.l)
#define gteSZ2 (psxRegs.CP2D.p[18].w.l)
#define gteSZ3 (psxRegs.CP2D.p[19].w.l)
#define gteRGB0 (psxRegs.CP2D.r[20])
#define gteR0 (psxRegs.CP2D.p[20].b.l)
#define gteG0 (psxRegs.CP2D.p[20].b.h)
#define gteB0 (psxRegs.CP2D.p[20].b.h2)
#define gteCODE0 (psxRegs.CP2D.p[20].b.h3)
#define gteRGB1 (psxRegs.CP2D.r[21])
#define gteR1 (psxRegs.CP2D.p[21].b.l)
#define gteG1 (psxRegs.CP2D.p[21].b.h)
#define gteB1 (psxRegs.CP2D.p[21].b.h2)
#define gteCODE1 (psxRegs.CP2D.p[21].b.h3)
#define gteRGB2 (psxRegs.CP2D.r[22])
#define gteR2 (psxRegs.CP2D.p[22].b.l)
#define gteG2 (psxRegs.CP2D.p[22].b.h)
#define gteB2 (psxRegs.CP2D.p[22].b.h2)
#define gteCODE2 (psxRegs.CP2D.p[22].b.h3)
#define gteRES1 (psxRegs.CP2D.r[23])
#define gteMAC0 (((s32 *)psxRegs.CP2D.r)[24])
#define gteMAC1 (((s32 *)psxRegs.CP2D.r)[25])
#define gteMAC2 (((s32 *)psxRegs.CP2D.r)[26])
#define gteMAC3 (((s32 *)psxRegs.CP2D.r)[27])
#define gteIRGB (psxRegs.CP2D.r[28])
#define gteORGB (psxRegs.CP2D.r[29])
#define gteLZCS (psxRegs.CP2D.r[30])
#define gteLZCR (psxRegs.CP2D.r[31])
#define gteR11R12 (((s32 *)psxRegs.CP2C.r)[0])
#define gteR22R23 (((s32 *)psxRegs.CP2C.r)[2])
#define gteR11 (psxRegs.CP2C.p[0].sw.l)
#define gteR12 (psxRegs.CP2C.p[0].sw.h)
#define gteR13 (psxRegs.CP2C.p[1].sw.l)
#define gteR21 (psxRegs.CP2C.p[1].sw.h)
#define gteR22 (psxRegs.CP2C.p[2].sw.l)
#define gteR23 (psxRegs.CP2C.p[2].sw.h)
#define gteR31 (psxRegs.CP2C.p[3].sw.l)
#define gteR32 (psxRegs.CP2C.p[3].sw.h)
#define gteR33 (psxRegs.CP2C.p[4].sw.l)
#define gteTRX (((s32 *)psxRegs.CP2C.r)[5])
#define gteTRY (((s32 *)psxRegs.CP2C.r)[6])
#define gteTRZ (((s32 *)psxRegs.CP2C.r)[7])
#define gteL11 (psxRegs.CP2C.p[8].sw.l)
#define gteL12 (psxRegs.CP2C.p[8].sw.h)
#define gteL13 (psxRegs.CP2C.p[9].sw.l)
#define gteL21 (psxRegs.CP2C.p[9].sw.h)
#define gteL22 (psxRegs.CP2C.p[10].sw.l)
#define gteL23 (psxRegs.CP2C.p[10].sw.h)
#define gteL31 (psxRegs.CP2C.p[11].sw.l)
#define gteL32 (psxRegs.CP2C.p[11].sw.h)
#define gteL33 (psxRegs.CP2C.p[12].sw.l)
#define gteRBK (((s32 *)psxRegs.CP2C.r)[13])
#define gteGBK (((s32 *)psxRegs.CP2C.r)[14])
#define gteBBK (((s32 *)psxRegs.CP2C.r)[15])
#define gteLR1 (psxRegs.CP2C.p[16].sw.l)
#define gteLR2 (psxRegs.CP2C.p[16].sw.h)
#define gteLR3 (psxRegs.CP2C.p[17].sw.l)
#define gteLG1 (psxRegs.CP2C.p[17].sw.h)
#define gteLG2 (psxRegs.CP2C.p[18].sw.l)
#define gteLG3 (psxRegs.CP2C.p[18].sw.h)
#define gteLB1 (psxRegs.CP2C.p[19].sw.l)
#define gteLB2 (psxRegs.CP2C.p[19].sw.h)
#define gteLB3 (psxRegs.CP2C.p[20].sw.l)
#define gteRFC (((s32 *)psxRegs.CP2C.r)[21])
#define gteGFC (((s32 *)psxRegs.CP2C.r)[22])
#define gteBFC (((s32 *)psxRegs.CP2C.r)[23])
#define gteOFX (((s32 *)psxRegs.CP2C.r)[24])
#define gteOFY (((s32 *)psxRegs.CP2C.r)[25])
#define gteH (psxRegs.CP2C.p[26].sw.l)
#define gteDQA (psxRegs.CP2C.p[27].sw.l)
#define gteDQB (((s32 *)psxRegs.CP2C.r)[28])
#define gteZSF3 (psxRegs.CP2C.p[29].sw.l)
#define gteZSF4 (psxRegs.CP2C.p[30].sw.l)
#define gteFLAG (psxRegs.CP2C.r[31])
#define GTE_OP(op) ((op >> 20) & 31)
#define GTE_SF(op) ((op >> 19) & 1)
#define GTE_MX(op) ((op >> 17) & 3)
#define GTE_V(op) ((op >> 15) & 3)
#define GTE_CV(op) ((op >> 13) & 3)
#define GTE_CD(op) ((op >> 11) & 3) /* not used */
#define GTE_LM(op) ((op >> 10) & 1)
#define GTE_CT(op) ((op >> 6) & 15) /* not used */
#define GTE_FUNCT(op) (op & 63)
#define gteop (psxRegs.code & 0x1ffffff)
static inline s64 BOUNDS(s64 n_value, s64 n_max, int n_maxflag, s64 n_min, int n_minflag) {
if (n_value > n_max) {
gteFLAG |= n_maxflag;
} else if (n_value < n_min) {
gteFLAG |= n_minflag;
}
return n_value;
}
static inline s32 LIM(s32 value, s32 max, s32 min, u32 flag) {
s32 ret = value;
if (value > max) {
gteFLAG |= flag;
ret = max;
} else if (value < min) {
gteFLAG |= flag;
ret = min;
}
return ret;
}
#define A1(a) BOUNDS((a), 0x7fffffff, (1 << 30), -(s64)0x80000000, (1 << 31) | (1 << 27))
#define A2(a) BOUNDS((a), 0x7fffffff, (1 << 29), -(s64)0x80000000, (1 << 31) | (1 << 26))
#define A3(a) BOUNDS((a), 0x7fffffff, (1 << 28), -(s64)0x80000000, (1 << 31) | (1 << 25))
#define limB1(a, l) LIM((a), 0x7fff, -0x8000 * !l, (1 << 31) | (1 << 24))
#define limB2(a, l) LIM((a), 0x7fff, -0x8000 * !l, (1 << 31) | (1 << 23))
#define limB3(a, l) LIM((a), 0x7fff, -0x8000 * !l, (1 << 22))
#define limC1(a) LIM((a), 0x00ff, 0x0000, (1 << 21))
#define limC2(a) LIM((a), 0x00ff, 0x0000, (1 << 20))
#define limC3(a) LIM((a), 0x00ff, 0x0000, (1 << 19))
#define limD(a) LIM((a), 0xffff, 0x0000, (1 << 31) | (1 << 18))
static inline u32 limE(u32 result) {
if (result > 0x1ffff) {
gteFLAG |= (1 << 31) | (1 << 17);
return 0x1ffff;
}
return result;
}
#define F(a) BOUNDS((a), 0x7fffffff, (1 << 31) | (1 << 16), -(s64)0x80000000, (1 << 31) | (1 << 15))
#define limG1(a) LIM((a), 0x3ff, -0x400, (1 << 31) | (1 << 14))
#define limG2(a) LIM((a), 0x3ff, -0x400, (1 << 31) | (1 << 13))
#define limH(a) LIM((a), 0xfff, 0x000, (1 << 12))
#include "gte_divider.h"
static inline u32 MFC2(int reg) {
switch (reg) {
case 1:
case 3:
case 5:
case 8:
case 9:
case 10:
case 11:
psxRegs.CP2D.r[reg] = (s32)psxRegs.CP2D.p[reg].sw.l;
break;
case 7:
case 16:
case 17:
case 18:
case 19:
psxRegs.CP2D.r[reg] = (u32)psxRegs.CP2D.p[reg].w.l;
break;
case 15:
psxRegs.CP2D.r[reg] = gteSXY2;
break;
case 28:
case 30:
return 0;
case 29:
psxRegs.CP2D.r[reg] = LIM(gteIR1 >> 7, 0x1f, 0, 0) |
(LIM(gteIR2 >> 7, 0x1f, 0, 0) << 5) |
(LIM(gteIR3 >> 7, 0x1f, 0, 0) << 10);
break;
}
return psxRegs.CP2D.r[reg];
}
static inline void MTC2(u32 value, int reg) {
switch (reg) {
case 15:
gteSXY0 = gteSXY1;
gteSXY1 = gteSXY2;
gteSXY2 = value;
gteSXYP = value;
break;
case 28:
gteIRGB = value;
gteIR1 = (value & 0x1f) << 7;
gteIR2 = (value & 0x3e0) << 2;
gteIR3 = (value & 0x7c00) >> 3;
break;
case 30:
{
int a;
gteLZCS = value;
a = gteLZCS;
if (a > 0) {
int i;
for (i = 31; (a & (1 << i)) == 0 && i >= 0; i--);
gteLZCR = 31 - i;
} else if (a < 0) {
int i;
a ^= 0xffffffff;
for (i = 31; (a & (1 << i)) == 0 && i >= 0; i--);
gteLZCR = 31 - i;
} else {
gteLZCR = 32;
}
}
break;
case 7:
case 29:
case 31:
return;
default:
psxRegs.CP2D.r[reg] = value;
}
}
static inline void CTC2(u32 value, int reg) {
switch (reg) {
case 4:
case 12:
case 20:
case 26:
case 27:
case 29:
case 30:
value = (s32)(s16)value;
break;
case 31:
value = value & 0x7ffff000;
if (value & 0x7f87e000) value |= 0x80000000;
break;
}
psxRegs.CP2C.r[reg] = value;
}
void gteMFC2() {
if (!_Rt_) return;
psxRegs.GPR.r[_Rt_] = MFC2(_Rd_);
}
void gteCFC2() {
if (!_Rt_) return;
psxRegs.GPR.r[_Rt_] = psxRegs.CP2C.r[_Rd_];
}
void gteMTC2() {
MTC2(psxRegs.GPR.r[_Rt_], _Rd_);
}
void gteCTC2() {
CTC2(psxRegs.GPR.r[_Rt_], _Rd_);
}
#define _oB_ (psxRegs.GPR.r[_Rs_] + _Imm_)
void gteLWC2() {
MTC2(psxMemRead32(_oB_), _Rt_);
}
void gteSWC2() {
psxMemWrite32(_oB_, MFC2(_Rt_));
}
void gteRTPS() {
int quotient;
#ifdef GTE_LOG
GTE_LOG("GTE RTPS\n");
#endif
gteFLAG = 0;
gteMAC1 = A1((((s64)gteTRX << 12) + (gteR11 * gteVX0) + (gteR12 * gteVY0) + (gteR13 * gteVZ0)) >> 12);
gteMAC2 = A2((((s64)gteTRY << 12) + (gteR21 * gteVX0) + (gteR22 * gteVY0) + (gteR23 * gteVZ0)) >> 12);
gteMAC3 = A3((((s64)gteTRZ << 12) + (gteR31 * gteVX0) + (gteR32 * gteVY0) + (gteR33 * gteVZ0)) >> 12);
gteIR1 = limB1(gteMAC1, 0);
gteIR2 = limB2(gteMAC2, 0);
gteIR3 = limB3(gteMAC3, 0);
gteSZ0 = gteSZ1;
gteSZ1 = gteSZ2;
gteSZ2 = gteSZ3;
gteSZ3 = limD(gteMAC3);
quotient = limE(DIVIDE(gteH, gteSZ3));
gteSXY0 = gteSXY1;
gteSXY1 = gteSXY2;
gteSX2 = limG1(F((s64)gteOFX + ((s64)gteIR1 * quotient)) >> 16);
gteSY2 = limG2(F((s64)gteOFY + ((s64)gteIR2 * quotient)) >> 16);
gteMAC0 = F((s64)(gteDQB + ((s64)gteDQA * quotient)) >> 12);
gteIR0 = limH(gteMAC0);
}
void gteRTPT() {
int quotient;
int v;
s32 vx, vy, vz;
#ifdef GTE_LOG
GTE_LOG("GTE RTPT\n");
#endif
gteFLAG = 0;
gteSZ0 = gteSZ3;
for (v = 0; v < 3; v++) {
vx = VX(v);
vy = VY(v);
vz = VZ(v);
gteMAC1 = A1((((s64)gteTRX << 12) + (gteR11 * vx) + (gteR12 * vy) + (gteR13 * vz)) >> 12);
gteMAC2 = A2((((s64)gteTRY << 12) + (gteR21 * vx) + (gteR22 * vy) + (gteR23 * vz)) >> 12);
gteMAC3 = A3((((s64)gteTRZ << 12) + (gteR31 * vx) + (gteR32 * vy) + (gteR33 * vz)) >> 12);
gteIR1 = limB1(gteMAC1, 0);
gteIR2 = limB2(gteMAC2, 0);
gteIR3 = limB3(gteMAC3, 0);
fSZ(v) = limD(gteMAC3);
quotient = limE(DIVIDE(gteH, fSZ(v)));
fSX(v) = limG1(F((s64)gteOFX + ((s64)gteIR1 * quotient)) >> 16);
fSY(v) = limG2(F((s64)gteOFY + ((s64)gteIR2 * quotient)) >> 16);
}
gteMAC0 = F((s64)(gteDQB + ((s64)gteDQA * quotient)) >> 12);
gteIR0 = limH(gteMAC0);
}
void gteMVMVA() {
int shift = 12 * GTE_SF(gteop);
int mx = GTE_MX(gteop);
int v = GTE_V(gteop);
int cv = GTE_CV(gteop);
int lm = GTE_LM(gteop);
s32 vx = VX(v);
s32 vy = VY(v);
s32 vz = VZ(v);
#ifdef GTE_LOG
GTE_LOG("GTE MVMVA\n");
#endif
gteFLAG = 0;
gteMAC1 = A1((((s64)CV1(cv) << 12) + (MX11(mx) * vx) + (MX12(mx) * vy) + (MX13(mx) * vz)) >> shift);
gteMAC2 = A2((((s64)CV2(cv) << 12) + (MX21(mx) * vx) + (MX22(mx) * vy) + (MX23(mx) * vz)) >> shift);
gteMAC3 = A3((((s64)CV3(cv) << 12) + (MX31(mx) * vx) + (MX32(mx) * vy) + (MX33(mx) * vz)) >> shift);
gteIR1 = limB1(gteMAC1, lm);
gteIR2 = limB2(gteMAC2, lm);
gteIR3 = limB3(gteMAC3, lm);
}
void gteNCLIP() {
#ifdef GTE_LOG
GTE_LOG("GTE NCLIP\n");
#endif
gteFLAG = 0;
gteMAC0 = F((s64)gteSX0 * (gteSY1 - gteSY2) +
gteSX1 * (gteSY2 - gteSY0) +
gteSX2 * (gteSY0 - gteSY1));
}
void gteAVSZ3() {
#ifdef GTE_LOG
GTE_LOG("GTE AVSZ3\n");
#endif
gteFLAG = 0;
gteMAC0 = F((s64)(gteZSF3 * gteSZ1) + (gteZSF3 * gteSZ2) + (gteZSF3 * gteSZ3));
gteOTZ = limD(gteMAC0 >> 12);
}
void gteAVSZ4() {
#ifdef GTE_LOG
GTE_LOG("GTE AVSZ4\n");
#endif
gteFLAG = 0;
gteMAC0 = F((s64)(gteZSF4 * (gteSZ0 + gteSZ1 + gteSZ2 + gteSZ3)));
gteOTZ = limD(gteMAC0 >> 12);
}
void gteSQR() {
int shift = 12 * GTE_SF(gteop);
int lm = GTE_LM(gteop);
#ifdef GTE_LOG
GTE_LOG("GTE SQR\n");
#endif
gteFLAG = 0;
gteMAC1 = A1((gteIR1 * gteIR1) >> shift);
gteMAC2 = A2((gteIR2 * gteIR2) >> shift);
gteMAC3 = A3((gteIR3 * gteIR3) >> shift);
gteIR1 = limB1(gteMAC1 >> shift, lm);
gteIR2 = limB2(gteMAC2 >> shift, lm);
gteIR3 = limB3(gteMAC3 >> shift, lm);
}
void gteNCCS() {
#ifdef GTE_LOG
GTE_LOG("GTE NCCS\n");
#endif
gteFLAG = 0;
gteMAC1 = A1((((s64)gteL11 * gteVX0) + (gteL12 * gteVY0) + (gteL13 * gteVZ0)) >> 12);
gteMAC2 = A2((((s64)gteL21 * gteVX0) + (gteL22 * gteVY0) + (gteL23 * gteVZ0)) >> 12);
gteMAC3 = A3((((s64)gteL31 * gteVX0) + (gteL32 * gteVY0) + (gteL33 * gteVZ0)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1((((s64)gteRBK << 12) + (gteLR1 * gteIR1) + (gteLR2 * gteIR2) + (gteLR3 * gteIR3)) >> 12);
gteMAC2 = A2((((s64)gteGBK << 12) + (gteLG1 * gteIR1) + (gteLG2 * gteIR2) + (gteLG3 * gteIR3)) >> 12);
gteMAC3 = A3((((s64)gteBBK << 12) + (gteLB1 * gteIR1) + (gteLB2 * gteIR2) + (gteLB3 * gteIR3)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1(((s64)gteR * gteIR1) >> 8);
gteMAC2 = A2(((s64)gteG * gteIR2) >> 8);
gteMAC3 = A3(((s64)gteB * gteIR3) >> 8);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
void gteNCCT() {
int v;
s32 vx, vy, vz;
#ifdef GTE_LOG
GTE_LOG("GTE NCCT\n");
#endif
gteFLAG = 0;
for (v = 0; v < 3; v++) {
vx = VX(v);
vy = VY(v);
vz = VZ(v);
gteMAC1 = A1((((s64)gteL11 * vx) + (gteL12 * vy) + (gteL13 * vz)) >> 12);
gteMAC2 = A2((((s64)gteL21 * vx) + (gteL22 * vy) + (gteL23 * vz)) >> 12);
gteMAC3 = A3((((s64)gteL31 * vx) + (gteL32 * vy) + (gteL33 * vz)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1((((s64)gteRBK << 12) + (gteLR1 * gteIR1) + (gteLR2 * gteIR2) + (gteLR3 * gteIR3)) >> 12);
gteMAC2 = A2((((s64)gteGBK << 12) + (gteLG1 * gteIR1) + (gteLG2 * gteIR2) + (gteLG3 * gteIR3)) >> 12);
gteMAC3 = A3((((s64)gteBBK << 12) + (gteLB1 * gteIR1) + (gteLB2 * gteIR2) + (gteLB3 * gteIR3)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1(((s64)gteR * gteIR1) >> 8);
gteMAC2 = A2(((s64)gteG * gteIR2) >> 8);
gteMAC3 = A3(((s64)gteB * gteIR3) >> 8);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
}
void gteNCDS() {
#ifdef GTE_LOG
GTE_LOG("GTE NCDS\n");
#endif
gteFLAG = 0;
gteMAC1 = A1((((s64)gteL11 * gteVX0) + (gteL12 * gteVY0) + (gteL13 * gteVZ0)) >> 12);
gteMAC2 = A2((((s64)gteL21 * gteVX0) + (gteL22 * gteVY0) + (gteL23 * gteVZ0)) >> 12);
gteMAC3 = A3((((s64)gteL31 * gteVX0) + (gteL32 * gteVY0) + (gteL33 * gteVZ0)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1((((s64)gteRBK << 12) + (gteLR1 * gteIR1) + (gteLR2 * gteIR2) + (gteLR3 * gteIR3)) >> 12);
gteMAC2 = A2((((s64)gteGBK << 12) + (gteLG1 * gteIR1) + (gteLG2 * gteIR2) + (gteLG3 * gteIR3)) >> 12);
gteMAC3 = A3((((s64)gteBBK << 12) + (gteLB1 * gteIR1) + (gteLB2 * gteIR2) + (gteLB3 * gteIR3)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1(((((s64)gteR << 4) * gteIR1) + (gteIR0 * limB1(gteRFC - ((gteR * gteIR1) >> 8), 0))) >> 12);
gteMAC2 = A2(((((s64)gteG << 4) * gteIR2) + (gteIR0 * limB2(gteGFC - ((gteG * gteIR2) >> 8), 0))) >> 12);
gteMAC3 = A3(((((s64)gteB << 4) * gteIR3) + (gteIR0 * limB3(gteBFC - ((gteB * gteIR3) >> 8), 0))) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
void gteNCDT() {
int v;
s32 vx, vy, vz;
#ifdef GTE_LOG
GTE_LOG("GTE NCDT\n");
#endif
gteFLAG = 0;
for (v = 0; v < 3; v++) {
vx = VX(v);
vy = VY(v);
vz = VZ(v);
gteMAC1 = A1((((s64)gteL11 * vx) + (gteL12 * vy) + (gteL13 * vz)) >> 12);
gteMAC2 = A2((((s64)gteL21 * vx) + (gteL22 * vy) + (gteL23 * vz)) >> 12);
gteMAC3 = A3((((s64)gteL31 * vx) + (gteL32 * vy) + (gteL33 * vz)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1((((s64)gteRBK << 12) + (gteLR1 * gteIR1) + (gteLR2 * gteIR2) + (gteLR3 * gteIR3)) >> 12);
gteMAC2 = A2((((s64)gteGBK << 12) + (gteLG1 * gteIR1) + (gteLG2 * gteIR2) + (gteLG3 * gteIR3)) >> 12);
gteMAC3 = A3((((s64)gteBBK << 12) + (gteLB1 * gteIR1) + (gteLB2 * gteIR2) + (gteLB3 * gteIR3)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1(((((s64)gteR << 4) * gteIR1) + (gteIR0 * limB1(gteRFC - ((gteR * gteIR1) >> 8), 0))) >> 12);
gteMAC2 = A2(((((s64)gteG << 4) * gteIR2) + (gteIR0 * limB2(gteGFC - ((gteG * gteIR2) >> 8), 0))) >> 12);
gteMAC3 = A3(((((s64)gteB << 4) * gteIR3) + (gteIR0 * limB3(gteBFC - ((gteB * gteIR3) >> 8), 0))) >> 12);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
}
void gteOP() {
int shift = 12 * GTE_SF(gteop);
int lm = GTE_LM(gteop);
#ifdef GTE_LOG
GTE_LOG("GTE OP\n");
#endif
gteFLAG = 0;
gteMAC1 = A1(((s64)(gteR22 * gteIR3) - (gteR33 * gteIR2)) >> shift);
gteMAC2 = A2(((s64)(gteR33 * gteIR1) - (gteR11 * gteIR3)) >> shift);
gteMAC3 = A3(((s64)(gteR11 * gteIR2) - (gteR22 * gteIR1)) >> shift);
gteIR1 = limB1(gteMAC1, lm);
gteIR2 = limB2(gteMAC2, lm);
gteIR3 = limB3(gteMAC3, lm);
}
void gteDCPL() {
int lm = GTE_LM(gteop);
s64 RIR1 = ((s64)gteR * gteIR1) >> 8;
s64 GIR2 = ((s64)gteG * gteIR2) >> 8;
s64 BIR3 = ((s64)gteB * gteIR3) >> 8;
#ifdef GTE_LOG
GTE_LOG("GTE DCPL\n");
#endif
gteFLAG = 0;
gteMAC1 = A1(RIR1 + ((gteIR0 * limB1(gteRFC - RIR1, 0)) >> 12));
gteMAC2 = A2(GIR2 + ((gteIR0 * limB1(gteGFC - GIR2, 0)) >> 12));
gteMAC3 = A3(BIR3 + ((gteIR0 * limB1(gteBFC - BIR3, 0)) >> 12));
gteIR1 = limB1(gteMAC1, lm);
gteIR2 = limB2(gteMAC2, lm);
gteIR3 = limB3(gteMAC3, lm);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
void gteGPF() {
int shift = 12 * GTE_SF(gteop);
#ifdef GTE_LOG
GTE_LOG("GTE GPF\n");
#endif
gteFLAG = 0;
gteMAC1 = A1(((s64)gteIR0 * gteIR1) >> shift);
gteMAC2 = A2(((s64)gteIR0 * gteIR2) >> shift);
gteMAC3 = A3(((s64)gteIR0 * gteIR3) >> shift);
gteIR1 = limB1(gteMAC1, 0);
gteIR2 = limB2(gteMAC2, 0);
gteIR3 = limB3(gteMAC3, 0);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
void gteGPL() {
int shift = 12 * GTE_SF(gteop);
#ifdef GTE_LOG
GTE_LOG("GTE GPL\n");
#endif
gteFLAG = 0;
gteMAC1 = A1((((s64)gteMAC1 << shift) + (gteIR0 * gteIR1)) >> shift);
gteMAC2 = A2((((s64)gteMAC2 << shift) + (gteIR0 * gteIR2)) >> shift);
gteMAC3 = A3((((s64)gteMAC3 << shift) + (gteIR0 * gteIR3)) >> shift);
gteIR1 = limB1(gteMAC1, 0);
gteIR2 = limB2(gteMAC2, 0);
gteIR3 = limB3(gteMAC3, 0);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
void gteDPCS() {
int shift = 12 * GTE_SF(gteop);
#ifdef GTE_LOG
GTE_LOG("GTE DPCS\n");
#endif
gteFLAG = 0;
gteMAC1 = A1(((gteR << 16) + (gteIR0 * limB1(A1((s64)gteRFC - (gteR << 4)) << (12 - shift), 0))) >> 12);
gteMAC2 = A2(((gteG << 16) + (gteIR0 * limB2(A2((s64)gteGFC - (gteG << 4)) << (12 - shift), 0))) >> 12);
gteMAC3 = A3(((gteB << 16) + (gteIR0 * limB3(A3((s64)gteBFC - (gteB << 4)) << (12 - shift), 0))) >> 12);
gteIR1 = limB1(gteMAC1, 0);
gteIR2 = limB2(gteMAC2, 0);
gteIR3 = limB3(gteMAC3, 0);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
void gteDPCT() {
int v;
#ifdef GTE_LOG
GTE_LOG("GTE DPCT\n");
#endif
gteFLAG = 0;
for (v = 0; v < 3; v++) {
gteMAC1 = A1((((s64)gteR0 << 16) + ((s64)gteIR0 * (limB1(gteRFC - (gteR0 << 4), 0)))) >> 12);
gteMAC2 = A2((((s64)gteG0 << 16) + ((s64)gteIR0 * (limB1(gteGFC - (gteG0 << 4), 0)))) >> 12);
gteMAC3 = A3((((s64)gteB0 << 16) + ((s64)gteIR0 * (limB1(gteBFC - (gteB0 << 4), 0)))) >> 12);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
gteIR1 = limB1(gteMAC1, 0);
gteIR2 = limB2(gteMAC2, 0);
gteIR3 = limB3(gteMAC3, 0);
}
void gteNCS() {
#ifdef GTE_LOG
GTE_LOG("GTE NCS\n");
#endif
gteFLAG = 0;
gteMAC1 = A1((((s64)gteL11 * gteVX0) + (gteL12 * gteVY0) + (gteL13 * gteVZ0)) >> 12);
gteMAC2 = A2((((s64)gteL21 * gteVX0) + (gteL22 * gteVY0) + (gteL23 * gteVZ0)) >> 12);
gteMAC3 = A3((((s64)gteL31 * gteVX0) + (gteL32 * gteVY0) + (gteL33 * gteVZ0)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1((((s64)gteRBK << 12) + (gteLR1 * gteIR1) + (gteLR2 * gteIR2) + (gteLR3 * gteIR3)) >> 12);
gteMAC2 = A2((((s64)gteGBK << 12) + (gteLG1 * gteIR1) + (gteLG2 * gteIR2) + (gteLG3 * gteIR3)) >> 12);
gteMAC3 = A3((((s64)gteBBK << 12) + (gteLB1 * gteIR1) + (gteLB2 * gteIR2) + (gteLB3 * gteIR3)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
void gteNCT() {
int v;
s32 vx, vy, vz;
#ifdef GTE_LOG
GTE_LOG("GTE NCT\n");
#endif
gteFLAG = 0;
for (v = 0; v < 3; v++) {
vx = VX(v);
vy = VY(v);
vz = VZ(v);
gteMAC1 = A1((((s64)gteL11 * vx) + (gteL12 * vy) + (gteL13 * vz)) >> 12);
gteMAC2 = A2((((s64)gteL21 * vx) + (gteL22 * vy) + (gteL23 * vz)) >> 12);
gteMAC3 = A3((((s64)gteL31 * vx) + (gteL32 * vy) + (gteL33 * vz)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1((((s64)gteRBK << 12) + (gteLR1 * gteIR1) + (gteLR2 * gteIR2) + (gteLR3 * gteIR3)) >> 12);
gteMAC2 = A2((((s64)gteGBK << 12) + (gteLG1 * gteIR1) + (gteLG2 * gteIR2) + (gteLG3 * gteIR3)) >> 12);
gteMAC3 = A3((((s64)gteBBK << 12) + (gteLB1 * gteIR1) + (gteLB2 * gteIR2) + (gteLB3 * gteIR3)) >> 12);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
}
void gteCC() {
#ifdef GTE_LOG
GTE_LOG("GTE CC\n");
#endif
gteFLAG = 0;
gteMAC1 = A1((((s64)gteRBK << 12) + (gteLR1 * gteIR1) + (gteLR2 * gteIR2) + (gteLR3 * gteIR3)) >> 12);
gteMAC2 = A2((((s64)gteGBK << 12) + (gteLG1 * gteIR1) + (gteLG2 * gteIR2) + (gteLG3 * gteIR3)) >> 12);
gteMAC3 = A3((((s64)gteBBK << 12) + (gteLB1 * gteIR1) + (gteLB2 * gteIR2) + (gteLB3 * gteIR3)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1(((s64)gteR * gteIR1) >> 8);
gteMAC2 = A2(((s64)gteG * gteIR2) >> 8);
gteMAC3 = A3(((s64)gteB * gteIR3) >> 8);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
void gteINTPL() {
int shift = 12 * GTE_SF(gteop);
int lm = GTE_LM(gteop);
#ifdef GTE_LOG
GTE_LOG("GTE INTPL\n");
#endif
gteFLAG = 0;
gteMAC1 = A1(((gteIR1 << 12) + (gteIR0 * limB1(((s64)gteRFC - gteIR1), 0))) >> shift);
gteMAC2 = A2(((gteIR2 << 12) + (gteIR0 * limB2(((s64)gteGFC - gteIR2), 0))) >> shift);
gteMAC3 = A3(((gteIR3 << 12) + (gteIR0 * limB3(((s64)gteBFC - gteIR3), 0))) >> shift);
gteIR1 = limB1(gteMAC1, lm);
gteIR2 = limB2(gteMAC2, lm);
gteIR3 = limB3(gteMAC3, lm);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}
void gteCDP() {
#ifdef GTE_LOG
GTE_LOG("GTE CDP\n");
#endif
gteFLAG = 0;
gteMAC1 = A1((((s64)gteRBK << 12) + (gteLR1 * gteIR1) + (gteLR2 * gteIR2) + (gteLR3 * gteIR3)) >> 12);
gteMAC2 = A2((((s64)gteGBK << 12) + (gteLG1 * gteIR1) + (gteLG2 * gteIR2) + (gteLG3 * gteIR3)) >> 12);
gteMAC3 = A3((((s64)gteBBK << 12) + (gteLB1 * gteIR1) + (gteLB2 * gteIR2) + (gteLB3 * gteIR3)) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteMAC1 = A1(((((s64)gteR << 4) * gteIR1) + (gteIR0 * limB1(gteRFC - ((gteR * gteIR1) >> 8), 0))) >> 12);
gteMAC2 = A2(((((s64)gteG << 4) * gteIR2) + (gteIR0 * limB2(gteGFC - ((gteG * gteIR2) >> 8), 0))) >> 12);
gteMAC3 = A3(((((s64)gteB << 4) * gteIR3) + (gteIR0 * limB3(gteBFC - ((gteB * gteIR3) >> 8), 0))) >> 12);
gteIR1 = limB1(gteMAC1, 1);
gteIR2 = limB2(gteMAC2, 1);
gteIR3 = limB3(gteMAC3, 1);
gteRGB0 = gteRGB1;
gteRGB1 = gteRGB2;
gteCODE2 = gteCODE;
gteR2 = limC1(gteMAC1 >> 4);
gteG2 = limC2(gteMAC2 >> 4);
gteB2 = limC3(gteMAC3 >> 4);
}

65
libpcsxcore/gte.h Normal file
View File

@ -0,0 +1,65 @@
/***************************************************************************
* PCSX-Revolution - PlayStation Emulator for Nintendo Wii *
* Copyright (C) 2009-2010 PCSX-Revolution Dev Team *
* <http://code.google.com/p/pcsx-revolution/> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __GTE_H__
#define __GTE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "psxcommon.h"
#include "r3000a.h"
void gteMFC2();
void gteCFC2();
void gteMTC2();
void gteCTC2();
void gteLWC2();
void gteSWC2();
void gteRTPS();
void gteOP();
void gteNCLIP();
void gteDPCS();
void gteINTPL();
void gteMVMVA();
void gteNCDS();
void gteNCDT();
void gteCDP();
void gteNCCS();
void gteCC();
void gteNCS();
void gteNCT();
void gteSQR();
void gteDCPL();
void gteDPCT();
void gteAVSZ3();
void gteAVSZ4();
void gteRTPT();
void gteGPF();
void gteGPL();
void gteNCCT();
#ifdef __cplusplus
}
#endif
#endif

4133
libpcsxcore/gte_divider.h Normal file

File diff suppressed because it is too large Load Diff

79
libpcsxcore/ix86/iGte.h Normal file
View File

@ -0,0 +1,79 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __IGTE_H__
#define __IGTE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "../r3000a.h"
#include "../psxmem.h"
#define CP2_FUNC(f) \
void gte##f(); \
static void rec##f() { \
iFlushRegs(); \
MOV32ItoM((u32)&psxRegs.code, (u32)psxRegs.code); \
CALLFunc ((u32)gte##f); \
/* branch = 2; */\
}
#define CP2_FUNCNC(f) \
void gte##f(); \
static void rec##f() { \
iFlushRegs(); \
CALLFunc ((u32)gte##f); \
/* branch = 2; */\
}
CP2_FUNC(MFC2);
CP2_FUNC(MTC2);
CP2_FUNC(CFC2);
CP2_FUNC(CTC2);
CP2_FUNC(LWC2);
CP2_FUNC(SWC2);
CP2_FUNCNC(RTPS);
CP2_FUNC(OP);
CP2_FUNCNC(NCLIP);
CP2_FUNC(DPCS);
CP2_FUNC(INTPL);
CP2_FUNC(MVMVA);
CP2_FUNCNC(NCDS);
CP2_FUNCNC(NCDT);
CP2_FUNCNC(CDP);
CP2_FUNCNC(NCCS);
CP2_FUNCNC(CC);
CP2_FUNCNC(NCS);
CP2_FUNCNC(NCT);
CP2_FUNC(SQR);
CP2_FUNC(DCPL);
CP2_FUNCNC(DPCT);
CP2_FUNCNC(AVSZ3);
CP2_FUNCNC(AVSZ4);
CP2_FUNCNC(RTPT);
CP2_FUNC(GPF);
CP2_FUNC(GPL);
CP2_FUNCNC(NCCT);
#ifdef __cplusplus
}
#endif
#endif

2899
libpcsxcore/ix86/iR3000A.c Normal file

File diff suppressed because it is too large Load Diff

1723
libpcsxcore/ix86/ix86.c Normal file

File diff suppressed because it is too large Load Diff

673
libpcsxcore/ix86/ix86.h Normal file
View File

@ -0,0 +1,673 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
/*
* ix86 definitions v0.5.1
* Authors: linuzappz <linuzappz@pcsx.net>
* alexey silinov
*/
#ifndef __IX86_H__
#define __IX86_H__
#ifdef __cplusplus
extern "C" {
#endif
// include basic types
#include "../psxcommon.h"
#include "../r3000a.h"
#include "../psxhle.h"
// x86Flags defines
#define X86FLAG_FPU 0x00000001
#define X86FLAG_VME 0x00000002
#define X86FLAG_DEBUGEXT 0x00000004
#define X86FLAG_4MPAGE 0x00000008
#define X86FLAG_TSC 0x00000010
#define X86FLAG_MSR 0x00000020
#define X86FLAG_PAE 0x00000040
#define X86FLAG_MCHKXCP 0x00000080
#define X86FLAG_CMPXCHG8B 0x00000100
#define X86FLAG_APIC 0x00000200
#define X86FLAG_SYSENTER 0x00000800
#define X86FLAG_MTRR 0x00001000
#define X86FLAG_GPE 0x00002000
#define X86FLAG_MCHKARCH 0x00004000
#define X86FLAG_CMOV 0x00008000
#define X86FLAG_PAT 0x00010000
#define X86FLAG_PSE36 0x00020000
#define X86FLAG_PN 0x00040000
#define X86FLAG_MMX 0x00800000
#define X86FLAG_FXSAVE 0x01000000
#define X86FLAG_SSE 0x02000000
// x86EFlags defines
#define X86EFLAG_MMXEXT 0x00400000
#define X86EFLAG_3DNOWEXT 0x40000000
#define X86EFLAG_3DNOW 0x80000000
/* general defines */
#define write8(val) *(u8 *)x86Ptr = val; x86Ptr++;
#define write16(val) *(u16*)x86Ptr = val; x86Ptr+=2;
#define write32(val) *(u32*)x86Ptr = val; x86Ptr+=4;
#define write64(val) *(u64*)x86Ptr = val; x86Ptr+=8;
#define EAX 0
#define EBX 3
#define ECX 1
#define EDX 2
#define ESI 6
#define EDI 7
#define EBP 5
#define ESP 4
#define MM0 0
#define MM1 1
#define MM2 2
#define MM3 3
#define MM4 4
#define MM5 5
#define MM6 6
#define MM7 7
#define XMM0 0
#define XMM1 1
#define XMM2 2
#define XMM3 3
#define XMM4 4
#define XMM5 5
#define XMM6 6
#define XMM7 7
extern s8 *x86Ptr;
extern u8 *j8Ptr[32];
extern u32 *j32Ptr[32];
void x86Init();
void x86SetPtr(char *ptr);
void x86Shutdown();
void x86SetJ8(u8 *j8);
void x86SetJ32(u32 *j32);
void x86Align(int bytes);
/********************/
/* IX86 intructions */
/********************/
/*
* scale values:
* 0 - *1
* 1 - *2
* 2 - *4
* 3 - *8
*/
////////////////////////////////////
// mov instructions /
////////////////////////////////////
/* mov r32 to r32 */
void MOV32RtoR(int to, int from);
/* mov r32 to m32 */
void MOV32RtoM(u32 to, int from);
/* mov m32 to r32 */
void MOV32MtoR(int to, u32 from);
/* mov [r32] to r32 */
void MOV32RmtoR(int to, int from);
/* mov [r32][r32*scale] to r32 */
void MOV32RmStoR(int to, int from, int from2, int scale);
/* mov r32 to [r32] */
void MOV32RtoRm(int to, int from);
/* mov r32 to [r32][r32*scale] */
void MOV32RtoRmS(int to, int to2, int scale, int from);
/* mov imm32 to r32 */
void MOV32ItoR(int to, u32 from);
/* mov imm32 to m32 */
void MOV32ItoM(u32 to, u32 from);
/* mov r16 to m16 */
void MOV16RtoM(u32 to, int from);
/* mov m16 to r16 */
void MOV16MtoR(int to, u32 from);
/* mov imm16 to m16 */
void MOV16ItoM(u32 to, u16 from);
/* mov r8 to m8 */
void MOV8RtoM(u32 to, int from);
/* mov m8 to r8 */
void MOV8MtoR(int to, u32 from);
/* mov imm8 to m8 */
void MOV8ItoM(u32 to, u8 from);
/* movsx r8 to r32 */
void MOVSX32R8toR(int to, int from);
/* movsx m8 to r32 */
void MOVSX32M8toR(int to, u32 from);
/* movsx r16 to r32 */
void MOVSX32R16toR(int to, int from);
/* movsx m16 to r32 */
void MOVSX32M16toR(int to, u32 from);
/* movzx r8 to r32 */
void MOVZX32R8toR(int to, int from);
/* movzx m8 to r32 */
void MOVZX32M8toR(int to, u32 from);
/* movzx r16 to r32 */
void MOVZX32R16toR(int to, int from);
/* movzx m16 to r32 */
void MOVZX32M16toR(int to, u32 from);
/* cmovne r32 to r32 */
void CMOVNE32RtoR(int to, int from);
/* cmovne m32 to r32*/
void CMOVNE32MtoR(int to, u32 from);
/* cmove r32 to r32*/
void CMOVE32RtoR(int to, int from);
/* cmove m32 to r32*/
void CMOVE32MtoR(int to, u32 from);
/* cmovg r32 to r32*/
void CMOVG32RtoR(int to, int from);
/* cmovg m32 to r32*/
void CMOVG32MtoR(int to, u32 from);
/* cmovge r32 to r32*/
void CMOVGE32RtoR(int to, int from);
/* cmovge m32 to r32*/
void CMOVGE32MtoR(int to, u32 from);
/* cmovl r32 to r32*/
void CMOVL32RtoR(int to, int from);
/* cmovl m32 to r32*/
void CMOVL32MtoR(int to, u32 from);
/* cmovle r32 to r32*/
void CMOVLE32RtoR(int to, int from);
/* cmovle m32 to r32*/
void CMOVLE32MtoR(int to, u32 from);
////////////////////////////////////
// arithmetic instructions /
////////////////////////////////////
/* add imm32 to r32 */
void ADD32ItoR(int to, u32 from);
/* add imm32 to m32 */
void ADD32ItoM(u32 to, u32 from);
/* add r32 to r32 */
void ADD32RtoR(int to, int from);
/* add r32 to m32 */
void ADD32RtoM(u32 to, int from);
/* add m32 to r32 */
void ADD32MtoR(int to, u32 from);
/* adc imm32 to r32 */
void ADC32ItoR(int to, u32 from);
/* adc r32 to r32 */
void ADC32RtoR(int to, int from);
/* adc m32 to r32 */
void ADC32MtoR(int to, u32 from);
/* inc r32 */
void INC32R(int to);
/* inc m32 */
void INC32M(u32 to);
/* sub imm32 to r32 */
void SUB32ItoR(int to, u32 from);
/* sub r32 to r32 */
void SUB32RtoR(int to, int from);
/* sub m32 to r32 */
void SUB32MtoR(int to, u32 from);
/* sbb imm32 to r32 */
void SBB32ItoR(int to, u32 from);
/* sbb r32 to r32 */
void SBB32RtoR(int to, int from);
/* sbb m32 to r32 */
void SBB32MtoR(int to, u32 from);
/* dec r32 */
void DEC32R(int to);
/* dec m32 */
void DEC32M(u32 to);
/* mul eax by r32 to edx:eax */
void MUL32R(int from);
/* mul eax by m32 to edx:eax */
void MUL32M(u32 from);
/* imul eax by r32 to edx:eax */
void IMUL32R(int from);
/* imul eax by m32 to edx:eax */
void IMUL32M(u32 from);
/* imul r32 by r32 to r32 */
void IMUL32RtoR(int to, int from);
/* div eax by r32 to edx:eax */
void DIV32R(int from);
/* div eax by m32 to edx:eax */
void DIV32M(u32 from);
/* idiv eax by r32 to edx:eax */
void IDIV32R(int from);
/* idiv eax by m32 to edx:eax */
void IDIV32M(u32 from);
////////////////////////////////////
// shifting instructions /
////////////////////////////////////
/* shl imm8 to r32 */
void SHL32ItoR(int to, u8 from);
/* shl cl to r32 */
void SHL32CLtoR(int to);
/* shr imm8 to r32 */
void SHR32ItoR(int to, u8 from);
/* shr cl to r32 */
void SHR32CLtoR(int to);
/* sar imm8 to r32 */
void SAR32ItoR(int to, u8 from);
/* sar cl to r32 */
void SAR32CLtoR(int to);
/* sal imm8 to r32 */
#define SAL32ItoR SHL32ItoR
/* sal cl to r32 */
#define SAL32CLtoR SHL32CLtoR
// logical instructions
/* or imm32 to r32 */
void OR32ItoR(int to, u32 from);
/* or imm32 to m32 */
void OR32ItoM(u32 to, u32 from);
/* or r32 to r32 */
void OR32RtoR(int to, int from);
/* or r32 to m32 */
void OR32RtoM(u32 to, int from);
/* or m32 to r32 */
void OR32MtoR(int to, u32 from);
/* xor imm32 to r32 */
void XOR32ItoR(int to, u32 from);
/* xor imm32 to m32 */
void XOR32ItoM(u32 to, u32 from);
/* xor r32 to r32 */
void XOR32RtoR(int to, int from);
/* xor r32 to m32 */
void XOR32RtoM(u32 to, int from);
/* xor m32 to r32 */
void XOR32MtoR(int to, u32 from);
/* and imm32 to r32 */
void AND32ItoR(int to, u32 from);
/* and imm32 to m32 */
void AND32ItoM(u32 to, u32 from);
/* and r32 to r32 */
void AND32RtoR(int to, int from);
/* and r32 to m32 */
void AND32RtoM(u32 to, int from);
/* and m32 to r32 */
void AND32MtoR(int to, u32 from);
/* not r32 */
void NOT32R(int from);
/* neg r32 */
void NEG32R(int from);
////////////////////////////////////
// jump instructions /
////////////////////////////////////
/* jmp rel8 */
u8* JMP8(u8 to);
/* jmp rel32 */
u32* JMP32(u32 to);
/* jmp r32 */
void JMP32R(int to);
/* je rel8 */
u8* JE8(u8 to);
/* jz rel8 */
u8* JZ8(u8 to);
/* jg rel8 */
u8* JG8(u8 to);
/* jge rel8 */
u8* JGE8(u8 to);
/* jl rel8 */
u8* JL8(u8 to);
/* jle rel8 */
u8* JLE8(u8 to);
/* jne rel8 */
u8* JNE8(u8 to);
/* jnz rel8 */
u8* JNZ8(u8 to);
/* jng rel8 */
u8* JNG8(u8 to);
/* jnge rel8 */
u8* JNGE8(u8 to);
/* jnl rel8 */
u8* JNL8(u8 to);
/* jnle rel8 */
u8* JNLE8(u8 to);
/* jo rel8 */
u8* JO8(u8 to);
/* jno rel8 */
u8* JNO8(u8 to);
/* je rel32 */
u32* JE32(u32 to);
/* jz rel32 */
u32* JZ32(u32 to);
/* jg rel32 */
u32* JG32(u32 to);
/* jge rel32 */
u32* JGE32(u32 to);
/* jl rel32 */
u32* JL32(u32 to);
/* jle rel32 */
u32* JLE32(u32 to);
/* jne rel32 */
u32* JNE32(u32 to);
/* jnz rel32 */
u32* JNZ32(u32 to);
/* jng rel32 */
u32* JNG32(u32 to);
/* jnge rel32 */
u32* JNGE32(u32 to);
/* jnl rel32 */
u32* JNL32(u32 to);
/* jnle rel32 */
u32* JNLE32(u32 to);
/* jo rel32 */
u32* JO32(u32 to);
/* jno rel32 */
u32* JNO32(u32 to);
/* call func */
void CALLFunc(u32 func); // based on CALL32
/* call rel32 */
void CALL32(u32 to);
/* call r32 */
void CALL32R(int to);
/* call m32 */
void CALL32M(u32 to);
////////////////////////////////////
// misc instructions /
////////////////////////////////////
/* cmp imm32 to r32 */
void CMP32ItoR(int to, u32 from);
/* cmp imm32 to m32 */
void CMP32ItoM(u32 to, u32 from);
/* cmp r32 to r32 */
void CMP32RtoR(int to, int from);
/* cmp m32 to r32 */
void CMP32MtoR(int to, u32 from);
/* test imm32 to r32 */
void TEST32ItoR(int to, u32 from);
/* test r32 to r32 */
void TEST32RtoR(int to, int from);
/* sets r8 */
void SETS8R(int to);
/* setl r8 */
void SETL8R(int to);
/* setb r8 */
void SETB8R(int to);
/* cbw */
void CBW();
/* cwd */
void CWD();
/* cdq */
void CDQ();
/* push r32 */
void PUSH32R(int from);
/* push m32 */
void PUSH32M(u32 from);
/* push imm32 */
void PUSH32I(u32 from);
/* pop r32 */
void POP32R(int from);
/* pushad */
void PUSHA32();
/* popad */
void POPA32();
/* ret */
void RET();
/********************/
/* FPU instructions */
/********************/
/* fild m32 to fpu reg stack */
void FILD32(u32 from);
/* fistp m32 from fpu reg stack */
void FISTP32(u32 from);
/* fld m32 to fpu reg stack */
void FLD32(u32 from);
/* fstp m32 from fpu reg stack */
void FSTP32(u32 to);
/* fldcw fpu control word from m16 */
void FLDCW(u32 from);
/* fstcw fpu control word to m16 */
void FNSTCW(u32 to);
/* fadd m32 to fpu reg stack */
void FADD32(u32 from);
/* fsub m32 to fpu reg stack */
void FSUB32(u32 from);
/* fmul m32 to fpu reg stack */
void FMUL32(u32 from);
/* fdiv m32 to fpu reg stack */
void FDIV32(u32 from);
/* fabs fpu reg stack */
void FABS();
/* fsqrt fpu reg stack */
void FSQRT();
/* fchs fpu reg stack */
void FCHS();
/********************/
/* MMX instructions */
/********************/
// r64 = mm
/* movq m64 to r64 */
void MOVQMtoR(int to, u32 from);
/* movq r64 to m64 */
void MOVQRtoM(u32 to, int from);
/* pand r64 to r64 */
void PANDRtoR(int to, int from);
/* pand m64 to r64 */
void PANDMtoR(int to, u32 from);
/* pandn r64 to r64 */
void PANDNRtoR(int to, int from);
/* pandn r64 to r64 */
void PANDNMtoR(int to, u32 from);
/* por r64 to r64 */
void PORRtoR(int to, int from);
/* por m64 to r64 */
void PORMtoR(int to, u32 from);
/* pxor r64 to r64 */
void PXORRtoR(int to, int from);
/* pxor m64 to r64 */
void PXORMtoR(int to, u32 from);
/* psllq r64 to r64 */
void PSLLQRtoR(int to, int from);
/* psllq m64 to r64 */
void PSLLQMtoR(int to, u32 from);
/* psllq imm8 to r64 */
void PSLLQItoR(int to, u8 from);
/* psrlq r64 to r64 */
void PSRLQRtoR(int to, int from);
/* psrlq m64 to r64 */
void PSRLQMtoR(int to, u32 from);
/* psrlq imm8 to r64 */
void PSRLQItoR(int to, u8 from);
/* paddusb r64 to r64 */
void PADDUSBRtoR(int to, int from);
/* paddusb m64 to r64 */
void PADDUSBMtoR(int to, u32 from);
/* paddusw r64 to r64 */
void PADDUSWRtoR(int to, int from);
/* paddusw m64 to r64 */
void PADDUSWMtoR(int to, u32 from);
/* paddb r64 to r64 */
void PADDBRtoR(int to, int from);
/* paddb m64 to r64 */
void PADDBMtoR(int to, u32 from);
/* paddw r64 to r64 */
void PADDWRtoR(int to, int from);
/* paddw m64 to r64 */
void PADDWMtoR(int to, u32 from);
/* paddd r64 to r64 */
void PADDDRtoR(int to, int from);
/* paddd m64 to r64 */
void PADDDMtoR(int to, u32 from);
/* emms */
void EMMS();
void FEMMS();
void BT32ItoR(int to,int from);
void RCR32ItoR(int to,int from);
//Basara:changed
void PADDSBRtoR(int to, int from);
void PADDSWRtoR(int to, int from);
void PADDSDRtoR(int to, int from);
void PSUBSBRtoR(int to, int from);
void PSUBSWRtoR(int to, int from);
void PSUBSDRtoR(int to, int from);
void PSUBBRtoR(int to, int from);
void PSUBWRtoR(int to, int from);
void PSUBDRtoR(int to, int from);
void MOVQ64ItoR(int reg,u64 i); //Prototype.Todo add all consts to end of block.not after jr $+8
void PMAXSWRtoR(int to,int from);
void PMINSWRtoR(int to,int from);
void PCMPEQBRtoR(int to,int from);
void PCMPEQWRtoR(int to,int from);
void PCMPEQDRtoR(int to,int from);
void PCMPGTBRtoR(int to,int from);
void PCMPGTWRtoR(int to,int from);
void PCMPGTDRtoR(int to,int from);
void PSRLWItoR(int to,int from);
void PSRLDItoR(int to,int from);
void PSLLWItoR(int to,int from);
void PSLLDItoR(int to,int from);
void PSRAWItoR(int to,int from);
void PSRADItoR(int to,int from);
//Added:basara 11.01.2003
void FCOMP32(u32 from);
void FNSTSWtoAX();
void SETNZ8R(int to);
//Added:basara 14.01.2003
void PFCMPEQMtoR(int to,int from);
void PFCMPGTMtoR(int to,int from);
void PFCMPGEMtoR(int to,int from);
void PFADDMtoR(int to,int from);
void PFADDRtoR(int to,int from);
void PFSUBMtoR(int to,int from);
void PFSUBRtoR(int to,int from);
void PFMULMtoR(int to,int from);
void PFMULRtoR(int to,int from);
void PFRCPMtoR(int to,int from);
void PFRCPRtoR(int to,int from);
void PFRCPIT1RtoR(int to,int from);
void PFRCPIT2RtoR(int to,int from);
void PFRSQRTRtoR(int to,int from);
void PFRSQIT1RtoR(int to,int from);
void PF2IDMtoR(int to,int from);
void PF2IDRtoR(int to,int from);
void PI2FDMtoR(int to,int from);
void PI2FDRtoR(int to,int from);
void PFMAXMtoR(int to,int from);
void PFMAXRtoR(int to,int from);
void PFMINMtoR(int to,int from);
void PFMINRtoR(int to,int from);
void MOVDMtoR(int to, u32 from);
void MOVDRtoM(u32 to, int from);
void MOVD32RtoR(int to, int from);
void MOVD64RtoR(int to, int from);
void MOVQRtoR(int to,int from);
//if to==from MMLO=MMHI
void PUNPCKHDQRtoR(int to,int from);
//if to==from MMHI=MMLO
void PUNPCKLDQRtoR(int to,int from);
/*
SSE intructions
*/
void MOVAPSMtoR(int to,int from);
void MOVAPSRtoM(int to,int from);
void MOVAPSRtoR(int to,int from);
void ORPSMtoR(int to,int from);
void ORPSRtoR(int to,int from);
void XORPSMtoR(int to,int from);
void XORPSRtoR(int to,int from);
void ANDPSMtoR(int to,int from);
void ANDPSRtoR(int to,int from);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,2 @@
This is the AMD64 dynamic recompiler.
Made from opcodes from PCSX2 0.9.3 and the x86 recompiler modified to fit. ie. currently no AMD64/SSE specific code advantages.

View File

@ -0,0 +1,79 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __IGTE_H__
#define __IGTE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "../r3000a.h"
#include "../psxmem.h"
#define CP2_FUNC(f) \
void gte##f(); \
static void rec##f() { \
iFlushRegs(); \
MOV32ItoM((uptr)&psxRegs.code, (u32)psxRegs.code); \
CALLFunc((uptr)gte##f); \
/* branch = 2; */\
}
#define CP2_FUNCNC(f) \
void gte##f(); \
static void rec##f() { \
iFlushRegs(); \
CALLFunc((uptr)gte##f); \
/* branch = 2; */\
}
CP2_FUNC(MFC2);
CP2_FUNC(MTC2);
CP2_FUNC(CFC2);
CP2_FUNC(CTC2);
CP2_FUNC(LWC2);
CP2_FUNC(SWC2);
CP2_FUNCNC(RTPS);
CP2_FUNC(OP);
CP2_FUNCNC(NCLIP);
CP2_FUNC(DPCS);
CP2_FUNC(INTPL);
CP2_FUNC(MVMVA);
CP2_FUNCNC(NCDS);
CP2_FUNCNC(NCDT);
CP2_FUNCNC(CDP);
CP2_FUNCNC(NCCS);
CP2_FUNCNC(CC);
CP2_FUNCNC(NCS);
CP2_FUNCNC(NCT);
CP2_FUNC(SQR);
CP2_FUNC(DCPL);
CP2_FUNCNC(DPCT);
CP2_FUNCNC(AVSZ3);
CP2_FUNCNC(AVSZ4);
CP2_FUNCNC(RTPT);
CP2_FUNC(GPF);
CP2_FUNC(GPL);
CP2_FUNCNC(NCCT);
#ifdef __cplusplus
}
#endif
#endif

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

@ -0,0 +1,178 @@
// stop compiling if NORECBUILD build (only for Visual Studio)
#if !(defined(_MSC_VER) && defined(PCSX2_NORECBUILD))
#include "ix86-64.h"
/**********************/
/* 3DNOW instructions */
/**********************/
/* femms */
void FEMMS( void )
{
write16( 0x0E0F );
}
void PFCMPEQMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0xB0 );
}
void PFCMPGTMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0xA0 );
}
void PFCMPGEMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0x90 );
}
void PFADDMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0x9E );
}
void PFADDRtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0x9E );
}
void PFSUBMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0x9A );
}
void PFSUBRtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0x9A );
}
void PFMULMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0xB4 );
}
void PFMULRtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0xB4 );
}
void PFRCPMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0x96 );
}
void PFRCPRtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0x96 );
}
void PFRCPIT1RtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0xA6 );
}
void PFRCPIT2RtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0xB6 );
}
void PFRSQRTRtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0x97 );
}
void PFRSQIT1RtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0xA7 );
}
void PF2IDMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0x1D );
}
void PF2IDRtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0x1D );
}
void PI2FDMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0x0D );
}
void PI2FDRtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0x0D );
}
void PFMAXMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0xA4 );
}
void PFMAXRtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0xA4 );
}
void PFMINMtoR( x86IntRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x0F), true, to, from, 1);
write8( 0x94 );
}
void PFMINRtoR( x86IntRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x0F0F );
ModRM( 3, to, from );
write8( 0x94 );
}
#endif

View File

@ -0,0 +1,487 @@
/* Cpudetection lib
* Copyright (C) 2002-2003 Pcsx2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#if defined (_WIN32)
#include <windows.h>
#endif
#include <string.h>
#include <stdio.h>
#include "ix86-64.h"
#if defined (_MSC_VER) && _MSC_VER >= 1400
void __cpuid(int* CPUInfo, int InfoType);
unsigned __int64 __rdtsc();
#pragma intrinsic(__cpuid)
#pragma intrinsic(__rdtsc)
#endif
CAPABILITIES cpucaps;
CPUINFO cpuinfo;
#define cpuid(cmd,a,b,c,d) \
__asm__ __volatile__("cpuid" \
: "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "0" (cmd))
static s32 iCpuId( u32 cmd, u32 *regs )
{
int flag=1;
#if defined (_MSC_VER) && _MSC_VER >= 1400
__cpuid( regs, cmd );
return 0;
#elif defined (_MSC_VER)
#ifdef __x86_64__
assert(0);
#else // __x86_64__
__asm
{
push ebx;
push edi;
pushfd;
pop eax;
mov edx, eax;
xor eax, 1 << 21;
push eax;
popfd;
pushfd;
pop eax;
xor eax, edx;
mov flag, eax;
}
if ( ! flag )
{
return -1;
}
__asm
{
mov eax, cmd;
cpuid;
mov edi, [regs]
mov [edi], eax;
mov [edi+4], ebx;
mov [edi+8], ecx;
mov [edi+12], edx;
pop edi;
pop ebx;
}
#endif // __x86_64__
return 0;
#else
#ifndef __x86_64__
// see if we can use cpuid
__asm__ __volatile__ (
"sub $0x18, %%esp\n"
"pushf\n"
"pop %%eax\n"
"mov %%eax, %%edx\n"
"xor $0x200000, %%eax\n"
"push %%eax\n"
"popf\n"
"pushf\n"
"pop %%eax\n"
"xor %%edx, %%eax\n"
"mov %%eax, %0\n"
"add $0x18, %%esp\n"
: "=r"(flag) :
);
#endif
if ( !flag )
return -1;
cpuid(cmd, regs[0], regs[1], regs[2], regs[3]);
return 0;
#endif // _MSC_VER
}
u64 GetCPUTick( void )
{
#if defined (_MSC_VER) && _MSC_VER >= 1400
return __rdtsc();
#elif defined(__MSCW32__) && !defined(__x86_64__)
__asm rdtsc;
#else
u32 _a, _d;
__asm__ __volatile__ ("rdtsc" : "=a"(_a), "=d"(_d));
return (u64)_a | ((u64)_d << 32);
#endif
}
#if defined __LINUX__
#include <sys/time.h>
#include <errno.h>
//*
unsigned long timeGetTime2()
{
struct timeval tv;
gettimeofday(&tv, 0); // well, maybe there are better ways
return (unsigned long)tv.tv_sec * 1000 + tv.tv_usec/1000; // to do that, but at least it works
}
//*/
#endif
s64 CPUSpeedHz( unsigned int time )
{
s64 timeStart,
timeStop;
s64 startTick,
endTick;
s64 overhead;
if( ! cpucaps.hasTimeStampCounter )
{
return 0; //check if function is supported
}
overhead = GetCPUTick() - GetCPUTick();
timeStart = timeGetTime2( );
while( timeGetTime2( ) == timeStart )
{
timeStart = timeGetTime2( );
}
for(;;)
{
timeStop = timeGetTime2( );
if ( ( timeStop - timeStart ) > 1 )
{
startTick = GetCPUTick( );
break;
}
}
timeStart = timeStop;
for(;;)
{
timeStop = timeGetTime2( );
if ( ( timeStop - timeStart ) > time )
{
endTick = GetCPUTick( );
break;
}
}
return (s64)( ( endTick - startTick ) + ( overhead ) );
}
////////////////////////////////////////////////////
void cpudetectInit( void )
{
u32 regs[ 4 ];
u32 cmds;
u32 AMDspeed;
s8 AMDspeedString[10];
int cputype=0; // Cpu type
//AMD 64 STUFF
u32 x86_64_8BITBRANDID;
u32 x86_64_12BITBRANDID;
memset( cpuinfo.x86ID, 0, sizeof( cpuinfo.x86ID ) );
cpuinfo.x86Family = 0;
cpuinfo.x86Model = 0;
cpuinfo.x86PType = 0;
cpuinfo.x86StepID = 0;
cpuinfo.x86Flags = 0;
cpuinfo.x86EFlags = 0;
if ( iCpuId( 0, regs ) == -1 ) return;
cmds = regs[ 0 ];
((u32*)cpuinfo.x86ID)[ 0 ] = regs[ 1 ];
((u32*)cpuinfo.x86ID)[ 1 ] = regs[ 3 ];
((u32*)cpuinfo.x86ID)[ 2 ] = regs[ 2 ];
if ( cmds >= 0x00000001 )
{
if ( iCpuId( 0x00000001, regs ) != -1 )
{
cpuinfo.x86StepID = regs[ 0 ] & 0xf;
cpuinfo.x86Model = (regs[ 0 ] >> 4) & 0xf;
cpuinfo.x86Family = (regs[ 0 ] >> 8) & 0xf;
cpuinfo.x86PType = (regs[ 0 ] >> 12) & 0x3;
x86_64_8BITBRANDID = regs[1] & 0xff;
cpuinfo.x86Flags = regs[ 3 ];
}
}
if ( iCpuId( 0x80000000, regs ) != -1 )
{
cmds = regs[ 0 ];
if ( cmds >= 0x80000001 )
{
if ( iCpuId( 0x80000001, regs ) != -1 )
{
x86_64_12BITBRANDID = regs[1] & 0xfff;
cpuinfo.x86EFlags = regs[ 3 ];
}
}
}
switch(cpuinfo.x86PType)
{
case 0:
strcpy( cpuinfo.x86Type, "Standard OEM");
break;
case 1:
strcpy( cpuinfo.x86Type, "Overdrive");
break;
case 2:
strcpy( cpuinfo.x86Type, "Dual");
break;
case 3:
strcpy( cpuinfo.x86Type, "Reserved");
break;
default:
strcpy( cpuinfo.x86Type, "Unknown");
break;
}
if ( cpuinfo.x86ID[ 0 ] == 'G' ){ cputype=0;}//trick lines but if you know a way better ;p
if ( cpuinfo.x86ID[ 0 ] == 'A' ){ cputype=1;}
if ( cputype == 0 ) //intel cpu
{
if( ( cpuinfo.x86Family >= 7 ) && ( cpuinfo.x86Family < 15 ) )
{
strcpy( cpuinfo.x86Fam, "Intel P6 family (Not PIV and Higher then PPro" );
}
else
{
switch( cpuinfo.x86Family )
{
// Start at 486 because if it's below 486 there is no cpuid instruction
case 4:
strcpy( cpuinfo.x86Fam, "Intel 486" );
break;
case 5:
switch( cpuinfo.x86Model )
{
case 4:
case 8: // 0.25 µm
strcpy( cpuinfo.x86Fam, "Intel Pentium (MMX)");
break;
default:
strcpy( cpuinfo.x86Fam, "Intel Pentium" );
}
break;
case 6:
switch( cpuinfo.x86Model )
{
case 0: // Pentium pro (P6 A-Step)
case 1: // Pentium pro
strcpy( cpuinfo.x86Fam, "Intel Pentium Pro" );
break;
case 2: // 66 MHz FSB
case 5: // Xeon/Celeron (0.25 µm)
case 6: // Internal L2 cache
strcpy( cpuinfo.x86Fam, "Intel Pentium II" );
break;
case 7: // Xeon external L2 cache
case 8: // Xeon/Celeron with 256 KB on-die L2 cache
case 10: // Xeon/Celeron with 1 or 2 MB on-die L2 cache
case 11: // Xeon/Celeron with Tualatin core, on-die cache
strcpy( cpuinfo.x86Fam, "Intel Pentium III" );
break;
case 15: // Core 2 Duo Allendale/Conroe
strcpy( cpuinfo.x86Fam, "Intel Core 2 Duo" );
break;
default:
strcpy( cpuinfo.x86Fam, "Intel Pentium Pro (Unknown)" );
}
break;
case 15:
switch( cpuinfo.x86Model )
{
case 0: // Willamette (A-Step)
case 1: // Willamette
strcpy( cpuinfo.x86Fam, "Willamette Intel Pentium IV" );
break;
case 2: // Northwood
strcpy( cpuinfo.x86Fam, "Northwood Intel Pentium IV" );
break;
default:
strcpy( cpuinfo.x86Fam, "Intel Pentium IV (Unknown)" );
break;
}
break;
default:
strcpy( cpuinfo.x86Fam, "Unknown Intel CPU" );
}
}
}
else if ( cputype == 1 ) //AMD cpu
{
if( cpuinfo.x86Family >= 7 )
{
if((x86_64_12BITBRANDID !=0) || (x86_64_8BITBRANDID !=0))
{
if(x86_64_8BITBRANDID == 0 )
{
switch((x86_64_12BITBRANDID >>6)& 0x3f)
{
case 4:
strcpy(cpuinfo.x86Fam,"AMD Athlon(tm) 64 Processor");
AMDspeed = 22 + (x86_64_12BITBRANDID & 0x1f);
//AMDspeedString = strtol(AMDspeed, (char**)NULL,10);
sprintf(AMDspeedString," %d",AMDspeed);
strcat(AMDspeedString,"00+");
strcat(cpuinfo.x86Fam,AMDspeedString);
break;
case 12:
strcpy(cpuinfo.x86Fam,"AMD Opteron(tm) Processor");
break;
case 5:
strcpy( cpuinfo.x86Fam, "AMD Athlon X2 Processor" );
AMDspeed = 22 + (x86_64_12BITBRANDID & 0x1f);
//AMDspeedString = strtol(AMDspeed, (char**)NULL,10);
sprintf(AMDspeedString," %d",AMDspeed);
strcat(AMDspeedString,"00+");
strcat(cpuinfo.x86Fam,AMDspeedString);
break;
case 44:
strcpy( cpuinfo.x86Fam, "AMD Opteron(tm) Dual Core Processor" );
break;
default:
strcpy(cpuinfo.x86Fam,"Unknown AMD 64 proccesor");
}
}
else //8bit brand id is non zero
{
strcpy(cpuinfo.x86Fam,"Unsupported yet AMD64 cpu");
}
}
else
{
strcpy( cpuinfo.x86Fam, "AMD K7+ Processor" );
}
}
else
{
switch ( cpuinfo.x86Family )
{
case 4:
switch( cpuinfo.x86Model )
{
case 14:
case 15: // Write-back enhanced
strcpy( cpuinfo.x86Fam, "AMD 5x86 Processor" );
break;
case 3: // DX2
case 7: // Write-back enhanced DX2
case 8: // DX4
case 9: // Write-back enhanced DX4
strcpy( cpuinfo.x86Fam, "AMD 486 Processor" );
break;
default:
strcpy( cpuinfo.x86Fam, "AMD Unknown Processor" );
}
break;
case 5:
switch( cpuinfo.x86Model)
{
case 0: // SSA 5 (75, 90 and 100 Mhz)
case 1: // 5k86 (PR 120 and 133 MHz)
case 2: // 5k86 (PR 166 MHz)
case 3: // K5 5k86 (PR 200 MHz)
strcpy( cpuinfo.x86Fam, "AMD K5 Processor" );
break;
case 6:
case 7: // (0.25 µm)
case 8: // K6-2
case 9: // K6-III
case 14: // K6-2+ / K6-III+
strcpy( cpuinfo.x86Fam, "AMD K6 Series Processor" );
break;
default:
strcpy( cpuinfo.x86Fam, "AMD Unknown Processor" );
}
break;
case 6:
strcpy( cpuinfo.x86Fam, "AMD Athlon XP Processor" );
break;
default:
strcpy( cpuinfo.x86Fam, "Unknown AMD CPU" );
}
}
}
//capabilities
cpucaps.hasFloatingPointUnit = ( cpuinfo.x86Flags >> 0 ) & 1;
cpucaps.hasVirtual8086ModeEnhancements = ( cpuinfo.x86Flags >> 1 ) & 1;
cpucaps.hasDebuggingExtensions = ( cpuinfo.x86Flags >> 2 ) & 1;
cpucaps.hasPageSizeExtensions = ( cpuinfo.x86Flags >> 3 ) & 1;
cpucaps.hasTimeStampCounter = ( cpuinfo.x86Flags >> 4 ) & 1;
cpucaps.hasModelSpecificRegisters = ( cpuinfo.x86Flags >> 5 ) & 1;
cpucaps.hasPhysicalAddressExtension = ( cpuinfo.x86Flags >> 6 ) & 1;
cpucaps.hasMachineCheckArchitecture = ( cpuinfo.x86Flags >> 7 ) & 1;
cpucaps.hasCOMPXCHG8BInstruction = ( cpuinfo.x86Flags >> 8 ) & 1;
cpucaps.hasAdvancedProgrammableInterruptController = ( cpuinfo.x86Flags >> 9 ) & 1;
cpucaps.hasSEPFastSystemCall = ( cpuinfo.x86Flags >> 11 ) & 1;
cpucaps.hasMemoryTypeRangeRegisters = ( cpuinfo.x86Flags >> 12 ) & 1;
cpucaps.hasPTEGlobalFlag = ( cpuinfo.x86Flags >> 13 ) & 1;
cpucaps.hasMachineCheckArchitecture = ( cpuinfo.x86Flags >> 14 ) & 1;
cpucaps.hasConditionalMoveAndCompareInstructions = ( cpuinfo.x86Flags >> 15 ) & 1;
cpucaps.hasFGPageAttributeTable = ( cpuinfo.x86Flags >> 16 ) & 1;
cpucaps.has36bitPageSizeExtension = ( cpuinfo.x86Flags >> 17 ) & 1;
cpucaps.hasProcessorSerialNumber = ( cpuinfo.x86Flags >> 18 ) & 1;
cpucaps.hasCFLUSHInstruction = ( cpuinfo.x86Flags >> 19 ) & 1;
cpucaps.hasDebugStore = ( cpuinfo.x86Flags >> 21 ) & 1;
cpucaps.hasACPIThermalMonitorAndClockControl = ( cpuinfo.x86Flags >> 22 ) & 1;
cpucaps.hasMultimediaExtensions = ( cpuinfo.x86Flags >> 23 ) & 1; //mmx
cpucaps.hasFastStreamingSIMDExtensionsSaveRestore = ( cpuinfo.x86Flags >> 24 ) & 1;
cpucaps.hasStreamingSIMDExtensions = ( cpuinfo.x86Flags >> 25 ) & 1; //sse
cpucaps.hasStreamingSIMD2Extensions = ( cpuinfo.x86Flags >> 26 ) & 1; //sse2
cpucaps.hasSelfSnoop = ( cpuinfo.x86Flags >> 27 ) & 1;
cpucaps.hasHyperThreading = ( cpuinfo.x86Flags >> 28 ) & 1;
cpucaps.hasThermalMonitor = ( cpuinfo.x86Flags >> 29 ) & 1;
cpucaps.hasIntel64BitArchitecture = ( cpuinfo.x86Flags >> 30 ) & 1;
//that is only for AMDs
cpucaps.hasMultimediaExtensionsExt = ( cpuinfo.x86EFlags >> 22 ) & 1; //mmx2
cpucaps.hasAMD64BitArchitecture = ( cpuinfo.x86EFlags >> 29 ) & 1; //64bit cpu
cpucaps.has3DNOWInstructionExtensionsExt = ( cpuinfo.x86EFlags >> 30 ) & 1; //3dnow+
cpucaps.has3DNOWInstructionExtensions = ( cpuinfo.x86EFlags >> 31 ) & 1; //3dnow
cpuinfo.cpuspeed = (u32 )(CPUSpeedHz( 1000 ) / 1000000);
}

View File

@ -0,0 +1,248 @@
// stop compiling if NORECBUILD build (only for Visual Studio)
#if !(defined(_MSC_VER) && defined(PCSX2_NORECBUILD))
#include <stdio.h>
#include <string.h>
#include "ix86-64.h"
/********************/
/* FPU instructions */
/********************/
/* fild m32 to fpu reg stack */
void FILD32( uptr from )
{
MEMADDR_OP(0, VAROP1(0xDB), false, 0, from, 0);
}
/* fistp m32 from fpu reg stack */
void FISTP32( uptr from )
{
MEMADDR_OP(0, VAROP1(0xDB), false, 3, from, 0);
}
/* fld m32 to fpu reg stack */
void FLD32( uptr from )
{
MEMADDR_OP(0, VAROP1(0xD9), false, 0, from, 0);
}
// fld st(i)
void FLD(int st) { write16(0xc0d9+(st<<8)); }
void FLD1() { write16(0xe8d9); }
void FLDL2E() { write16(0xead9); }
/* fst m32 from fpu reg stack */
void FST32( uptr to )
{
MEMADDR_OP(0, VAROP1(0xD9), false, 2, to, 0);
}
/* fstp m32 from fpu reg stack */
void FSTP32( uptr to )
{
MEMADDR_OP(0, VAROP1(0xD9), false, 3, to, 0);
}
// fstp st(i)
void FSTP(int st) { write16(0xd8dd+(st<<8)); }
/* fldcw fpu control word from m16 */
void FLDCW( uptr from )
{
MEMADDR_OP(0, VAROP1(0xD9), false, 5, from, 0);
}
/* fnstcw fpu control word to m16 */
void FNSTCW( uptr to )
{
MEMADDR_OP(0, VAROP1(0xD9), false, 7, to, 0);
}
void FNSTSWtoAX( void )
{
write16( 0xE0DF );
}
void FXAM()
{
write16(0xe5d9);
}
void FDECSTP() { write16(0xf6d9); }
void FRNDINT() { write16(0xfcd9); }
void FXCH(int st) { write16(0xc8d9+(st<<8)); }
void F2XM1() { write16(0xf0d9); }
void FSCALE() { write16(0xfdd9); }
/* fadd ST(src) to fpu reg stack ST(0) */
void FADD32Rto0( x86IntRegType src )
{
write8( 0xD8 );
write8( 0xC0 + src );
}
/* fadd ST(0) to fpu reg stack ST(src) */
void FADD320toR( x86IntRegType src )
{
write8( 0xDC );
write8( 0xC0 + src );
}
/* fsub ST(src) to fpu reg stack ST(0) */
void FSUB32Rto0( x86IntRegType src )
{
write8( 0xD8 );
write8( 0xE0 + src );
}
/* fsub ST(0) to fpu reg stack ST(src) */
void FSUB320toR( x86IntRegType src )
{
write8( 0xDC );
write8( 0xE8 + src );
}
/* fsubp -> substract ST(0) from ST(1), store in ST(1) and POP stack */
void FSUBP( void )
{
write8( 0xDE );
write8( 0xE9 );
}
/* fmul ST(src) to fpu reg stack ST(0) */
void FMUL32Rto0( x86IntRegType src )
{
write8( 0xD8 );
write8( 0xC8 + src );
}
/* fmul ST(0) to fpu reg stack ST(src) */
void FMUL320toR( x86IntRegType src )
{
write8( 0xDC );
write8( 0xC8 + src );
}
/* fdiv ST(src) to fpu reg stack ST(0) */
void FDIV32Rto0( x86IntRegType src )
{
write8( 0xD8 );
write8( 0xF0 + src );
}
/* fdiv ST(0) to fpu reg stack ST(src) */
void FDIV320toR( x86IntRegType src )
{
write8( 0xDC );
write8( 0xF8 + src );
}
void FDIV320toRP( x86IntRegType src )
{
write8( 0xDE );
write8( 0xF8 + src );
}
/* fadd m32 to fpu reg stack */
void FADD32( uptr from )
{
MEMADDR_OP(0, VAROP1(0xD8), false, 0, from, 0);
}
/* fsub m32 to fpu reg stack */
void FSUB32( uptr from )
{
MEMADDR_OP(0, VAROP1(0xD8), false, 4, from, 0);
}
/* fmul m32 to fpu reg stack */
void FMUL32( uptr from )
{
MEMADDR_OP(0, VAROP1(0xD8), false, 1, from, 0);
}
/* fdiv m32 to fpu reg stack */
void FDIV32( uptr from )
{
MEMADDR_OP(0, VAROP1(0xD8), false, 6, from, 0);
}
/* fabs fpu reg stack */
void FABS( void )
{
write16( 0xE1D9 );
}
/* fsqrt fpu reg stack */
void FSQRT( void )
{
write16( 0xFAD9 );
}
void FPATAN(void) { write16(0xf3d9); }
void FSIN(void) { write16(0xfed9); }
/* fchs fpu reg stack */
void FCHS( void )
{
write16( 0xE0D9 );
}
/* fcomi st, st(i) */
void FCOMI( x86IntRegType src )
{
write8( 0xDB );
write8( 0xF0 + src );
}
/* fcomip st, st(i) */
void FCOMIP( x86IntRegType src )
{
write8( 0xDF );
write8( 0xF0 + src );
}
/* fucomi st, st(i) */
void FUCOMI( x86IntRegType src )
{
write8( 0xDB );
write8( 0xE8 + src );
}
/* fucomip st, st(i) */
void FUCOMIP( x86IntRegType src )
{
write8( 0xDF );
write8( 0xE8 + src );
}
/* fcom m32 to fpu reg stack */
void FCOM32( uptr from )
{
MEMADDR_OP(0, VAROP1(0xD8), false, 2, from, 0);
}
/* fcomp m32 to fpu reg stack */
void FCOMP32( uptr from )
{
MEMADDR_OP(0, VAROP1(0xD8), false, 3, from, 0);
}
#define FCMOV32( low, high ) \
{ \
write8( low ); \
write8( high + from ); \
}
void FCMOVB32( x86IntRegType from ) { FCMOV32( 0xDA, 0xC0 ); }
void FCMOVE32( x86IntRegType from ) { FCMOV32( 0xDA, 0xC8 ); }
void FCMOVBE32( x86IntRegType from ) { FCMOV32( 0xDA, 0xD0 ); }
void FCMOVU32( x86IntRegType from ) { FCMOV32( 0xDA, 0xD8 ); }
void FCMOVNB32( x86IntRegType from ) { FCMOV32( 0xDB, 0xC0 ); }
void FCMOVNE32( x86IntRegType from ) { FCMOV32( 0xDB, 0xC8 ); }
void FCMOVNBE32( x86IntRegType from ) { FCMOV32( 0xDB, 0xD0 ); }
void FCMOVNU32( x86IntRegType from ) { FCMOV32( 0xDB, 0xD8 ); }
#endif

View File

@ -0,0 +1,646 @@
// stop compiling if NORECBUILD build (only for Visual Studio)
#if !(defined(_MSC_VER) && defined(PCSX2_NORECBUILD))
#include "ix86-64.h"
#include <assert.h>
/********************/
/* MMX instructions */
/********************/
// r64 = mm
/* movq m64 to r64 */
void MOVQMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x6F), true, to, from, 0);
}
/* movq r64 to m64 */
void MOVQRtoM( uptr to, x86MMXRegType from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x7F), true, from, to, 0);
}
/* pand r64 to r64 */
void PANDRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xDB0F );
ModRM( 3, to, from );
}
void PANDNRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xDF0F );
ModRM( 3, to, from );
}
/* por r64 to r64 */
void PORRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xEB0F );
ModRM( 3, to, from );
}
/* pxor r64 to r64 */
void PXORRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xEF0F );
ModRM( 3, to, from );
}
/* psllq r64 to r64 */
void PSLLQRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xF30F );
ModRM( 3, to, from );
}
/* psllq m64 to r64 */
void PSLLQMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xF3), true, to, from, 0);
}
/* psllq imm8 to r64 */
void PSLLQItoR( x86MMXRegType to, u8 from )
{
RexB(0, to);
write16( 0x730F );
ModRM( 3, 6, to);
write8( from );
}
/* psrlq r64 to r64 */
void PSRLQRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xD30F );
ModRM( 3, to, from );
}
/* psrlq m64 to r64 */
void PSRLQMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xD3), true, to, from, 0);
}
/* psrlq imm8 to r64 */
void PSRLQItoR( x86MMXRegType to, u8 from )
{
RexB(0, to);
write16( 0x730F );
ModRM( 3, 2, to);
write8( from );
}
/* paddusb r64 to r64 */
void PADDUSBRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xDC0F );
ModRM( 3, to, from );
}
/* paddusb m64 to r64 */
void PADDUSBMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xDC), true, to, from, 0);
}
/* paddusw r64 to r64 */
void PADDUSWRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xDD0F );
ModRM( 3, to, from );
}
/* paddusw m64 to r64 */
void PADDUSWMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xDD), true, to, from, 0);
}
/* paddb r64 to r64 */
void PADDBRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xFC0F );
ModRM( 3, to, from );
}
/* paddb m64 to r64 */
void PADDBMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xFC), true, to, from, 0);
}
/* paddw r64 to r64 */
void PADDWRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xFD0F );
ModRM( 3, to, from );
}
/* paddw m64 to r64 */
void PADDWMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xFD), true, to, from, 0);
}
/* paddd r64 to r64 */
void PADDDRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xFE0F );
ModRM( 3, to, from );
}
/* paddd m64 to r64 */
void PADDDMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xFE), true, to, from, 0);
}
/* emms */
void EMMS( void )
{
write16( 0x770F );
}
void PADDSBRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xEC0F );
ModRM( 3, to, from );
}
void PADDSWRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xED0F );
ModRM( 3, to, from );
}
// paddq m64 to r64 (sse2 only?)
void PADDQMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xD4), true, to, from, 0);
}
// paddq r64 to r64 (sse2 only?)
void PADDQRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xD40F );
ModRM( 3, to, from );
}
void PSUBSBRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xE80F );
ModRM( 3, to, from );
}
void PSUBSWRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xE90F );
ModRM( 3, to, from );
}
void PSUBBRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xF80F );
ModRM( 3, to, from );
}
void PSUBWRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xF90F );
ModRM( 3, to, from );
}
void PSUBDRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xFA0F );
ModRM( 3, to, from );
}
void PSUBDMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xFA), true, to, from, 0);
}
void PSUBUSBRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xD80F );
ModRM( 3, to, from );
}
void PSUBUSWRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xD90F );
ModRM( 3, to, from );
}
// psubq m64 to r64 (sse2 only?)
void PSUBQMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xFB), true, to, from, 0);
}
// psubq r64 to r64 (sse2 only?)
void PSUBQRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xFB0F );
ModRM( 3, to, from );
}
// pmuludq m64 to r64 (sse2 only?)
void PMULUDQMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xF4), true, to, from, 0);
}
// pmuludq r64 to r64 (sse2 only?)
void PMULUDQRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xF40F );
ModRM( 3, to, from );
}
void PCMPEQBRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0x740F );
ModRM( 3, to, from );
}
void PCMPEQWRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0x750F );
ModRM( 3, to, from );
}
void PCMPEQDRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0x760F );
ModRM( 3, to, from );
}
void PCMPEQDMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x76), true, to, from, 0);
}
void PCMPGTBRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0x640F );
ModRM( 3, to, from );
}
void PCMPGTWRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0x650F );
ModRM( 3, to, from );
}
void PCMPGTDRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0x660F );
ModRM( 3, to, from );
}
void PCMPGTDMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x66), true, to, from, 0);
}
void PSRLWItoR( x86MMXRegType to, u8 from )
{
RexB(0, to);
write16( 0x710F );
ModRM( 3, 2 , to );
write8( from );
}
void PSRLDItoR( x86MMXRegType to, u8 from )
{
RexB(0, to);
write16( 0x720F );
ModRM( 3, 2 , to );
write8( from );
}
void PSRLDRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xD20F );
ModRM( 3, to, from );
}
void PSLLWItoR( x86MMXRegType to, u8 from )
{
RexB(0, to);
write16( 0x710F );
ModRM( 3, 6 , to );
write8( from );
}
void PSLLDItoR( x86MMXRegType to, u8 from )
{
RexB(0, to);
write16( 0x720F );
ModRM( 3, 6 , to );
write8( from );
}
void PSLLDRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xF20F );
ModRM( 3, to, from );
}
void PSRAWItoR( x86MMXRegType to, u8 from )
{
RexB(0, to);
write16( 0x710F );
ModRM( 3, 4 , to );
write8( from );
}
void PSRADItoR( x86MMXRegType to, u8 from )
{
RexB(0, to);
write16( 0x720F );
ModRM( 3, 4 , to );
write8( from );
}
void PSRADRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0xE20F );
ModRM( 3, to, from );
}
/* por m64 to r64 */
void PORMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xEB), true, to, from, 0);
}
/* pxor m64 to r64 */
void PXORMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xEF), true, to, from, 0);
}
/* pand m64 to r64 */
void PANDMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xDB), true, to, from, 0);
}
void PANDNMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0xDF), true, to, from, 0);
}
void PUNPCKHDQRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0x6A0F );
ModRM( 3, to, from );
}
void PUNPCKHDQMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x6A), true, to, from, 0);
}
void PUNPCKLDQRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0x620F );
ModRM( 3, to, from );
}
void PUNPCKLDQMtoR( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x62), true, to, from, 0);
}
void MOVQ64ItoR( x86MMXRegType reg, u64 i )
{
RexR(0, reg);
write16(0x6F0F);
ModRM(0, reg, DISP32);
write32(2);
JMP8( 8 );
write64( i );
}
void MOVQRtoR( x86MMXRegType to, x86MMXRegType from )
{
RexRB(0, to, from);
write16( 0x6F0F );
ModRM( 3, to, from );
}
void MOVQRmtoROffset( x86MMXRegType to, x86IntRegType from, u32 offset )
{
RexRB(0, to, from);
write16( 0x6F0F );
if( offset < 128 ) {
ModRM( 1, to, from );
write8(offset);
}
else {
ModRM( 2, to, from );
write32(offset);
}
}
void MOVQRtoRmOffset( x86IntRegType to, x86MMXRegType from, u32 offset )
{
RexRB(0, from, to);
write16( 0x7F0F );
if( offset < 128 ) {
ModRM( 1, from , to );
write8(offset);
}
else {
ModRM( 2, from, to );
write32(offset);
}
}
/* movd m32 to r64 */
void MOVDMtoMMX( x86MMXRegType to, uptr from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x6E), true, to, from, 0);
}
/* movd r64 to m32 */
void MOVDMMXtoM( uptr to, x86MMXRegType from )
{
MEMADDR_OP(0, VAROP2(0x0F, 0x7E), true, from, to, 0);
}
void MOVD32RtoMMX( x86MMXRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x6E0F );
ModRM( 3, to, from );
}
void MOVD32RmtoMMX( x86MMXRegType to, x86IntRegType from )
{
RexRB(0, to, from);
write16( 0x6E0F );
ModRM( 0, to, from );
}
void MOVD32RmOffsettoMMX( x86MMXRegType to, x86IntRegType from, u32 offset )
{
RexRB(0, to, from);
write16( 0x6E0F );
if( offset < 128 ) {
ModRM( 1, to, from );
write8(offset);
}
else {
ModRM( 2, to, from );
write32(offset);
}
}
void MOVD32MMXtoR( x86IntRegType to, x86MMXRegType from )
{
RexRB(0, from, to);
write16( 0x7E0F );
ModRM( 3, from, to );
}
void MOVD32MMXtoRm( x86IntRegType to, x86MMXRegType from )
{
RexRB(0, from, to);
write16( 0x7E0F );
ModRM( 0, from, to );
if( to >= 4 ) {
// no idea why
assert( to == ESP );
write8(0x24);
}
}
void MOVD32MMXtoRmOffset( x86IntRegType to, x86MMXRegType from, u32 offset )
{
RexRB(0, from, to);
write16( 0x7E0F );
if( offset < 128 ) {
ModRM( 1, from, to );
write8(offset);
}
else {
ModRM( 2, from, to );
write32(offset);
}
}
///* movd r32 to r64 */
//void MOVD32MMXtoMMX( x86MMXRegType to, x86MMXRegType from )
//{
// write16( 0x6E0F );
// ModRM( 3, to, from );
//}
//
///* movq r64 to r32 */
//void MOVD64MMXtoMMX( x86MMXRegType to, x86MMXRegType from )
//{
// write16( 0x7E0F );
// ModRM( 3, from, to );
//}
// untested
void PACKSSWBMMXtoMMX(x86MMXRegType to, x86MMXRegType from)
{
RexRB(0, to, from);
write16( 0x630F );
ModRM( 3, to, from );
}
void PACKSSDWMMXtoMMX(x86MMXRegType to, x86MMXRegType from)
{
RexRB(0, to, from);
write16( 0x6B0F );
ModRM( 3, to, from );
}
void PMOVMSKBMMXtoR(x86IntRegType to, x86MMXRegType from)
{
RexRB(0, to, from);
write16( 0xD70F );
ModRM( 3, to, from );
}
void PINSRWRtoMMX( x86MMXRegType to, x86SSERegType from, u8 imm8 )
{
RexRB(0, to, from);
write16( 0xc40f );
ModRM( 3, to, from );
write8( imm8 );
}
void PSHUFWRtoR(x86MMXRegType to, x86MMXRegType from, u8 imm8)
{
RexRB(0, to, from);
write16(0x700f);
ModRM( 3, to, from );
write8(imm8);
}
void PSHUFWMtoR(x86MMXRegType to, uptr from, u8 imm8)
{
MEMADDR_OP(0, VAROP2(0x0F, 0x70), true, to, from, 1 /* XXX was 0? */);
write8(imm8);
}
void MASKMOVQRtoR(x86MMXRegType to, x86MMXRegType from)
{
RexRB(0, to, from);
write16(0xf70f);
ModRM( 3, to, from );
}
#endif

File diff suppressed because it is too large Load Diff

565
libpcsxcore/mdec.c Normal file
View File

@ -0,0 +1,565 @@
/***************************************************************************
* Copyright (C) 2010 Gabriele Gorla *
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#include "mdec.h"
#define DSIZE 8
#define DSIZE2 (DSIZE * DSIZE)
#define SCALE(x, n) ((x) >> (n))
#define SCALER(x, n) (((x) + ((1 << (n)) >> 1)) >> (n))
#define AAN_CONST_BITS 12
#define AAN_PRESCALE_BITS 16
#define AAN_CONST_SIZE 24
#define AAN_CONST_SCALE (AAN_CONST_SIZE - AAN_CONST_BITS)
#define AAN_PRESCALE_SIZE 20
#define AAN_PRESCALE_SCALE (AAN_PRESCALE_SIZE-AAN_PRESCALE_BITS)
#define AAN_EXTRA 12
#define FIX_1_082392200 SCALER(18159528, AAN_CONST_SCALE) // B6
#define FIX_1_414213562 SCALER(23726566, AAN_CONST_SCALE) // A4
#define FIX_1_847759065 SCALER(31000253, AAN_CONST_SCALE) // A2
#define FIX_2_613125930 SCALER(43840978, AAN_CONST_SCALE) // B2
#define MULS(var, const) (SCALE((var) * (const), AAN_CONST_BITS))
#define RLE_RUN(a) ((a) >> 10)
#define RLE_VAL(a) (((int)(a) << (sizeof(int) * 8 - 10)) >> (sizeof(int) * 8 - 10))
#if 0
static void printmatrixu8(u8 *m) {
int i;
for(i = 0; i < DSIZE2; i++) {
printf("%3d ",m[i]);
if((i+1) % 8 == 0) printf("\n");
}
}
#endif
static inline void fillcol(int *blk, int val) {
blk[0 * DSIZE] = blk[1 * DSIZE] = blk[2 * DSIZE] = blk[3 * DSIZE]
= blk[4 * DSIZE] = blk[5 * DSIZE] = blk[6 * DSIZE] = blk[7 * DSIZE] = val;
}
static inline void fillrow(int *blk, int val) {
blk[0] = blk[1] = blk[2] = blk[3]
= blk[4] = blk[5] = blk[6] = blk[7] = val;
}
void idct(int *block,int used_col) {
int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
int z5, z10, z11, z12, z13;
int *ptr;
int i;
// the block has only the DC coefficient
if (used_col == -1) {
int v = block[0];
for (i = 0; i < DSIZE2; i++) block[i] = v;
return;
}
// last_col keeps track of the highest column with non zero coefficients
ptr = block;
for (i = 0; i < DSIZE; i++, ptr++) {
if ((used_col & (1 << i)) == 0) {
// the column is empty or has only the DC coefficient
if (ptr[DSIZE * 0]) {
fillcol(ptr, ptr[0]);
used_col |= (1 << i);
}
continue;
}
// further optimization could be made by keeping track of
// last_row in rl2blk
z10 = ptr[DSIZE * 0] + ptr[DSIZE * 4]; // s04
z11 = ptr[DSIZE * 0] - ptr[DSIZE * 4]; // d04
z13 = ptr[DSIZE * 2] + ptr[DSIZE * 6]; // s26
z12 = MULS(ptr[DSIZE * 2] - ptr[DSIZE * 6], FIX_1_414213562) - z13;
//^^^^ d26=d26*2*A4-s26
tmp0 = z10 + z13; // os07 = s04 + s26
tmp3 = z10 - z13; // os34 = s04 - s26
tmp1 = z11 + z12; // os16 = d04 + d26
tmp2 = z11 - z12; // os25 = d04 - d26
z13 = ptr[DSIZE * 3] + ptr[DSIZE * 5]; //s53
z10 = ptr[DSIZE * 3] - ptr[DSIZE * 5]; //-d53
z11 = ptr[DSIZE * 1] + ptr[DSIZE * 7]; //s17
z12 = ptr[DSIZE * 1] - ptr[DSIZE * 7]; //d17
tmp7 = z11 + z13; // od07 = s17 + s53
z5 = (z12 - z10) * (FIX_1_847759065);
tmp6 = SCALE(z10*(FIX_2_613125930) + z5, AAN_CONST_BITS) - tmp7;
tmp5 = MULS(z11 - z13, FIX_1_414213562) - tmp6;
tmp4 = SCALE(z12*(FIX_1_082392200) - z5, AAN_CONST_BITS) + tmp5;
// path #1
//z5 = (z12 - z10)* FIX_1_847759065;
// tmp0 = (d17 + d53) * 2*A2
//tmp6 = DESCALE(z10*FIX_2_613125930 + z5, CONST_BITS) - tmp7;
// od16 = (d53*-2*B2 + tmp0) - od07
//tmp4 = DESCALE(z12*FIX_1_082392200 - z5, CONST_BITS) + tmp5;
// od34 = (d17*2*B6 - tmp0) + od25
// path #2
// od34 = d17*2*(B6-A2) - d53*2*A2
// od16 = d53*2*(A2-B2) + d17*2*A2
// end
// tmp5 = MULS(z11 - z13, FIX_1_414213562) - tmp6;
// od25 = (s17 - s53)*2*A4 - od16
ptr[DSIZE * 0] = (tmp0 + tmp7); // os07 + od07
ptr[DSIZE * 7] = (tmp0 - tmp7); // os07 - od07
ptr[DSIZE * 1] = (tmp1 + tmp6); // os16 + od16
ptr[DSIZE * 6] = (tmp1 - tmp6); // os16 - od16
ptr[DSIZE * 2] = (tmp2 + tmp5); // os25 + od25
ptr[DSIZE * 5] = (tmp2 - tmp5); // os25 - od25
ptr[DSIZE * 4] = (tmp3 + tmp4); // os34 + od34
ptr[DSIZE * 3] = (tmp3 - tmp4); // os34 - od34
}
ptr = block;
if (used_col == 1) {
for (i = 0; i < DSIZE; i++)
fillrow(block + DSIZE * i, block[DSIZE * i]);
} else {
for (i = 0; i < DSIZE; i++, ptr += DSIZE) {
z10 = ptr[0] + ptr[4];
z11 = ptr[0] - ptr[4];
z13 = ptr[2] + ptr[6];
z12 = MULS(ptr[2] - ptr[6], FIX_1_414213562) - z13;
tmp0 = z10 + z13;
tmp3 = z10 - z13;
tmp1 = z11 + z12;
tmp2 = z11 - z12;
z13 = ptr[3] + ptr[5];
z10 = ptr[3] - ptr[5];
z11 = ptr[1] + ptr[7];
z12 = ptr[1] - ptr[7];
tmp7 = z11 + z13;
z5 = (z12 - z10) * FIX_1_847759065;
tmp6 = SCALE(z10 * FIX_2_613125930 + z5, AAN_CONST_BITS) - tmp7;
tmp5 = MULS(z11 - z13, FIX_1_414213562) - tmp6;
tmp4 = SCALE(z12 * FIX_1_082392200 - z5, AAN_CONST_BITS) + tmp5;
ptr[0] = tmp0 + tmp7;
ptr[7] = tmp0 - tmp7;
ptr[1] = tmp1 + tmp6;
ptr[6] = tmp1 - tmp6;
ptr[2] = tmp2 + tmp5;
ptr[5] = tmp2 - tmp5;
ptr[4] = tmp3 + tmp4;
ptr[3] = tmp3 - tmp4;
}
}
}
// mdec0: command register
#define MDEC0_STP 0x02000000
#define MDEC0_RGB24 0x08000000
#define MDEC0_SIZE_MASK 0xFFFF
// mdec1: status register
#define MDEC1_BUSY 0x20000000
#define MDEC1_DREQ 0x18000000
#define MDEC1_FIFO 0xc0000000
#define MDEC1_RGB24 0x02000000
#define MDEC1_STP 0x00800000
#define MDEC1_RESET 0x80000000
struct {
u32 reg0;
u32 reg1;
unsigned short *rl;
int rlsize;
} mdec;
static int iq_y[DSIZE2], iq_uv[DSIZE2];
static int zscan[DSIZE2] = {
0 , 1 , 8 , 16, 9 , 2 , 3 , 10,
17, 24, 32, 25, 18, 11, 4 , 5 ,
12, 19, 26, 33, 40, 48, 41, 34,
27, 20, 13, 6 , 7 , 14, 21, 28,
35, 42, 49, 56, 57, 50, 43, 36,
29, 22, 15, 23, 30, 37, 44, 51,
58, 59, 52, 45, 38, 31, 39, 46,
53, 60, 61, 54, 47, 55, 62, 63
};
static int aanscales[DSIZE2] = {
1048576, 1454417, 1370031, 1232995, 1048576, 823861, 567485, 289301,
1454417, 2017334, 1900287, 1710213, 1454417, 1142728, 787125, 401273,
1370031, 1900287, 1790031, 1610986, 1370031, 1076426, 741455, 377991,
1232995, 1710213, 1610986, 1449849, 1232995, 968758, 667292, 340183,
1048576, 1454417, 1370031, 1232995, 1048576, 823861, 567485, 289301,
823861, 1142728, 1076426, 968758, 823861, 647303, 445870, 227303,
567485, 787125, 741455, 667292, 567485, 445870, 307121, 156569,
289301, 401273, 377991, 340183, 289301, 227303, 156569, 79818
};
static void iqtab_init(int *iqtab, unsigned char *iq_y) {
int i;
for (i = 0; i < DSIZE2; i++) {
iqtab[i] = (iq_y[i] * SCALER(aanscales[zscan[i]], AAN_PRESCALE_SCALE));
}
}
#define MDEC_END_OF_DATA 0xfe00
unsigned short *rl2blk(int *blk, unsigned short *mdec_rl) {
int i, k, q_scale, rl, used_col;
int *iqtab;
memset(blk, 0, 6 * DSIZE2 * sizeof(int));
iqtab = iq_uv;
for (i = 0; i < 6; i++) {
// decode blocks (Cr,Cb,Y1,Y2,Y3,Y4)
if (i == 2) iqtab = iq_y;
rl = SWAP16(*mdec_rl); mdec_rl++;
q_scale = RLE_RUN(rl);
blk[0] = SCALER(iqtab[0] * RLE_VAL(rl), AAN_EXTRA - 3);
for (k = 0, used_col = 0;;) {
rl = SWAP16(*mdec_rl); mdec_rl++;
if (rl == MDEC_END_OF_DATA) break;
k += RLE_RUN(rl) + 1; // skip zero-coefficients
if (k > 63) {
// printf("run lenght exceeded 64 enties\n");
break;
}
// zigzag transformation
blk[zscan[k]] = SCALER(RLE_VAL(rl) * iqtab[k] * q_scale, AAN_EXTRA);
// keep track of used columns to speed up the idtc
used_col |= (zscan[k] > 7) ? 1 << (zscan[k] & 7) : 0;
}
if (k == 0) used_col = -1;
// used_col is -1 for blocks with only the DC coefficient
// any other value is a bitmask of the columns that have
// at least one non zero cofficient in the rows 1-7
// single coefficients in row 0 are treted specially
// in the idtc function
idct(blk, used_col);
blk += DSIZE2;
}
return mdec_rl;
}
// full scale (JPEG)
// Y/Cb/Cr[0...255] -> R/G/B[0...255]
// R = 1.000 * (Y) + 1.400 * (Cr - 128)
// G = 1.000 * (Y) - 0.343 * (Cb - 128) - 0.711 (Cr - 128)
// B = 1.000 * (Y) + 1.765 * (Cb - 128)
#define MULR(a) ((1434 * (a)))
#define MULB(a) ((1807 * (a)))
#define MULG2(a, b) ((-351 * (a) - 728 * (b)))
#define MULY(a) ((a) << 10)
#define MAKERGB15(r, g, b, a) (SWAP16(a | ((b) << 10) | ((g) << 5) | (r)))
#define SCALE8(c) SCALER(c, 20)
#define SCALE5(c) SCALER(c, 23)
#define CLAMP5(c) ( ((c) < -16) ? 0 : (((c) > (31 - 16)) ? 31 : ((c) + 16)) )
#define CLAMP8(c) ( ((c) < -128) ? 0 : (((c) > (255 - 128)) ? 255 : ((c) + 128)) )
#define CLAMP_SCALE8(a) (CLAMP8(SCALE8(a)))
#define CLAMP_SCALE5(a) (CLAMP5(SCALE5(a)))
static inline void putlinebw15(unsigned short *image, int *Yblk) {
int i;
int A = (mdec.reg0 & MDEC0_STP) ? 0x8000 : 0;
for (i = 0; i < 8; i++, Yblk++) {
int Y = *Yblk;
// missing rounding
image[i] = SWAP16((CLAMP5(Y >> 3) * 0x421) | A);
}
}
static void putquadrgb15(unsigned short *image, int *Yblk, int Cr, int Cb) {
int Y, R, G, B;
int A = (mdec.reg0 & MDEC0_STP) ? 0x8000 : 0;
R = MULR(Cr);
G = MULG2(Cb, Cr);
B = MULB(Cb);
// added transparency
Y = MULY(Yblk[0]);
image[0] = MAKERGB15(CLAMP_SCALE5(Y + R), CLAMP_SCALE5(Y + G), CLAMP_SCALE5(Y + B), A);
Y = MULY(Yblk[1]);
image[1] = MAKERGB15(CLAMP_SCALE5(Y + R), CLAMP_SCALE5(Y + G), CLAMP_SCALE5(Y + B), A);
Y = MULY(Yblk[8]);
image[16] = MAKERGB15(CLAMP_SCALE5(Y + R), CLAMP_SCALE5(Y + G), CLAMP_SCALE5(Y + B), A);
Y = MULY(Yblk[9]);
image[17] = MAKERGB15(CLAMP_SCALE5(Y + R), CLAMP_SCALE5(Y + G), CLAMP_SCALE5(Y + B), A);
}
static void yuv2rgb15(int *blk, unsigned short *image) {
int x, y;
int *Yblk = blk + DSIZE2 * 2;
int *Crblk = blk;
int *Cbblk = blk + DSIZE2;
if (!Config.Mdec) {
for (y = 0; y < 16; y += 2, Crblk += 4, Cbblk += 4, Yblk += 8, image += 24) {
if (y == 8) Yblk += DSIZE2;
for (x = 0; x < 4; x++, image += 2, Crblk++, Cbblk++, Yblk += 2) {
putquadrgb15(image, Yblk, *Crblk, *Cbblk);
putquadrgb15(image + 8, Yblk + DSIZE2, *(Crblk + 4), *(Cbblk + 4));
}
}
} else {
for (y = 0; y < 16; y++, Yblk += 8, image += 16) {
if (y == 8) Yblk += DSIZE2;
putlinebw15(image, Yblk);
putlinebw15(image + 8, Yblk + DSIZE2);
}
}
}
static inline void putlinebw24(unsigned char *image, int *Yblk) {
int i;
unsigned char Y;
for (i = 0; i < 8 * 3; i += 3, Yblk++) {
Y = CLAMP8(*Yblk);
image[i + 0] = Y;
image[i + 1] = Y;
image[i + 2] = Y;
}
}
static void putquadrgb24(unsigned char *image, int *Yblk, int Cr, int Cb) {
int Y, R, G, B;
R = MULR(Cr);
G = MULG2(Cb,Cr);
B = MULB(Cb);
Y = MULY(Yblk[0]);
image[0 * 3 + 0] = CLAMP_SCALE8(Y + R);
image[0 * 3 + 1] = CLAMP_SCALE8(Y + G);
image[0 * 3 + 2] = CLAMP_SCALE8(Y + B);
Y = MULY(Yblk[1]);
image[1 * 3 + 0] = CLAMP_SCALE8(Y + R);
image[1 * 3 + 1] = CLAMP_SCALE8(Y + G);
image[1 * 3 + 2] = CLAMP_SCALE8(Y + B);
Y = MULY(Yblk[8]);
image[16 * 3 + 0] = CLAMP_SCALE8(Y + R);
image[16 * 3 + 1] = CLAMP_SCALE8(Y + G);
image[16 * 3 + 2] = CLAMP_SCALE8(Y + B);
Y = MULY(Yblk[9]);
image[17 * 3 + 0] = CLAMP_SCALE8(Y + R);
image[17 * 3 + 1] = CLAMP_SCALE8(Y + G);
image[17 * 3 + 2] = CLAMP_SCALE8(Y + B);
}
static void yuv2rgb24(int *blk, unsigned char *image) {
int x, y;
int *Yblk = blk + DSIZE2 * 2;
int *Crblk = blk;
int *Cbblk = blk + DSIZE2;
if (!Config.Mdec) {
for (y = 0; y < 16; y += 2, Crblk += 4, Cbblk += 4, Yblk += 8, image += 24 * 3) {
if (y == 8) Yblk += DSIZE2;
for (x = 0; x < 4; x++, image += 6, Crblk++, Cbblk++, Yblk += 2) {
putquadrgb24(image, Yblk, *Crblk, *Cbblk);
putquadrgb24(image + 8 * 3, Yblk + DSIZE2, *(Crblk + 4), *(Cbblk + 4));
}
}
} else {
for (y = 0; y < 16; y++, Yblk += 8, image += 16 * 3) {
if (y == 8) Yblk += DSIZE2;
putlinebw24(image, Yblk);
putlinebw24(image + 8 * 3, Yblk + DSIZE2);
}
}
}
void mdecInit(void) {
mdec.rl = (u16 *)&psxM[0x100000];
mdec.reg0 = 0;
mdec.reg1 = 0;
}
// command register
void mdecWrite0(u32 data) {
#ifdef CDR_LOG
CDR_LOG("mdec0 write %08x\n", data);
#endif
mdec.reg0 = data;
}
u32 mdecRead0(void) {
#ifdef CDR_LOG
CDR_LOG("mdec0 read %08x\n", mdec.reg0);
#endif
// mame is returning 0
return mdec.reg0;
}
// status register
void mdecWrite1(u32 data) {
#ifdef CDR_LOG
CDR_LOG("mdec1 write %08x\n", data);
#endif
if (data & MDEC1_RESET) { // mdec reset
mdec.reg0 = 0;
mdec.reg1 = 0;
}
}
u32 mdecRead1(void) {
u32 v = mdec.reg1;
v |= (mdec.reg0 & MDEC0_STP) ? MDEC1_STP : 0;
v |= (mdec.reg0 & MDEC0_RGB24) ? MDEC1_RGB24 : 0;
#ifdef CDR_LOG
CDR_LOG("mdec1 read %08x\n", v);
#endif
return v;
}
void psxDma0(u32 adr, u32 bcr, u32 chcr) {
int cmd = mdec.reg0;
int size;
#ifdef CDR_LOG
CDR_LOG("DMA0 %08x %08x %08x\n", adr, bcr, chcr);
#endif
if (chcr != 0x01000201) {
// printf("chcr != 0x01000201\n");
return;
}
size = (bcr >> 16) * (bcr & 0xffff);
switch (cmd >> 28) {
case 0x3: // decode
mdec.rl = (u16 *)PSXM(adr);
mdec.rlsize = mdec.reg0 & MDEC0_SIZE_MASK;
break;
case 0x4: // quantization table upload
{
u8 *p = (u8 *)PSXM(adr);
// printf("uploading new quantization table\n");
// printmatrixu8(p);
// printmatrixu8(p + 64);
iqtab_init(iq_y, p);
iqtab_init(iq_uv, p + 64);
}
break;
case 0x6: // cosine table
// printf("mdec cosine table\n");
break;
default:
// printf("mdec unknown command\n");
break;
}
HW_DMA0_CHCR &= SWAP32(~0x01000000);
DMA_INTERRUPT(0);
}
void psxDma1(u32 adr, u32 bcr, u32 chcr) {
int blk[DSIZE2 * 6];
unsigned short *image;
int size;
#ifdef CDR_LOG
CDR_LOG("DMA1 %08x %08x %08x (cmd = %08x)\n", adr, bcr, chcr, mdec.reg0);
#endif
if (chcr != 0x01000200) return;
size = (bcr >> 16) * (bcr & 0xffff);
image = (u16 *)PSXM(adr);
if (mdec.reg0 & MDEC0_RGB24) { // 15-b decoding
// MDECOUTDMA_INT(((size * (1000000 / 9000)) / 4) /** 4*/);
MDECOUTDMA_INT(size / 4);
size = size / ((16 * 16) / 2);
for (; size > 0; size--, image += (16 * 16)) {
mdec.rl = rl2blk(blk, mdec.rl);
yuv2rgb15(blk, image);
}
} else { // 24-b decoding
// MDECOUTDMA_INT(((size * (1000000 / 9000)) / 4) /** 4*/);
MDECOUTDMA_INT(size / 4);
size = size / ((24 * 16) / 2);
for (; size > 0; size--, image += (24 * 16)) {
mdec.rl = rl2blk(blk, mdec.rl);
yuv2rgb24(blk, (u8 *)image);
}
}
mdec.reg1 |= MDEC1_BUSY;
}
void mdec1Interrupt() {
#ifdef CDR_LOG
CDR_LOG("mdec1Interrupt\n");
#endif
if (HW_DMA1_CHCR & SWAP32(0x01000000)) {
// Set a fixed value totaly arbitrarie another sound value is
// PSXCLK / 60 or PSXCLK / 50 since the bug happened at end of frame.
// PSXCLK / 1000 seems good for FF9. (for FF9 need < ~28000)
// CAUTION: commented interrupt-handling may lead to problems, keep an eye ;-)
MDECOUTDMA_INT(PSXCLK / 1000 * BIAS);
// psxRegs.interrupt |= 0x02000000;
// psxRegs.intCycle[5 + 24 + 1] *= 8;
// psxRegs.intCycle[5 + 24] = psxRegs.cycle;
HW_DMA1_CHCR &= SWAP32(~0x01000000);
DMA_INTERRUPT(1);
} else {
mdec.reg1 &= ~MDEC1_BUSY;
}
}
int mdecFreeze(gzFile f, int Mode) {
gzfreeze(&mdec, sizeof(mdec));
gzfreeze(iq_y, sizeof(iq_y));
gzfreeze(iq_uv, sizeof(iq_uv));
return 0;
}

45
libpcsxcore/mdec.h Normal file
View File

@ -0,0 +1,45 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __MDEC_H__
#define __MDEC_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "psxcommon.h"
#include "r3000a.h"
#include "psxhw.h"
#include "psxdma.h"
void mdecInit();
void mdecWrite0(u32 data);
void mdecWrite1(u32 data);
u32 mdecRead0();
u32 mdecRead1();
void psxDma0(u32 madr, u32 bcr, u32 chcr);
void psxDma1(u32 madr, u32 bcr, u32 chcr);
void mdec1Interrupt();
int mdecFreeze(gzFile f, int Mode);
#ifdef __cplusplus
}
#endif
#endif

706
libpcsxcore/misc.c Normal file
View File

@ -0,0 +1,706 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
/*
* Miscellaneous functions, including savestates and CD-ROM loading.
*/
#include "misc.h"
#include "cdrom.h"
#include "mdec.h"
#include "ppf.h"
char CdromId[10] = "";
char CdromLabel[33] = "";
// PSX Executable types
#define PSX_EXE 1
#define CPE_EXE 2
#define COFF_EXE 3
#define INVALID_EXE 4
#define ISODCL(from, to) (to - from + 1)
struct iso_directory_record {
char length [ISODCL (1, 1)]; /* 711 */
char ext_attr_length [ISODCL (2, 2)]; /* 711 */
char extent [ISODCL (3, 10)]; /* 733 */
char size [ISODCL (11, 18)]; /* 733 */
char date [ISODCL (19, 25)]; /* 7 by 711 */
char flags [ISODCL (26, 26)];
char file_unit_size [ISODCL (27, 27)]; /* 711 */
char interleave [ISODCL (28, 28)]; /* 711 */
char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
unsigned char name_len [ISODCL (33, 33)]; /* 711 */
char name [1];
};
void mmssdd( char *b, char *p )
{
int m, s, d;
#if defined(__BIGENDIAN__)
int block = (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | (b[3] << 24);
#else
int block = *((int*)b);
#endif
block += 150;
m = block / 4500; // minutes
block = block - m * 4500; // minutes rest
s = block / 75; // seconds
d = block - s * 75; // seconds rest
m = ((m / 10) << 4) | m % 10;
s = ((s / 10) << 4) | s % 10;
d = ((d / 10) << 4) | d % 10;
p[0] = m;
p[1] = s;
p[2] = d;
}
#define incTime() \
time[0] = btoi(time[0]); time[1] = btoi(time[1]); time[2] = btoi(time[2]); \
time[2]++; \
if(time[2] == 75) { \
time[2] = 0; \
time[1]++; \
if (time[1] == 60) { \
time[1] = 0; \
time[0]++; \
} \
} \
time[0] = itob(time[0]); time[1] = itob(time[1]); time[2] = itob(time[2]);
#define READTRACK() \
if (CDR_readTrack(time) == -1) return -1; \
buf = CDR_getBuffer(); \
if (buf == NULL) return -1; else CheckPPFCache(buf, time[0], time[1], time[2]);
#define READDIR(_dir) \
READTRACK(); \
memcpy(_dir, buf + 12, 2048); \
\
incTime(); \
READTRACK(); \
memcpy(_dir + 2048, buf + 12, 2048);
int GetCdromFile(u8 *mdir, u8 *time, s8 *filename) {
struct iso_directory_record *dir;
char ddir[4096];
u8 *buf;
int i;
// only try to scan if a filename is given
if (!strlen(filename)) return -1;
i = 0;
while (i < 4096) {
dir = (struct iso_directory_record*) &mdir[i];
if (dir->length[0] == 0) {
return -1;
}
i += dir->length[0];
if (dir->flags[0] & 0x2) { // it's a dir
if (!strnicmp((char *)&dir->name[0], filename, dir->name_len[0])) {
if (filename[dir->name_len[0]] != '\\') continue;
filename += dir->name_len[0] + 1;
mmssdd(dir->extent, (char *)time);
READDIR(ddir);
i = 0;
mdir = ddir;
}
} else {
if (!strnicmp((char *)&dir->name[0], filename, strlen(filename))) {
mmssdd(dir->extent, (char *)time);
break;
}
}
}
return 0;
}
int LoadCdrom() {
EXE_HEADER tmpHead;
struct iso_directory_record *dir;
u8 time[4], *buf;
u8 mdir[4096];
s8 exename[256];
if (!Config.HLE) {
psxRegs.pc = psxRegs.GPR.n.ra;
return 0;
}
time[0] = itob(0); time[1] = itob(2); time[2] = itob(0x10);
READTRACK();
// skip head and sub, and go to the root directory record
dir = (struct iso_directory_record*) &buf[12+156];
mmssdd(dir->extent, (char*)time);
READDIR(mdir);
// Load SYSTEM.CNF and scan for the main executable
if (GetCdromFile(mdir, time, "SYSTEM.CNF;1") == -1) {
// if SYSTEM.CNF is missing, start an existing PSX.EXE
if (GetCdromFile(mdir, time, "PSX.EXE;1") == -1) return -1;
READTRACK();
}
else {
// read the SYSTEM.CNF
READTRACK();
sscanf((char *)buf + 12, "BOOT = cdrom:\\%256s", exename);
if (GetCdromFile(mdir, time, exename) == -1) {
sscanf((char *)buf + 12, "BOOT = cdrom:%256s", exename);
if (GetCdromFile(mdir, time, exename) == -1) {
char *ptr = strstr(buf + 12, "cdrom:");
if (ptr != NULL) {
ptr += 6;
while (*ptr == '\\' || *ptr == '/') ptr++;
strncpy(exename, ptr, 255);
exename[255] = '\0';
ptr = exename;
while (*ptr != '\0' && *ptr != '\r' && *ptr != '\n') ptr++;
*ptr = '\0';
if (GetCdromFile(mdir, time, exename) == -1)
return -1;
} else
return -1;
}
}
// Read the EXE-Header
READTRACK();
}
memcpy(&tmpHead, buf + 12, sizeof(EXE_HEADER));
psxRegs.pc = SWAP32(tmpHead.pc0);
psxRegs.GPR.n.gp = SWAP32(tmpHead.gp0);
psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr);
if (psxRegs.GPR.n.sp == 0) psxRegs.GPR.n.sp = 0x801fff00;
tmpHead.t_size = SWAP32(tmpHead.t_size);
tmpHead.t_addr = SWAP32(tmpHead.t_addr);
// Read the rest of the main executable
while (tmpHead.t_size) {
void *ptr = (void *)PSXM(tmpHead.t_addr);
incTime();
READTRACK();
if (ptr != NULL) memcpy(ptr, buf+12, 2048);
tmpHead.t_size -= 2048;
tmpHead.t_addr += 2048;
}
return 0;
}
int LoadCdromFile(const char *filename, EXE_HEADER *head) {
struct iso_directory_record *dir;
u8 time[4],*buf;
u8 mdir[4096], exename[256];
u32 size, addr;
sscanf(filename, "cdrom:\\%256s", exename);
time[0] = itob(0); time[1] = itob(2); time[2] = itob(0x10);
READTRACK();
// skip head and sub, and go to the root directory record
dir = (struct iso_directory_record *)&buf[12 + 156];
mmssdd(dir->extent, (char*)time);
READDIR(mdir);
if (GetCdromFile(mdir, time, exename) == -1) return -1;
READTRACK();
memcpy(head, buf + 12, sizeof(EXE_HEADER));
size = head->t_size;
addr = head->t_addr;
while (size) {
incTime();
READTRACK();
memcpy((void *)PSXM(addr), buf + 12, 2048);
size -= 2048;
addr += 2048;
}
return 0;
}
int CheckCdrom() {
struct iso_directory_record *dir;
unsigned char time[4], *buf;
unsigned char mdir[4096];
char exename[256];
int i, c;
FreePPFCache();
time[0] = itob(0);
time[1] = itob(2);
time[2] = itob(0x10);
READTRACK();
CdromLabel[0] = '\0';
CdromId[0] = '\0';
strncpy(CdromLabel, buf + 52, 32);
// skip head and sub, and go to the root directory record
dir = (struct iso_directory_record *)&buf[12 + 156];
mmssdd(dir->extent, (char *)time);
READDIR(mdir);
if (GetCdromFile(mdir, time, "SYSTEM.CNF;1") != -1) {
READTRACK();
sscanf((char *)buf + 12, "BOOT = cdrom:\\%256s", exename);
if (GetCdromFile(mdir, time, exename) == -1) {
sscanf((char *)buf + 12, "BOOT = cdrom:%256s", exename);
if (GetCdromFile(mdir, time, exename) == -1) {
char *ptr = strstr(buf + 12, "cdrom:"); // possibly the executable is in some subdir
if (ptr != NULL) {
ptr += 6;
while (*ptr == '\\' || *ptr == '/') ptr++;
strncpy(exename, ptr, 255);
exename[255] = '\0';
ptr = exename;
while (*ptr != '\0' && *ptr != '\r' && *ptr != '\n') ptr++;
*ptr = '\0';
if (GetCdromFile(mdir, time, exename) == -1)
return -1; // main executable not found
} else
return -1;
}
}
} else if (GetCdromFile(mdir, time, "PSX.EXE;1") != -1) {
strcpy(exename, "PSX.EXE;1");
strcpy(CdromId, "SLUS99999");
} else
return -1; // SYSTEM.CNF and PSX.EXE not found
if (CdromId[0] == '\0') {
i = strlen(exename);
if (i >= 2) {
if (exename[i - 2] == ';') i-= 2;
c = 8; i--;
while (i >= 0 && c >= 0) {
if (isalnum(exename[i])) CdromId[c--] = exename[i];
i--;
}
}
}
if (Config.PsxAuto) { // autodetect system (pal or ntsc)
if (strstr(exename, "ES") != NULL)
Config.PsxType = PSX_TYPE_PAL; // pal
else Config.PsxType = PSX_TYPE_NTSC; // ntsc
}
if (CdromLabel[0] == ' ') {
strncpy(CdromLabel, CdromId, 9);
}
SysPrintf(_("CD-ROM Label: %.32s\n"), CdromLabel);
SysPrintf(_("CD-ROM ID: %.9s\n"), CdromId);
BuildPPFCache();
return 0;
}
static int PSXGetFileType(FILE *f) {
unsigned long current;
u8 mybuf[2048];
EXE_HEADER *exe_hdr;
FILHDR *coff_hdr;
current = ftell(f);
fseek(f, 0L, SEEK_SET);
fread(mybuf, 2048, 1, f);
fseek(f, current, SEEK_SET);
exe_hdr = (EXE_HEADER *)mybuf;
if (memcmp(exe_hdr->id, "PS-X EXE", 8) == 0)
return PSX_EXE;
if (mybuf[0] == 'C' && mybuf[1] == 'P' && mybuf[2] == 'E')
return CPE_EXE;
coff_hdr = (FILHDR *)mybuf;
if (SWAPu16(coff_hdr->f_magic) == 0x0162)
return COFF_EXE;
return INVALID_EXE;
}
int Load(const char *ExePath) {
FILE *tmpFile;
EXE_HEADER tmpHead;
int type;
int retval = 0;
u8 opcode;
u32 section_address, section_size;
strncpy(CdromId, "SLUS99999", 9);
strncpy(CdromLabel, "SLUS_999.99", 11);
tmpFile = fopen(ExePath, "rb");
if (tmpFile == NULL) {
SysPrintf(_("Error opening file: %s.\n"), ExePath);
retval = -1;
} else {
type = PSXGetFileType(tmpFile);
switch (type) {
case PSX_EXE:
fread(&tmpHead,sizeof(EXE_HEADER),1,tmpFile);
fseek(tmpFile, 0x800, SEEK_SET);
fread((void *)PSXM(SWAP32(tmpHead.t_addr)), SWAP32(tmpHead.t_size),1,tmpFile);
fclose(tmpFile);
psxRegs.pc = SWAP32(tmpHead.pc0);
psxRegs.GPR.n.gp = SWAP32(tmpHead.gp0);
psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr);
if (psxRegs.GPR.n.sp == 0)
psxRegs.GPR.n.sp = 0x801fff00;
retval = 0;
break;
case CPE_EXE:
fseek(tmpFile, 6, SEEK_SET); /* Something tells me we should go to 4 and read the "08 00" here... */
do {
fread(&opcode, 1, 1, tmpFile);
switch (opcode) {
case 1: /* Section loading */
fread(&section_address, 4, 1, tmpFile);
fread(&section_size, 4, 1, tmpFile);
section_address = SWAPu32(section_address);
section_size = SWAPu32(section_size);
#ifdef EMU_LOG
EMU_LOG("Loading %08X bytes from %08X to %08X\n", section_size, ftell(tmpFile), section_address);
#endif
fread(PSXM(section_address), section_size, 1, tmpFile);
break;
case 3: /* register loading (PC only?) */
fseek(tmpFile, 2, SEEK_CUR); /* unknown field */
fread(&psxRegs.pc, 4, 1, tmpFile);
psxRegs.pc = SWAPu32(psxRegs.pc);
break;
case 0: /* End of file */
break;
default:
SysPrintf(_("Unknown CPE opcode %02x at position %08x.\n"), opcode, ftell(tmpFile) - 1);
retval = -1;
break;
}
} while (opcode != 0 && retval == 0);
break;
case COFF_EXE:
SysPrintf(_("COFF files not supported.\n"));
retval = -1;
break;
case INVALID_EXE:
SysPrintf(_("This file does not appear to be a valid PSX file.\n"));
retval = -1;
break;
}
}
if (retval != 0) {
CdromId[0] = '\0';
CdromLabel[0] = '\0';
}
return retval;
}
// STATES
static const char PcsxHeader[32] = "STv4 PCSX v" PACKAGE_VERSION;
// Savestate Versioning!
// If you make changes to the savestate version, please increment the value below.
static const u32 SaveVersion = 0x8b410004;
int SaveState(const char *file) {
gzFile f;
GPUFreeze_t *gpufP;
SPUFreeze_t *spufP;
int Size;
unsigned char *pMem;
f = gzopen(file, "wb");
if (f == NULL) return -1;
gzwrite(f, (void *)PcsxHeader, 32);
gzwrite(f, (void *)&SaveVersion, sizeof(u32));
gzwrite(f, (void *)&Config.HLE, sizeof(boolean));
pMem = (unsigned char *)malloc(128 * 96 * 3);
if (pMem == NULL) return -1;
GPU_getScreenPic(pMem);
gzwrite(f, pMem, 128 * 96 * 3);
free(pMem);
if (Config.HLE)
psxBiosFreeze(1);
gzwrite(f, psxM, 0x00200000);
gzwrite(f, psxR, 0x00080000);
gzwrite(f, psxH, 0x00010000);
gzwrite(f, (void *)&psxRegs, sizeof(psxRegs));
// gpu
gpufP = (GPUFreeze_t *)malloc(sizeof(GPUFreeze_t));
gpufP->ulFreezeVersion = 1;
GPU_freeze(1, gpufP);
gzwrite(f, gpufP, sizeof(GPUFreeze_t));
free(gpufP);
// spu
spufP = (SPUFreeze_t *) malloc(16);
SPU_freeze(2, spufP);
Size = spufP->Size; gzwrite(f, &Size, 4);
free(spufP);
spufP = (SPUFreeze_t *) malloc(Size);
SPU_freeze(1, spufP);
gzwrite(f, spufP, Size);
free(spufP);
sioFreeze(f, 1);
cdrFreeze(f, 1);
psxHwFreeze(f, 1);
psxRcntFreeze(f, 1);
mdecFreeze(f, 1);
gzclose(f);
return 0;
}
int LoadState(const char *file) {
gzFile f;
GPUFreeze_t *gpufP;
SPUFreeze_t *spufP;
int Size;
char header[32];
u32 version;
boolean hle;
f = gzopen(file, "rb");
if (f == NULL) return -1;
gzread(f, header, sizeof(header));
gzread(f, &version, sizeof(u32));
gzread(f, &hle, sizeof(boolean));
if (strncmp("STv4 PCSX", header, 9) != 0 || version != SaveVersion || hle != Config.HLE) {
gzclose(f);
return -1;
}
psxCpu->Reset();
gzseek(f, 128 * 96 * 3, SEEK_CUR);
gzread(f, psxM, 0x00200000);
gzread(f, psxR, 0x00080000);
gzread(f, psxH, 0x00010000);
gzread(f, (void *)&psxRegs, sizeof(psxRegs));
if (Config.HLE)
psxBiosFreeze(0);
// gpu
gpufP = (GPUFreeze_t *)malloc(sizeof(GPUFreeze_t));
gzread(f, gpufP, sizeof(GPUFreeze_t));
GPU_freeze(0, gpufP);
free(gpufP);
// spu
gzread(f, &Size, 4);
spufP = (SPUFreeze_t *)malloc(Size);
gzread(f, spufP, Size);
SPU_freeze(0, spufP);
free(spufP);
sioFreeze(f, 0);
cdrFreeze(f, 0);
psxHwFreeze(f, 0);
psxRcntFreeze(f, 0);
mdecFreeze(f, 0);
gzclose(f);
return 0;
}
int CheckState(const char *file) {
gzFile f;
char header[32];
u32 version;
boolean hle;
f = gzopen(file, "rb");
if (f == NULL) return -1;
gzread(f, header, sizeof(header));
gzread(f, &version, sizeof(u32));
gzread(f, &hle, sizeof(boolean));
gzclose(f);
if (strncmp("STv4 PCSX", header, 9) != 0 || version != SaveVersion || hle != Config.HLE)
return -1;
return 0;
}
// NET Function Helpers
int SendPcsxInfo() {
if (NET_recvData == NULL || NET_sendData == NULL)
return 0;
NET_sendData(&Config.Xa, sizeof(Config.Xa), PSE_NET_BLOCKING);
NET_sendData(&Config.Sio, sizeof(Config.Sio), PSE_NET_BLOCKING);
NET_sendData(&Config.SpuIrq, sizeof(Config.SpuIrq), PSE_NET_BLOCKING);
NET_sendData(&Config.RCntFix, sizeof(Config.RCntFix), PSE_NET_BLOCKING);
NET_sendData(&Config.PsxType, sizeof(Config.PsxType), PSE_NET_BLOCKING);
NET_sendData(&Config.Cpu, sizeof(Config.Cpu), PSE_NET_BLOCKING);
return 0;
}
int RecvPcsxInfo() {
int tmp;
if (NET_recvData == NULL || NET_sendData == NULL)
return 0;
NET_recvData(&Config.Xa, sizeof(Config.Xa), PSE_NET_BLOCKING);
NET_recvData(&Config.Sio, sizeof(Config.Sio), PSE_NET_BLOCKING);
NET_recvData(&Config.SpuIrq, sizeof(Config.SpuIrq), PSE_NET_BLOCKING);
NET_recvData(&Config.RCntFix, sizeof(Config.RCntFix), PSE_NET_BLOCKING);
NET_recvData(&Config.PsxType, sizeof(Config.PsxType), PSE_NET_BLOCKING);
SysUpdate();
tmp = Config.Cpu;
NET_recvData(&Config.Cpu, sizeof(Config.Cpu), PSE_NET_BLOCKING);
if (tmp != Config.Cpu) {
psxCpu->Shutdown();
#ifdef PSXREC
if (Config.Cpu == CPU_INTERPRETER) psxCpu = &psxInt;
else psxCpu = &psxRec;
#else
psxCpu = &psxInt;
#endif
if (psxCpu->Init() == -1) {
SysClose(); return -1;
}
psxCpu->Reset();
}
return 0;
}
// remove the leading and trailing spaces in a string
void trim(char *str) {
int pos = 0;
char *dest = str;
// skip leading blanks
while (str[pos] <= ' ' && str[pos] > 0)
pos++;
while (str[pos]) {
*(dest++) = str[pos];
pos++;
}
*(dest--) = '\0'; // store the null
// remove trailing blanks
while (dest >= str && *dest <= ' ' && *dest > 0)
*(dest--) = '\0';
}
// lookup table for crc calculation
static unsigned short crctab[256] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108,
0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210,
0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B,
0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401,
0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE,
0xF5CF, 0xC5AC, 0xD58D, 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6,
0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D,
0xC7BC, 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 0x5AF5,
0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC,
0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 0x6CA6, 0x7C87, 0x4CE4,
0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD,
0xAD2A, 0xBD0B, 0x8D68, 0x9D49, 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13,
0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A,
0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E,
0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 0x02B1,
0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 0xB5EA, 0xA5CB,
0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 0x34E2, 0x24C3, 0x14A0,
0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xA7DB, 0xB7FA, 0x8799, 0x97B8,
0xE75F, 0xF77E, 0xC71D, 0xD73C, 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657,
0x7676, 0x4615, 0x5634, 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9,
0xB98A, 0xA9AB, 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882,
0x28A3, 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 0xFD2E,
0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07,
0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D,
0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74,
0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
u16 calcCrc(u8 *d, int len) {
u16 crc = 0;
int i;
for (i = 0; i < len; i++) {
crc = crctab[(crc >> 8) ^ d[i]] ^ (crc << 8);
}
return ~crc;
}

77
libpcsxcore/misc.h Normal file
View File

@ -0,0 +1,77 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __MISC_H__
#define __MISC_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "psxcommon.h"
#include "coff.h"
#include "plugins.h"
#include "r3000a.h"
#include "psxmem.h"
#undef s_addr
typedef struct {
unsigned char id[8];
u32 text;
u32 data;
u32 pc0;
u32 gp0;
u32 t_addr;
u32 t_size;
u32 d_addr;
u32 d_size;
u32 b_addr;
u32 b_size;
u32 s_addr;
u32 s_size;
u32 SavedSP;
u32 SavedFP;
u32 SavedGP;
u32 SavedRA;
u32 SavedS0;
} EXE_HEADER;
extern char CdromId[10];
extern char CdromLabel[33];
int LoadCdrom();
int LoadCdromFile(const char *filename, EXE_HEADER *head);
int CheckCdrom();
int Load(const char *ExePath);
int SaveState(const char *file);
int LoadState(const char *file);
int CheckState(const char *file);
int SendPcsxInfo();
int RecvPcsxInfo();
void trim(char *str);
u16 calcCrc(u8 *d, int len);
#ifdef __cplusplus
}
#endif
#endif

815
libpcsxcore/plugins.c Normal file
View File

@ -0,0 +1,815 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
/*
* Plugin library callback/access functions.
*/
#include "plugins.h"
#include "cdriso.h"
static char IsoFile[MAXPATHLEN] = "";
static s64 cdOpenCaseTime = 0;
GPUupdateLace GPU_updateLace;
GPUinit GPU_init;
GPUshutdown GPU_shutdown;
GPUconfigure GPU_configure;
GPUtest GPU_test;
GPUabout GPU_about;
GPUopen GPU_open;
GPUclose GPU_close;
GPUreadStatus GPU_readStatus;
GPUreadData GPU_readData;
GPUreadDataMem GPU_readDataMem;
GPUwriteStatus GPU_writeStatus;
GPUwriteData GPU_writeData;
GPUwriteDataMem GPU_writeDataMem;
GPUdmaChain GPU_dmaChain;
GPUkeypressed GPU_keypressed;
GPUdisplayText GPU_displayText;
GPUmakeSnapshot GPU_makeSnapshot;
GPUfreeze GPU_freeze;
GPUgetScreenPic GPU_getScreenPic;
GPUshowScreenPic GPU_showScreenPic;
GPUclearDynarec GPU_clearDynarec;
GPUvBlank GPU_vBlank;
CDRinit CDR_init;
CDRshutdown CDR_shutdown;
CDRopen CDR_open;
CDRclose CDR_close;
CDRtest CDR_test;
CDRgetTN CDR_getTN;
CDRgetTD CDR_getTD;
CDRreadTrack CDR_readTrack;
CDRgetBuffer CDR_getBuffer;
CDRplay CDR_play;
CDRstop CDR_stop;
CDRgetStatus CDR_getStatus;
CDRgetDriveLetter CDR_getDriveLetter;
CDRgetBufferSub CDR_getBufferSub;
CDRconfigure CDR_configure;
CDRabout CDR_about;
CDRsetfilename CDR_setfilename;
CDRreadCDDA CDR_readCDDA;
CDRgetTE CDR_getTE;
SPUconfigure SPU_configure;
SPUabout SPU_about;
SPUinit SPU_init;
SPUshutdown SPU_shutdown;
SPUtest SPU_test;
SPUopen SPU_open;
SPUclose SPU_close;
SPUplaySample SPU_playSample;
SPUwriteRegister SPU_writeRegister;
SPUreadRegister SPU_readRegister;
SPUwriteDMA SPU_writeDMA;
SPUreadDMA SPU_readDMA;
SPUwriteDMAMem SPU_writeDMAMem;
SPUreadDMAMem SPU_readDMAMem;
SPUplayADPCMchannel SPU_playADPCMchannel;
SPUfreeze SPU_freeze;
SPUregisterCallback SPU_registerCallback;
SPUasync SPU_async;
SPUplayCDDAchannel SPU_playCDDAchannel;
PADconfigure PAD1_configure;
PADabout PAD1_about;
PADinit PAD1_init;
PADshutdown PAD1_shutdown;
PADtest PAD1_test;
PADopen PAD1_open;
PADclose PAD1_close;
PADquery PAD1_query;
PADreadPort1 PAD1_readPort1;
PADkeypressed PAD1_keypressed;
PADstartPoll PAD1_startPoll;
PADpoll PAD1_poll;
PADsetSensitive PAD1_setSensitive;
PADconfigure PAD2_configure;
PADabout PAD2_about;
PADinit PAD2_init;
PADshutdown PAD2_shutdown;
PADtest PAD2_test;
PADopen PAD2_open;
PADclose PAD2_close;
PADquery PAD2_query;
PADreadPort2 PAD2_readPort2;
PADkeypressed PAD2_keypressed;
PADstartPoll PAD2_startPoll;
PADpoll PAD2_poll;
PADsetSensitive PAD2_setSensitive;
NETinit NET_init;
NETshutdown NET_shutdown;
NETopen NET_open;
NETclose NET_close;
NETtest NET_test;
NETconfigure NET_configure;
NETabout NET_about;
NETpause NET_pause;
NETresume NET_resume;
NETqueryPlayer NET_queryPlayer;
NETsendData NET_sendData;
NETrecvData NET_recvData;
NETsendPadData NET_sendPadData;
NETrecvPadData NET_recvPadData;
NETsetInfo NET_setInfo;
NETkeypressed NET_keypressed;
#ifdef ENABLE_SIO1API
SIO1init SIO1_init;
SIO1shutdown SIO1_shutdown;
SIO1open SIO1_open;
SIO1close SIO1_close;
SIO1test SIO1_test;
SIO1configure SIO1_configure;
SIO1about SIO1_about;
SIO1pause SIO1_pause;
SIO1resume SIO1_resume;
SIO1keypressed SIO1_keypressed;
SIO1writeData8 SIO1_writeData8;
SIO1writeData16 SIO1_writeData16;
SIO1writeData32 SIO1_writeData32;
SIO1writeStat16 SIO1_writeStat16;
SIO1writeStat32 SIO1_writeStat32;
SIO1writeMode16 SIO1_writeMode16;
SIO1writeMode32 SIO1_writeMode32;
SIO1writeCtrl16 SIO1_writeCtrl16;
SIO1writeCtrl32 SIO1_writeCtrl32;
SIO1writeBaud16 SIO1_writeBaud16;
SIO1writeBaud32 SIO1_writeBaud32;
SIO1readData8 SIO1_readData8;
SIO1readData16 SIO1_readData16;
SIO1readData32 SIO1_readData32;
SIO1readStat16 SIO1_readStat16;
SIO1readStat32 SIO1_readStat32;
SIO1readMode16 SIO1_readMode16;
SIO1readMode32 SIO1_readMode32;
SIO1readCtrl16 SIO1_readCtrl16;
SIO1readCtrl32 SIO1_readCtrl32;
SIO1readBaud16 SIO1_readBaud16;
SIO1readBaud32 SIO1_readBaud32;
SIO1registerCallback SIO1_registerCallback;
#endif
static const char *err;
#define CheckErr(func) { \
err = SysLibError(); \
if (err != NULL) { SysMessage(_("Error loading %s: %s"), func, err); return -1; } \
}
#define LoadSym(dest, src, name, checkerr) { \
dest = (src)SysLoadSym(drv, name); \
if (checkerr) { CheckErr(name); } else SysLibError(); \
}
void *hGPUDriver = NULL;
void CALLBACK GPU__displayText(char *pText) {
SysPrintf("%s\n", pText);
}
long CALLBACK GPU__configure(void) { return 0; }
long CALLBACK GPU__test(void) { return 0; }
void CALLBACK GPU__about(void) {}
void CALLBACK GPU__makeSnapshot(void) {}
void CALLBACK GPU__keypressed(int key) {}
long CALLBACK GPU__getScreenPic(unsigned char *pMem) { return -1; }
long CALLBACK GPU__showScreenPic(unsigned char *pMem) { return -1; }
void CALLBACK GPU__clearDynarec(void (CALLBACK *callback)(void)) {}
void CALLBACK GPU__vBlank(int val) {}
#define LoadGpuSym1(dest, name) \
LoadSym(GPU_##dest, GPU##dest, name, TRUE);
#define LoadGpuSym0(dest, name) \
LoadSym(GPU_##dest, GPU##dest, name, FALSE); \
if (GPU_##dest == NULL) GPU_##dest = (GPU##dest) GPU__##dest;
#define LoadGpuSymN(dest, name) \
LoadSym(GPU_##dest, GPU##dest, name, FALSE);
static int LoadGPUplugin(const char *GPUdll) {
void *drv;
hGPUDriver = SysLoadLibrary(GPUdll);
if (hGPUDriver == NULL) {
GPU_configure = NULL;
SysMessage (_("Could not load GPU plugin %s!"), GPUdll); return -1;
}
drv = hGPUDriver;
LoadGpuSym1(init, "GPUinit");
LoadGpuSym1(shutdown, "GPUshutdown");
LoadGpuSym1(open, "GPUopen");
LoadGpuSym1(close, "GPUclose");
LoadGpuSym1(readData, "GPUreadData");
LoadGpuSym1(readDataMem, "GPUreadDataMem");
LoadGpuSym1(readStatus, "GPUreadStatus");
LoadGpuSym1(writeData, "GPUwriteData");
LoadGpuSym1(writeDataMem, "GPUwriteDataMem");
LoadGpuSym1(writeStatus, "GPUwriteStatus");
LoadGpuSym1(dmaChain, "GPUdmaChain");
LoadGpuSym1(updateLace, "GPUupdateLace");
LoadGpuSym0(keypressed, "GPUkeypressed");
LoadGpuSym0(displayText, "GPUdisplayText");
LoadGpuSym0(makeSnapshot, "GPUmakeSnapshot");
LoadGpuSym1(freeze, "GPUfreeze");
LoadGpuSym0(getScreenPic, "GPUgetScreenPic");
LoadGpuSym0(showScreenPic, "GPUshowScreenPic");
LoadGpuSym0(clearDynarec, "GPUclearDynarec");
LoadGpuSym0(vBlank, "GPUvBlank");
LoadGpuSym0(configure, "GPUconfigure");
LoadGpuSym0(test, "GPUtest");
LoadGpuSym0(about, "GPUabout");
return 0;
}
void *hCDRDriver = NULL;
long CALLBACK CDR__play(unsigned char *sector) { return 0; }
long CALLBACK CDR__stop(void) { return 0; }
long CALLBACK CDR__getStatus(struct CdrStat *stat) {
if (cdOpenCaseTime < 0 || cdOpenCaseTime > (s64)time(NULL))
stat->Status = 0x10;
else
stat->Status = 0;
return 0;
}
char* CALLBACK CDR__getDriveLetter(void) { return NULL; }
long CALLBACK CDR__configure(void) { return 0; }
long CALLBACK CDR__test(void) { return 0; }
void CALLBACK CDR__about(void) {}
long CALLBACK CDR__setfilename(char*filename) { return 0; }
#define LoadCdrSym1(dest, name) \
LoadSym(CDR_##dest, CDR##dest, name, TRUE);
#define LoadCdrSym0(dest, name) \
LoadSym(CDR_##dest, CDR##dest, name, FALSE); \
if (CDR_##dest == NULL) CDR_##dest = (CDR##dest) CDR__##dest;
#define LoadCdrSymN(dest, name) \
LoadSym(CDR_##dest, CDR##dest, name, FALSE);
static int LoadCDRplugin(const char *CDRdll) {
void *drv;
if (CDRdll == NULL) {
cdrIsoInit();
return 0;
}
hCDRDriver = SysLoadLibrary(CDRdll);
if (hCDRDriver == NULL) {
CDR_configure = NULL;
SysMessage (_("Could not load CD-ROM plugin %s!"), CDRdll); return -1;
}
drv = hCDRDriver;
LoadCdrSym1(init, "CDRinit");
LoadCdrSym1(shutdown, "CDRshutdown");
LoadCdrSym1(open, "CDRopen");
LoadCdrSym1(close, "CDRclose");
LoadCdrSym1(getTN, "CDRgetTN");
LoadCdrSym1(getTD, "CDRgetTD");
LoadCdrSym1(readTrack, "CDRreadTrack");
LoadCdrSym1(getBuffer, "CDRgetBuffer");
LoadCdrSym1(getBufferSub, "CDRgetBufferSub");
LoadCdrSym0(play, "CDRplay");
LoadCdrSym0(stop, "CDRstop");
LoadCdrSym0(getStatus, "CDRgetStatus");
LoadCdrSym0(getDriveLetter, "CDRgetDriveLetter");
LoadCdrSym0(configure, "CDRconfigure");
LoadCdrSym0(test, "CDRtest");
LoadCdrSym0(about, "CDRabout");
LoadCdrSym0(setfilename, "CDRsetfilename");
LoadCdrSymN(readCDDA, "CDRreadCDDA");
LoadCdrSymN(getTE, "CDRgetTE");
return 0;
}
void *hSPUDriver = NULL;
long CALLBACK SPU__configure(void) { return 0; }
void CALLBACK SPU__about(void) {}
long CALLBACK SPU__test(void) { return 0; }
#define LoadSpuSym1(dest, name) \
LoadSym(SPU_##dest, SPU##dest, name, TRUE);
#define LoadSpuSym0(dest, name) \
LoadSym(SPU_##dest, SPU##dest, name, FALSE); \
if (SPU_##dest == NULL) SPU_##dest = (SPU##dest) SPU__##dest;
#define LoadSpuSymN(dest, name) \
LoadSym(SPU_##dest, SPU##dest, name, FALSE);
static int LoadSPUplugin(const char *SPUdll) {
void *drv;
hSPUDriver = SysLoadLibrary(SPUdll);
if (hSPUDriver == NULL) {
SPU_configure = NULL;
SysMessage (_("Could not load SPU plugin %s!"), SPUdll); return -1;
}
drv = hSPUDriver;
LoadSpuSym1(init, "SPUinit");
LoadSpuSym1(shutdown, "SPUshutdown");
LoadSpuSym1(open, "SPUopen");
LoadSpuSym1(close, "SPUclose");
LoadSpuSym0(configure, "SPUconfigure");
LoadSpuSym0(about, "SPUabout");
LoadSpuSym0(test, "SPUtest");
LoadSpuSym1(writeRegister, "SPUwriteRegister");
LoadSpuSym1(readRegister, "SPUreadRegister");
LoadSpuSym1(writeDMA, "SPUwriteDMA");
LoadSpuSym1(readDMA, "SPUreadDMA");
LoadSpuSym1(writeDMAMem, "SPUwriteDMAMem");
LoadSpuSym1(readDMAMem, "SPUreadDMAMem");
LoadSpuSym1(playADPCMchannel, "SPUplayADPCMchannel");
LoadSpuSym1(freeze, "SPUfreeze");
LoadSpuSym1(registerCallback, "SPUregisterCallback");
LoadSpuSymN(async, "SPUasync");
LoadSpuSymN(playCDDAchannel, "SPUplayCDDAchannel");
return 0;
}
void *hPAD1Driver = NULL;
void *hPAD2Driver = NULL;
static unsigned char buf[256];
unsigned char stdpar[10] = { 0x00, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
unsigned char mousepar[8] = { 0x00, 0x12, 0x5a, 0xff, 0xff, 0xff, 0xff };
unsigned char analogpar[9] = { 0x00, 0xff, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
static int bufcount, bufc;
PadDataS padd1, padd2;
unsigned char _PADstartPoll(PadDataS *pad) {
bufc = 0;
switch (pad->controllerType) {
case PSE_PAD_TYPE_MOUSE:
mousepar[3] = pad->buttonStatus & 0xff;
mousepar[4] = pad->buttonStatus >> 8;
mousepar[5] = pad->moveX;
mousepar[6] = pad->moveY;
memcpy(buf, mousepar, 7);
bufcount = 6;
break;
case PSE_PAD_TYPE_NEGCON: // npc101/npc104(slph00001/slph00069)
analogpar[1] = 0x23;
analogpar[3] = pad->buttonStatus & 0xff;
analogpar[4] = pad->buttonStatus >> 8;
analogpar[5] = pad->rightJoyX;
analogpar[6] = pad->rightJoyY;
analogpar[7] = pad->leftJoyX;
analogpar[8] = pad->leftJoyY;
memcpy(buf, analogpar, 9);
bufcount = 8;
break;
case PSE_PAD_TYPE_ANALOGPAD: // scph1150
analogpar[1] = 0x73;
analogpar[3] = pad->buttonStatus & 0xff;
analogpar[4] = pad->buttonStatus >> 8;
analogpar[5] = pad->rightJoyX;
analogpar[6] = pad->rightJoyY;
analogpar[7] = pad->leftJoyX;
analogpar[8] = pad->leftJoyY;
memcpy(buf, analogpar, 9);
bufcount = 8;
break;
case PSE_PAD_TYPE_ANALOGJOY: // scph1110
analogpar[1] = 0x53;
analogpar[3] = pad->buttonStatus & 0xff;
analogpar[4] = pad->buttonStatus >> 8;
analogpar[5] = pad->rightJoyX;
analogpar[6] = pad->rightJoyY;
analogpar[7] = pad->leftJoyX;
analogpar[8] = pad->leftJoyY;
memcpy(buf, analogpar, 9);
bufcount = 8;
break;
case PSE_PAD_TYPE_STANDARD:
default:
stdpar[3] = pad->buttonStatus & 0xff;
stdpar[4] = pad->buttonStatus >> 8;
memcpy(buf, stdpar, 5);
bufcount = 4;
}
return buf[bufc++];
}
unsigned char _PADpoll(unsigned char value) {
if (bufc > bufcount) return 0;
return buf[bufc++];
}
unsigned char CALLBACK PAD1__startPoll(int pad) {
PadDataS padd;
PAD1_readPort1(&padd);
return _PADstartPoll(&padd);
}
unsigned char CALLBACK PAD1__poll(unsigned char value) {
return _PADpoll(value);
}
long CALLBACK PAD1__configure(void) { return 0; }
void CALLBACK PAD1__about(void) {}
long CALLBACK PAD1__test(void) { return 0; }
long CALLBACK PAD1__query(void) { return 3; }
long CALLBACK PAD1__keypressed() { return 0; }
#define LoadPad1Sym1(dest, name) \
LoadSym(PAD1_##dest, PAD##dest, name, TRUE);
#define LoadPad1SymN(dest, name) \
LoadSym(PAD1_##dest, PAD##dest, name, FALSE);
#define LoadPad1Sym0(dest, name) \
LoadSym(PAD1_##dest, PAD##dest, name, FALSE); \
if (PAD1_##dest == NULL) PAD1_##dest = (PAD##dest) PAD1__##dest;
static int LoadPAD1plugin(const char *PAD1dll) {
void *drv;
hPAD1Driver = SysLoadLibrary(PAD1dll);
if (hPAD1Driver == NULL) {
PAD1_configure = NULL;
SysMessage (_("Could not load Controller 1 plugin %s!"), PAD1dll); return -1;
}
drv = hPAD1Driver;
LoadPad1Sym1(init, "PADinit");
LoadPad1Sym1(shutdown, "PADshutdown");
LoadPad1Sym1(open, "PADopen");
LoadPad1Sym1(close, "PADclose");
LoadPad1Sym0(query, "PADquery");
LoadPad1Sym1(readPort1, "PADreadPort1");
LoadPad1Sym0(configure, "PADconfigure");
LoadPad1Sym0(test, "PADtest");
LoadPad1Sym0(about, "PADabout");
LoadPad1Sym0(keypressed, "PADkeypressed");
LoadPad1Sym0(startPoll, "PADstartPoll");
LoadPad1Sym0(poll, "PADpoll");
LoadPad1SymN(setSensitive, "PADsetSensitive");
return 0;
}
unsigned char CALLBACK PAD2__startPoll(int pad) {
PadDataS padd;
PAD2_readPort2(&padd);
return _PADstartPoll(&padd);
}
unsigned char CALLBACK PAD2__poll(unsigned char value) {
return _PADpoll(value);
}
long CALLBACK PAD2__configure(void) { return 0; }
void CALLBACK PAD2__about(void) {}
long CALLBACK PAD2__test(void) { return 0; }
long CALLBACK PAD2__query(void) { return PSE_PAD_USE_PORT1 | PSE_PAD_USE_PORT2; }
long CALLBACK PAD2__keypressed() { return 0; }
#define LoadPad2Sym1(dest, name) \
LoadSym(PAD2_##dest, PAD##dest, name, TRUE);
#define LoadPad2Sym0(dest, name) \
LoadSym(PAD2_##dest, PAD##dest, name, FALSE); \
if (PAD2_##dest == NULL) PAD2_##dest = (PAD##dest) PAD2__##dest;
#define LoadPad2SymN(dest, name) \
LoadSym(PAD2_##dest, PAD##dest, name, FALSE);
static int LoadPAD2plugin(const char *PAD2dll) {
void *drv;
hPAD2Driver = SysLoadLibrary(PAD2dll);
if (hPAD2Driver == NULL) {
PAD2_configure = NULL;
SysMessage (_("Could not load Controller 2 plugin %s!"), PAD2dll); return -1;
}
drv = hPAD2Driver;
LoadPad2Sym1(init, "PADinit");
LoadPad2Sym1(shutdown, "PADshutdown");
LoadPad2Sym1(open, "PADopen");
LoadPad2Sym1(close, "PADclose");
LoadPad2Sym0(query, "PADquery");
LoadPad2Sym1(readPort2, "PADreadPort2");
LoadPad2Sym0(configure, "PADconfigure");
LoadPad2Sym0(test, "PADtest");
LoadPad2Sym0(about, "PADabout");
LoadPad2Sym0(keypressed, "PADkeypressed");
LoadPad2Sym0(startPoll, "PADstartPoll");
LoadPad2Sym0(poll, "PADpoll");
LoadPad2SymN(setSensitive, "PADsetSensitive");
return 0;
}
void *hNETDriver = NULL;
void CALLBACK NET__setInfo(netInfo *info) {}
void CALLBACK NET__keypressed(int key) {}
long CALLBACK NET__configure(void) { return 0; }
long CALLBACK NET__test(void) { return 0; }
void CALLBACK NET__about(void) {}
#define LoadNetSym1(dest, name) \
LoadSym(NET_##dest, NET##dest, name, TRUE);
#define LoadNetSymN(dest, name) \
LoadSym(NET_##dest, NET##dest, name, FALSE);
#define LoadNetSym0(dest, name) \
LoadSym(NET_##dest, NET##dest, name, FALSE); \
if (NET_##dest == NULL) NET_##dest = (NET##dest) NET__##dest;
static int LoadNETplugin(const char *NETdll) {
void *drv;
hNETDriver = SysLoadLibrary(NETdll);
if (hNETDriver == NULL) {
SysMessage (_("Could not load NetPlay plugin %s!"), NETdll); return -1;
}
drv = hNETDriver;
LoadNetSym1(init, "NETinit");
LoadNetSym1(shutdown, "NETshutdown");
LoadNetSym1(open, "NETopen");
LoadNetSym1(close, "NETclose");
LoadNetSymN(sendData, "NETsendData");
LoadNetSymN(recvData, "NETrecvData");
LoadNetSym1(sendPadData, "NETsendPadData");
LoadNetSym1(recvPadData, "NETrecvPadData");
LoadNetSym1(queryPlayer, "NETqueryPlayer");
LoadNetSym1(pause, "NETpause");
LoadNetSym1(resume, "NETresume");
LoadNetSym0(setInfo, "NETsetInfo");
LoadNetSym0(keypressed, "NETkeypressed");
LoadNetSym0(configure, "NETconfigure");
LoadNetSym0(test, "NETtest");
LoadNetSym0(about, "NETabout");
return 0;
}
#ifdef ENABLE_SIO1API
void *hSIO1Driver = NULL;
long CALLBACK SIO1__init(void) { return 0; }
long CALLBACK SIO1__shutdown(void) { return 0; }
long CALLBACK SIO1__open(void) { return 0; }
long CALLBACK SIO1__close(void) { return 0; }
long CALLBACK SIO1__configure(void) { return 0; }
long CALLBACK SIO1__test(void) { return 0; }
void CALLBACK SIO1__about(void) {}
void CALLBACK SIO1__pause(void) {}
void CALLBACK SIO1__resume(void) {}
long CALLBACK SIO1__keypressed(int key) { return 0; }
void CALLBACK SIO1__writeData8(unsigned char val) {}
void CALLBACK SIO1__writeData16(unsigned short val) {}
void CALLBACK SIO1__writeData32(unsigned long val) {}
void CALLBACK SIO1__writeStat16(unsigned short val) {}
void CALLBACK SIO1__writeStat32(unsigned long val) {}
void CALLBACK SIO1__writeMode16(unsigned short val) {}
void CALLBACK SIO1__writeMode32(unsigned long val) {}
void CALLBACK SIO1__writeCtrl16(unsigned short val) {}
void CALLBACK SIO1__writeCtrl32(unsigned long val) {}
void CALLBACK SIO1__writeBaud16(unsigned short val) {}
void CALLBACK SIO1__writeBaud32(unsigned long val) {}
unsigned char CALLBACK SIO1__readData8(void) { return 0; }
unsigned short CALLBACK SIO1__readData16(void) { return 0; }
unsigned long CALLBACK SIO1__readData32(void) { return 0; }
unsigned short CALLBACK SIO1__readStat16(void) { return 0; }
unsigned long CALLBACK SIO1__readStat32(void) { return 0; }
unsigned short CALLBACK SIO1__readMode16(void) { return 0; }
unsigned long CALLBACK SIO1__readMode32(void) { return 0; }
unsigned short CALLBACK SIO1__readCtrl16(void) { return 0; }
unsigned long CALLBACK SIO1__readCtrl32(void) { return 0; }
unsigned short CALLBACK SIO1__readBaud16(void) { return 0; }
unsigned long CALLBACK SIO1__readBaud32(void) { return 0; }
void CALLBACK SIO1__registerCallback(void (CALLBACK *callback)(void)) {};
void CALLBACK SIO1irq(void) {
psxHu32ref(0x1070) |= SWAPu32(0x100);
}
#define LoadSio1Sym1(dest, name) \
LoadSym(SIO1_##dest, SIO1##dest, name, TRUE);
#define LoadSio1SymN(dest, name) \
LoadSym(SIO1_##dest, SIO1##dest, name, FALSE);
#define LoadSio1Sym0(dest, name) \
LoadSym(SIO1_##dest, SIO1##dest, name, FALSE); \
if (SIO1_##dest == NULL) SIO1_##dest = (SIO1##dest) SIO1__##dest;
static int LoadSIO1plugin(const char *SIO1dll) {
void *drv;
hSIO1Driver = SysLoadLibrary(SIO1dll);
if (hSIO1Driver == NULL) {
SysMessage (_("Could not load SIO1 plugin %s!"), SIO1dll); return -1;
}
drv = hSIO1Driver;
LoadSio1Sym0(init, "SIO1init");
LoadSio1Sym0(shutdown, "SIO1shutdown");
LoadSio1Sym0(open, "SIO1open");
LoadSio1Sym0(close, "SIO1close");
LoadSio1Sym0(pause, "SIO1pause");
LoadSio1Sym0(resume, "SIO1resume");
LoadSio1Sym0(keypressed, "SIO1keypressed");
LoadSio1Sym0(configure, "SIO1configure");
LoadSio1Sym0(test, "SIO1test");
LoadSio1Sym0(about, "SIO1about");
LoadSio1Sym0(writeData8, "SIO1writeData8");
LoadSio1Sym0(writeData16, "SIO1writeData16");
LoadSio1Sym0(writeData32, "SIO1writeData32");
LoadSio1Sym0(writeStat16, "SIO1writeStat16");
LoadSio1Sym0(writeStat32, "SIO1writeStat32");
LoadSio1Sym0(writeMode16, "SIO1writeMode16");
LoadSio1Sym0(writeMode32, "SIO1writeMode32");
LoadSio1Sym0(writeCtrl16, "SIO1writeCtrl16");
LoadSio1Sym0(writeCtrl32, "SIO1writeCtrl32");
LoadSio1Sym0(writeBaud16, "SIO1writeBaud16");
LoadSio1Sym0(writeBaud32, "SIO1writeBaud32");
LoadSio1Sym0(readData16, "SIO1readData16");
LoadSio1Sym0(readData32, "SIO1readData32");
LoadSio1Sym0(readStat16, "SIO1readStat16");
LoadSio1Sym0(readStat32, "SIO1readStat32");
LoadSio1Sym0(readMode16, "SIO1readMode16");
LoadSio1Sym0(readMode32, "SIO1readMode32");
LoadSio1Sym0(readCtrl16, "SIO1readCtrl16");
LoadSio1Sym0(readCtrl32, "SIO1readCtrl32");
LoadSio1Sym0(readBaud16, "SIO1readBaud16");
LoadSio1Sym0(readBaud32, "SIO1readBaud32");
LoadSio1Sym0(registerCallback, "SIO1registerCallback");
return 0;
}
#endif
void CALLBACK clearDynarec(void) {
psxCpu->Reset();
}
int LoadPlugins() {
int ret;
char Plugin[MAXPATHLEN];
ReleasePlugins();
if (UsingIso()) {
LoadCDRplugin(NULL);
} else {
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Cdr);
if (LoadCDRplugin(Plugin) == -1) return -1;
}
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Gpu);
if (LoadGPUplugin(Plugin) == -1) return -1;
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Spu);
if (LoadSPUplugin(Plugin) == -1) return -1;
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad1);
if (LoadPAD1plugin(Plugin) == -1) return -1;
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Pad2);
if (LoadPAD2plugin(Plugin) == -1) return -1;
if (strcmp("Disabled", Config.Net) == 0 || strcmp("", Config.Net) == 0)
Config.UseNet = FALSE;
else {
Config.UseNet = TRUE;
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Net);
if (LoadNETplugin(Plugin) == -1) Config.UseNet = FALSE;
}
#ifdef ENABLE_SIO1API
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Sio1);
if (LoadSIO1plugin(Plugin) == -1) return -1;
#endif
ret = CDR_init();
if (ret < 0) { SysMessage (_("Error initializing CD-ROM plugin: %d"), ret); return -1; }
ret = GPU_init();
if (ret < 0) { SysMessage (_("Error initializing GPU plugin: %d"), ret); return -1; }
ret = SPU_init();
if (ret < 0) { SysMessage (_("Error initializing SPU plugin: %d"), ret); return -1; }
ret = PAD1_init(1);
if (ret < 0) { SysMessage (_("Error initializing Controller 1 plugin: %d"), ret); return -1; }
ret = PAD2_init(2);
if (ret < 0) { SysMessage (_("Error initializing Controller 2 plugin: %d"), ret); return -1; }
if (Config.UseNet) {
ret = NET_init();
if (ret < 0) { SysMessage (_("Error initializing NetPlay plugin: %d"), ret); return -1; }
}
#ifdef ENABLE_SIO1API
ret = SIO1_init();
if (ret < 0) { SysMessage (_("Error initializing SIO1 plugin: %d"), ret); return -1; }
#endif
SysPrintf(_("Plugins loaded.\n"));
return 0;
}
void ReleasePlugins() {
if (Config.UseNet) {
int ret = NET_close();
if (ret < 0) Config.UseNet = FALSE;
}
NetOpened = FALSE;
if (hCDRDriver != NULL || cdrIsoActive()) CDR_shutdown();
if (hGPUDriver != NULL) GPU_shutdown();
if (hSPUDriver != NULL) SPU_shutdown();
if (hPAD1Driver != NULL) PAD1_shutdown();
if (hPAD2Driver != NULL) PAD2_shutdown();
if (Config.UseNet && hNETDriver != NULL) NET_shutdown();
if (hCDRDriver != NULL) SysCloseLibrary(hCDRDriver); hCDRDriver = NULL;
if (hGPUDriver != NULL) SysCloseLibrary(hGPUDriver); hGPUDriver = NULL;
if (hSPUDriver != NULL) SysCloseLibrary(hSPUDriver); hSPUDriver = NULL;
if (hPAD1Driver != NULL) SysCloseLibrary(hPAD1Driver); hPAD1Driver = NULL;
if (hPAD2Driver != NULL) SysCloseLibrary(hPAD2Driver); hPAD2Driver = NULL;
if (Config.UseNet && hNETDriver != NULL) {
SysCloseLibrary(hNETDriver); hNETDriver = NULL;
}
#ifdef ENABLE_SIO1API
if (hSIO1Driver != NULL) {
SIO1_shutdown();
SysCloseLibrary(hSIO1Driver);
hSIO1Driver = NULL;
}
#endif
}
void SetIsoFile(const char *filename) {
if (filename == NULL) {
IsoFile[0] = '\0';
return;
}
strncpy(IsoFile, filename, MAXPATHLEN);
}
const char *GetIsoFile(void) {
return IsoFile;
}
boolean UsingIso(void) {
return (IsoFile[0] != '\0');
}
void SetCdOpenCaseTime(s64 time) {
cdOpenCaseTime = time;
}

411
libpcsxcore/plugins.h Normal file
View File

@ -0,0 +1,411 @@
/***************************************************************************
* Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
#ifndef __PLUGINS_H__
#define __PLUGINS_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "psxcommon.h"
//#define ENABLE_SIO1API 1
#ifndef _WIN32
typedef void* HWND;
#define CALLBACK
typedef long (*GPUopen)(unsigned long *, char *, char *);
typedef long (*SPUopen)(void);
typedef long (*PADopen)(unsigned long *);
typedef long (*NETopen)(unsigned long *);
typedef long (*SIO1open)(unsigned long *);
#else
#include <windows.h>
typedef long (CALLBACK* GPUopen)(HWND);
typedef long (CALLBACK* SPUopen)(HWND);
typedef long (CALLBACK* PADopen)(HWND);
typedef long (CALLBACK* NETopen)(HWND);
typedef long (CALLBACK* SIO1open)(HWND);
#endif
#include "spu.h"
#include "psemu_plugin_defs.h"
#include "decode_xa.h"
int LoadPlugins();
void ReleasePlugins();
int OpenPlugins();
void ClosePlugins();
typedef unsigned long (CALLBACK* PSEgetLibType)(void);
typedef unsigned long (CALLBACK* PSEgetLibVersion)(void);
typedef char *(CALLBACK* PSEgetLibName)(void);
// GPU Functions
typedef long (CALLBACK* GPUinit)(void);
typedef long (CALLBACK* GPUshutdown)(void);
typedef long (CALLBACK* GPUclose)(void);
typedef void (CALLBACK* GPUwriteStatus)(uint32_t);
typedef void (CALLBACK* GPUwriteData)(uint32_t);
typedef void (CALLBACK* GPUwriteDataMem)(uint32_t *, int);
typedef uint32_t (CALLBACK* GPUreadStatus)(void);
typedef uint32_t (CALLBACK* GPUreadData)(void);
typedef void (CALLBACK* GPUreadDataMem)(uint32_t *, int);
typedef long (CALLBACK* GPUdmaChain)(uint32_t *,uint32_t);
typedef void (CALLBACK* GPUupdateLace)(void);
typedef long (CALLBACK* GPUconfigure)(void);
typedef long (CALLBACK* GPUtest)(void);
typedef void (CALLBACK* GPUabout)(void);
typedef void (CALLBACK* GPUmakeSnapshot)(void);
typedef void (CALLBACK* GPUkeypressed)(int);
typedef void (CALLBACK* GPUdisplayText)(char *);
typedef struct {
uint32_t ulFreezeVersion;
uint32_t ulStatus;
uint32_t ulControl[256];
unsigned char psxVRam[1024*512*2];
} GPUFreeze_t;
typedef long (CALLBACK* GPUfreeze)(uint32_t, GPUFreeze_t *);
typedef long (CALLBACK* GPUgetScreenPic)(unsigned char *);
typedef long (CALLBACK* GPUshowScreenPic)(unsigned char *);
typedef void (CALLBACK* GPUclearDynarec)(void (CALLBACK *callback)(void));
typedef void (CALLBACK* GPUvBlank)(int);
// GPU function pointers
extern GPUupdateLace GPU_updateLace;
extern GPUinit GPU_init;
extern GPUshutdown GPU_shutdown;
extern GPUconfigure GPU_configure;
extern GPUtest GPU_test;
extern GPUabout GPU_about;
extern GPUopen GPU_open;
extern GPUclose GPU_close;
extern GPUreadStatus GPU_readStatus;
extern GPUreadData GPU_readData;
extern GPUreadDataMem GPU_readDataMem;
extern GPUwriteStatus GPU_writeStatus;
extern GPUwriteData GPU_writeData;
extern GPUwriteDataMem GPU_writeDataMem;
extern GPUdmaChain GPU_dmaChain;
extern GPUkeypressed GPU_keypressed;
extern GPUdisplayText GPU_displayText;
extern GPUmakeSnapshot GPU_makeSnapshot;
extern GPUfreeze GPU_freeze;
extern GPUgetScreenPic GPU_getScreenPic;
extern GPUshowScreenPic GPU_showScreenPic;
extern GPUclearDynarec GPU_clearDynarec;
extern GPUvBlank GPU_vBlank;
// CD-ROM Functions
typedef long (CALLBACK* CDRinit)(void);
typedef long (CALLBACK* CDRshutdown)(void);
typedef long (CALLBACK* CDRopen)(void);
typedef long (CALLBACK* CDRclose)(void);
typedef long (CALLBACK* CDRgetTN)(unsigned char *);
typedef long (CALLBACK* CDRgetTD)(unsigned char, unsigned char *);
typedef long (CALLBACK* CDRreadTrack)(unsigned char *);
typedef unsigned char* (CALLBACK* CDRgetBuffer)(void);
typedef unsigned char* (CALLBACK* CDRgetBufferSub)(void);
typedef long (CALLBACK* CDRconfigure)(void);
typedef long (CALLBACK* CDRtest)(void);
typedef void (CALLBACK* CDRabout)(void);
typedef long (CALLBACK* CDRplay)(unsigned char *);
typedef long (CALLBACK* CDRstop)(void);
typedef long (CALLBACK* CDRsetfilename)(char *);
struct CdrStat {
uint32_t Type;
uint32_t Status;
unsigned char Time[3];
};
typedef long (CALLBACK* CDRgetStatus)(struct CdrStat *);
typedef char* (CALLBACK* CDRgetDriveLetter)(void);
struct SubQ {
char res0[12];
unsigned char ControlAndADR;
unsigned char TrackNumber;
unsigned char IndexNumber;
unsigned char TrackRelativeAddress[3];
unsigned char Filler;
unsigned char AbsoluteAddress[3];
unsigned char CRC[2];
char res1[72];
};
typedef long (CALLBACK* CDRreadCDDA)(unsigned char, unsigned char, unsigned char, unsigned char *);
typedef long (CALLBACK* CDRgetTE)(unsigned char, unsigned char *, unsigned char *, unsigned char *);
// CD-ROM function pointers
extern CDRinit CDR_init;
extern CDRshutdown CDR_shutdown;
extern CDRopen CDR_open;
extern CDRclose CDR_close;
extern CDRtest CDR_test;
extern CDRgetTN CDR_getTN;
extern CDRgetTD CDR_getTD;
extern CDRreadTrack CDR_readTrack;
extern CDRgetBuffer CDR_getBuffer;
extern CDRgetBufferSub CDR_getBufferSub;
extern CDRplay CDR_play;
extern CDRstop CDR_stop;
extern CDRgetStatus CDR_getStatus;
extern CDRgetDriveLetter CDR_getDriveLetter;
extern CDRconfigure CDR_configure;
extern CDRabout CDR_about;
extern CDRsetfilename CDR_setfilename;
extern CDRreadCDDA CDR_readCDDA;
extern CDRgetTE CDR_getTE;
// SPU Functions
typedef long (CALLBACK* SPUinit)(void);
typedef long (CALLBACK* SPUshutdown)(void);
typedef long (CALLBACK* SPUclose)(void);
typedef void (CALLBACK* SPUplaySample)(unsigned char);
typedef void (CALLBACK* SPUwriteRegister)(unsigned long, unsigned short);
typedef unsigned short (CALLBACK* SPUreadRegister)(unsigned long);
typedef void (CALLBACK* SPUwriteDMA)(unsigned short);
typedef unsigned short (CALLBACK* SPUreadDMA)(void);
typedef void (CALLBACK* SPUwriteDMAMem)(unsigned short *, int);
typedef void (CALLBACK* SPUreadDMAMem)(unsigned short *, int);
typedef void (CALLBACK* SPUplayADPCMchannel)(xa_decode_t *);
typedef void (CALLBACK* SPUregisterCallback)(void (CALLBACK *callback)(void));
typedef long (CALLBACK* SPUconfigure)(void);
typedef long (CALLBACK* SPUtest)(void);
typedef void (CALLBACK* SPUabout)(void);
typedef struct {
unsigned char PluginName[8];
uint32_t PluginVersion;
uint32_t Size;
unsigned char SPUPorts[0x200];
unsigned char SPURam[0x80000];
xa_decode_t xa;
unsigned char *SPUInfo;
} SPUFreeze_t;
typedef long (CALLBACK* SPUfreeze)(uint32_t, SPUFreeze_t *);
typedef void (CALLBACK* SPUasync)(uint32_t);
typedef void (CALLBACK* SPUplayCDDAchannel)(short *, int);
// SPU function pointers
extern SPUconfigure SPU_configure;
extern SPUabout SPU_about;
extern SPUinit SPU_init;
extern SPUshutdown SPU_shutdown;
extern SPUtest SPU_test;
extern SPUopen SPU_open;
extern SPUclose SPU_close;
extern SPUplaySample SPU_playSample;
extern SPUwriteRegister SPU_writeRegister;
extern SPUreadRegister SPU_readRegister;
extern SPUwriteDMA SPU_writeDMA;
extern SPUreadDMA SPU_readDMA;
extern SPUwriteDMAMem SPU_writeDMAMem;
extern SPUreadDMAMem SPU_readDMAMem;
extern SPUplayADPCMchannel SPU_playADPCMchannel;
extern SPUfreeze SPU_freeze;
extern SPUregisterCallback SPU_registerCallback;
extern SPUasync SPU_async;
extern SPUplayCDDAchannel SPU_playCDDAchannel;
// PAD Functions
typedef long (CALLBACK* PADconfigure)(void);
typedef void (CALLBACK* PADabout)(void);
typedef long (CALLBACK* PADinit)(long);
typedef long (CALLBACK* PADshutdown)(void);
typedef long (CALLBACK* PADtest)(void);
typedef long (CALLBACK* PADclose)(void);
typedef long (CALLBACK* PADquery)(void);
typedef long (CALLBACK* PADreadPort1)(PadDataS*);
typedef long (CALLBACK* PADreadPort2)(PadDataS*);
typedef long (CALLBACK* PADkeypressed)(void);
typedef unsigned char (CALLBACK* PADstartPoll)(int);
typedef unsigned char (CALLBACK* PADpoll)(unsigned char);
typedef void (CALLBACK* PADsetSensitive)(int);
// PAD function pointers
extern PADconfigure PAD1_configure;
extern PADabout PAD1_about;
extern PADinit PAD1_init;
extern PADshutdown PAD1_shutdown;
extern PADtest PAD1_test;
extern PADopen PAD1_open;
extern PADclose PAD1_close;
extern PADquery PAD1_query;
extern PADreadPort1 PAD1_readPort1;
extern PADkeypressed PAD1_keypressed;
extern PADstartPoll PAD1_startPoll;
extern PADpoll PAD1_poll;
extern PADsetSensitive PAD1_setSensitive;
extern PADconfigure PAD2_configure;
extern PADabout PAD2_about;
extern PADinit PAD2_init;
extern PADshutdown PAD2_shutdown;
extern PADtest PAD2_test;
extern PADopen PAD2_open;
extern PADclose PAD2_close;
extern PADquery PAD2_query;
extern PADreadPort2 PAD2_readPort2;
extern PADkeypressed PAD2_keypressed;
extern PADstartPoll PAD2_startPoll;
extern PADpoll PAD2_poll;
extern PADsetSensitive PAD2_setSensitive;
// NET Functions
typedef long (CALLBACK* NETinit)(void);
typedef long (CALLBACK* NETshutdown)(void);
typedef long (CALLBACK* NETclose)(void);
typedef long (CALLBACK* NETconfigure)(void);
typedef long (CALLBACK* NETtest)(void);
typedef void (CALLBACK* NETabout)(void);
typedef void (CALLBACK* NETpause)(void);
typedef void (CALLBACK* NETresume)(void);
typedef long (CALLBACK* NETqueryPlayer)(void);
typedef long (CALLBACK* NETsendData)(void *, int, int);
typedef long (CALLBACK* NETrecvData)(void *, int, int);
typedef long (CALLBACK* NETsendPadData)(void *, int);
typedef long (CALLBACK* NETrecvPadData)(void *, int);
typedef struct {
char EmuName[32];
char CdromID[9]; // ie. 'SCPH12345', no \0 trailing character
char CdromLabel[11];
void *psxMem;
GPUshowScreenPic GPU_showScreenPic;
GPUdisplayText GPU_displayText;
PADsetSensitive PAD_setSensitive;
char GPUpath[256]; // paths must be absolute
char SPUpath[256];
char CDRpath[256];
char MCD1path[256];
char MCD2path[256];
char BIOSpath[256]; // 'HLE' for internal bios
char Unused[1024];
} netInfo;
typedef long (CALLBACK* NETsetInfo)(netInfo *);
typedef long (CALLBACK* NETkeypressed)(int);
// NET function pointers
extern NETinit NET_init;
extern NETshutdown NET_shutdown;
extern NETopen NET_open;
extern NETclose NET_close;
extern NETtest NET_test;
extern NETconfigure NET_configure;
extern NETabout NET_about;
extern NETpause NET_pause;
extern NETresume NET_resume;
extern NETqueryPlayer NET_queryPlayer;
extern NETsendData NET_sendData;
extern NETrecvData NET_recvData;
extern NETsendPadData NET_sendPadData;
extern NETrecvPadData NET_recvPadData;
extern NETsetInfo NET_setInfo;
extern NETkeypressed NET_keypressed;
#ifdef ENABLE_SIO1API
// SIO1 Functions (link cable)
typedef long (CALLBACK* SIO1init)(void);
typedef long (CALLBACK* SIO1shutdown)(void);
typedef long (CALLBACK* SIO1close)(void);
typedef long (CALLBACK* SIO1configure)(void);
typedef long (CALLBACK* SIO1test)(void);
typedef void (CALLBACK* SIO1about)(void);
typedef void (CALLBACK* SIO1pause)(void);
typedef void (CALLBACK* SIO1resume)(void);
typedef long (CALLBACK* SIO1keypressed)(int);
typedef void (CALLBACK* SIO1writeData8)(unsigned char);
typedef void (CALLBACK* SIO1writeData16)(unsigned short);
typedef void (CALLBACK* SIO1writeData32)(unsigned long);
typedef void (CALLBACK* SIO1writeStat16)(unsigned short);
typedef void (CALLBACK* SIO1writeStat32)(unsigned long);
typedef void (CALLBACK* SIO1writeMode16)(unsigned short);
typedef void (CALLBACK* SIO1writeMode32)(unsigned long);
typedef void (CALLBACK* SIO1writeCtrl16)(unsigned short);
typedef void (CALLBACK* SIO1writeCtrl32)(unsigned long);
typedef void (CALLBACK* SIO1writeBaud16)(unsigned short);
typedef void (CALLBACK* SIO1writeBaud32)(unsigned long);
typedef unsigned char (CALLBACK* SIO1readData8)(void);
typedef unsigned short (CALLBACK* SIO1readData16)(void);
typedef unsigned long (CALLBACK* SIO1readData32)(void);
typedef unsigned short (CALLBACK* SIO1readStat16)(void);
typedef unsigned long (CALLBACK* SIO1readStat32)(void);
typedef unsigned short (CALLBACK* SIO1readMode16)(void);
typedef unsigned long (CALLBACK* SIO1readMode32)(void);
typedef unsigned short (CALLBACK* SIO1readCtrl16)(void);
typedef unsigned long (CALLBACK* SIO1readCtrl32)(void);
typedef unsigned short (CALLBACK* SIO1readBaud16)(void);
typedef unsigned long (CALLBACK* SIO1readBaud32)(void);
typedef void (CALLBACK* SIO1registerCallback)(void (CALLBACK *callback)(void));
// SIO1 function pointers
extern SIO1init SIO1_init;
extern SIO1shutdown SIO1_shutdown;
extern SIO1open SIO1_open;
extern SIO1close SIO1_close;
extern SIO1test SIO1_test;
extern SIO1configure SIO1_configure;
extern SIO1about SIO1_about;
extern SIO1pause SIO1_pause;
extern SIO1resume SIO1_resume;
extern SIO1keypressed SIO1_keypressed;
extern SIO1writeData8 SIO1_writeData8;
extern SIO1writeData16 SIO1_writeData16;
extern SIO1writeData32 SIO1_writeData32;
extern SIO1writeStat16 SIO1_writeStat16;
extern SIO1writeStat32 SIO1_writeStat32;
extern SIO1writeMode16 SIO1_writeMode16;
extern SIO1writeMode32 SIO1_writeMode32;
extern SIO1writeCtrl16 SIO1_writeCtrl16;
extern SIO1writeCtrl32 SIO1_writeCtrl32;
extern SIO1writeBaud16 SIO1_writeBaud16;
extern SIO1writeBaud32 SIO1_writeBaud32;
extern SIO1readData8 SIO1_readData8;
extern SIO1readData16 SIO1_readData16;
extern SIO1readData32 SIO1_readData32;
extern SIO1readStat16 SIO1_readStat16;
extern SIO1readStat32 SIO1_readStat32;
extern SIO1readMode16 SIO1_readMode16;
extern SIO1readMode32 SIO1_readMode32;
extern SIO1readCtrl16 SIO1_readCtrl16;
extern SIO1readCtrl32 SIO1_readCtrl32;
extern SIO1readBaud16 SIO1_readBaud16;
extern SIO1readBaud32 SIO1_readBaud32;
extern SIO1registerCallback SIO1_registerCallback;
#endif
void CALLBACK clearDynarec(void);
void SetIsoFile(const char *filename);
const char *GetIsoFile(void);
boolean UsingIso(void);
void SetCdOpenCaseTime(s64 time);
#ifdef __cplusplus
}
#endif
#endif

91
libpcsxcore/ppc/pGte.h Normal file
View File

@ -0,0 +1,91 @@
/* Pcsx - Pc Psx Emulator
* Copyright (C) 1999-2003 Pcsx Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#ifndef PGET_H
#define PGET_H
#ifdef __cplusplus
extern "C" {
#endif
int psxCP2time[64] = {
2, 16 , 1 , 1, 1, 1 , 8, 1, // 00
1 , 1 , 1 , 1, 6 , 1 , 1 , 1, // 08
8 , 8, 8, 19, 13 , 1 , 44 , 1, // 10
1 , 1 , 1 , 17, 11 , 1 , 14 , 1, // 18
30 , 1 , 1 , 1, 1, 1 , 1 , 1, // 20
5 , 8 , 17 , 1, 1, 5, 6, 1, // 28
23 , 1 , 1 , 1, 1, 1 , 1 , 1, // 30
1 , 1 , 1 , 1, 1, 6 , 5 , 39 // 38
};
#define CP2_FUNC(f) \
void gte##f(); \
static void rec##f() { \
if (pc < cop2readypc) idlecyclecount += (cop2readypc - pc)>>2; \
iFlushRegs(0); \
LIW(0, (u32)psxRegs.code); \
STW(0, OFFSET(&psxRegs, &psxRegs.code), GetHWRegSpecial(PSXREGS)); \
FlushAllHWReg(); \
CALLFunc ((u32)gte##f); \
cop2readypc = pc + psxCP2time[_fFunct_(psxRegs.code)]<<2; \
}
#define CP2_FUNCNC(f) \
void gte##f(); \
static void rec##f() { \
if (pc < cop2readypc) idlecyclecount += (cop2readypc - pc)>>2; \
iFlushRegs(0); \
CALLFunc ((u32)gte##f); \
/* branch = 2; */\
cop2readypc = pc + psxCP2time[_fFunct_(psxRegs.code)]; \
}
CP2_FUNC(MFC2);
CP2_FUNC(MTC2);
CP2_FUNC(CFC2);
CP2_FUNC(CTC2);
CP2_FUNC(LWC2);
CP2_FUNC(SWC2);
CP2_FUNCNC(RTPS);
CP2_FUNC(OP);
CP2_FUNCNC(NCLIP);
CP2_FUNC(DPCS);
CP2_FUNC(INTPL);
CP2_FUNC(MVMVA);
CP2_FUNCNC(NCDS);
CP2_FUNCNC(NCDT);
CP2_FUNCNC(CDP);
CP2_FUNCNC(NCCS);
CP2_FUNCNC(CC);
CP2_FUNCNC(NCS);
CP2_FUNCNC(NCT);
CP2_FUNC(SQR);
CP2_FUNC(DCPL);
CP2_FUNCNC(DPCT);
CP2_FUNCNC(AVSZ3);
CP2_FUNCNC(AVSZ4);
CP2_FUNCNC(RTPT);
CP2_FUNC(GPF);
CP2_FUNC(GPL);
CP2_FUNCNC(NCCT);
#ifdef __cplusplus
}
#endif
#endif

3540
libpcsxcore/ppc/pR3000A.c Normal file

File diff suppressed because it is too large Load Diff

124
libpcsxcore/ppc/pasm.s Normal file
View File

@ -0,0 +1,124 @@
#define OLD_REGISTER_OFFSET (19*4)
#define SP_SIZE (OLD_REGISTER_OFFSET+4+8)
/*asm void recRun(register void (*func)(), register u32 hw1, register u32 hw2)*/
.text
.align 4
.globl recRun
recRun:
/* prologue code */
mflr r0
stmw r13, -(32-13)*4(r1)
stw r0, 4(r1)
stwu r1, -((32-13)*4+8)(r1)
/* execute code */
mtctr r3
mr r31, r4
mr r30, r5
bctrl
/*
}
asm void returnPC()
{*/
.text
.align 4
.globl returnPC
returnPC:
// end code
lwz r0, (32-13)*4+8+4(r1)
addi r1, r1, (32-13)*4+8
mtlr r0
lmw r13, -(32-13)*4(r1)
blr
//}*/
// Memory functions that only works with a linear memory
.text
.align 4
.globl dynMemRead8
dynMemRead8:
// assumes that memory pointer is in r30
addis r2,r3,-0x1f80
srwi. r4,r2,16
bne+ .norm8
cmplwi r2,0x1000
blt- .norm8
b psxHwRead8
.norm8:
clrlwi r5,r3,3
lbzx r3,r5,r30
blr
.text
.align 4
.globl dynMemRead16
dynMemRead16:
// assumes that memory pointer is in r30
addis r2,r3,-0x1f80
srwi. r4,r2,16
bne+ .norm16
cmplwi r2,0x1000
blt- .norm16
b psxHwRead16
.norm16:
clrlwi r5,r3,3
lhbrx r3,r5,r30
blr
.text
.align 4
.globl dynMemRead32
dynMemRead32:
// assumes that memory pointer is in r30
addis r2,r3,-0x1f80
srwi. r4,r2,16
bne+ .norm32
cmplwi r2,0x1000
blt- .norm32
b psxHwRead32
.norm32:
clrlwi r5,r3,3
lwbrx r3,r5,r30
blr
/*
N P Z
0 0 0 X
- 0 0 1 X
1 0 0 X
1 0 1 X
P | (!N & Z)
P | !(N | !Z)
*/
.text
.align 4
.globl dynMemWrite32
dynMemWrite32:
// assumes that memory pointer is in r30
addis r2,r3,-0x1f80
srwi. r5,r2,16
bne+ .normw32
cmplwi r2,0x1000
blt .normw32
b psxHwWrite32
.normw32:
mtcrf 0xFF, r3
clrlwi r5,r3,3
crandc 0, 2, 0
cror 2, 1, 0
bne+ .okw32
// write test
li r2,0x0130
addis r2,r2,0xfffe
cmplw r3,r2
bnelr
.okw32:
stwbrx r4,r5,r30
blr

32
libpcsxcore/ppc/ppc.c Normal file
View File

@ -0,0 +1,32 @@
/*
* ix86 core v0.5.1
* Authors: linuzappz <linuzappz@pcsx.net>
* alexey silinov
*/
#include <stdio.h>
#include <string.h>
#include "ppc.h"
// General Purpose hardware registers
int cpuHWRegisters[NUM_HW_REGISTERS] = {
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
};
u32 *ppcPtr;
void ppcInit() {
}
void ppcSetPtr(u32 *ptr) {
ppcPtr = ptr;
}
void ppcAlign(int bytes) {
// forward align
ppcPtr = (u32*)(((u32)ppcPtr + bytes) & ~(bytes - 1));
}
void ppcShutdown() {
}

60
libpcsxcore/ppc/ppc.h Normal file
View File

@ -0,0 +1,60 @@
/*
* ppc definitions v0.5.1
* Authors: linuzappz <linuzappz@pcsx.net>
* alexey silinov
*/
#ifndef __PPC_H__
#define __PPC_H__
#ifdef __cplusplus
extern "C" {
#endif
// include basic types
#include "../psxcommon.h"
#include "ppc_mnemonics.h"
#define NUM_HW_REGISTERS 29
/* general defines */
#define write8(val) *(u8 *)ppcPtr = val; ppcPtr++;
#define write16(val) *(u16*)ppcPtr = val; ppcPtr+=2;
#define write32(val) *(u32*)ppcPtr = val; ppcPtr+=4;
#define write64(val) *(u64*)ppcPtr = val; ppcPtr+=8;
#define CALLFunc(FUNC) \
{ \
u32 _func = (FUNC); \
ReleaseArgs(); \
if ((_func & 0x1fffffc) == _func) { \
BLA(_func); \
} else { \
LIW(0, _func); \
MTCTR(0); \
BCTRL(); \
} \
}
extern int cpuHWRegisters[NUM_HW_REGISTERS];
extern u32 *ppcPtr;
extern u8 *j8Ptr[32];
extern u32 *j32Ptr[32];
void ppcInit();
void ppcSetPtr(u32 *ptr);
void ppcShutdown();
void ppcAlign(int bytes);
void returnPC();
void recRun(void (*func)(), u32 hw1, u32 hw2);
u8 dynMemRead8(u32 mem);
u16 dynMemRead16(u32 mem);
u32 dynMemRead32(u32 mem);
void dynMemWrite32(u32 mem, u32 val);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,529 @@
// ppc_mnemonics.h
#define INSTR (*(ppcPtr)++)
/* Link register related */
#define MFLR(REG) \
{int _reg = (REG); \
INSTR = (0x7C0802A6 | (_reg << 21));}
#define MTLR(REG) \
{int _reg = (REG); \
INSTR = (0x7C0803A6 | (_reg << 21));}
#define MTCTR(REG) \
{int _reg = (REG); \
INSTR = (0x7C0903A6 | (_reg << 21));}
#define BLR() \
{INSTR = (0x4E800020);}
#define BGTLR() \
{INSTR = (0x4D810020);}
/* Load ops */
#define LI(REG, IMM) \
{int _reg = (REG); \
INSTR = (0x38000000 | (_reg << 21) | ((IMM) & 0xffff));}
#define LIS(REG_DST, IMM) \
{int _dst = (REG_DST); \
INSTR = (0x3C000000 | (_dst << 21) | ((IMM) & 0xffff));}
#define LWZ(REG_DST, OFFSET, REG) \
{int _reg = (REG); int _dst=(REG_DST); \
INSTR = (0x80000000 | (_dst << 21) | (_reg << 16) | ((OFFSET) & 0xffff));}
#define LWZX(REG_DST, REG, REG_OFF) \
{int _reg = (REG), _off = (REG_OFF); int _dst=(REG_DST); \
INSTR = (0x7C00002E | (_dst << 21) | (_reg << 16) | (_off << 11));}
#define LWBRX(REG_DST, REG, REG_OFF) \
{int _reg = (REG), _off = (REG_OFF); int _dst=(REG_DST); \
INSTR = (0x7C00042C | (_dst << 21) | (_reg << 16) | (_off << 11));}
#define LHZ(REG_DST, OFFSET, REG) \
{int _reg = (REG); int _dst=(REG_DST); \
INSTR = (0xA0000000 | (_dst << 21) | (_reg << 16) | ((OFFSET) & 0xffff));}
#define LHA(REG_DST, OFFSET, REG) \
{int _reg = (REG); int _dst=(REG_DST); \
INSTR = (0xA8000000 | (_dst << 21) | (_reg << 16) | ((OFFSET) & 0xffff));}
#define LHBRX(REG_DST, REG, REG_OFF) \
{int _reg = (REG), _off = (REG_OFF); int _dst=(REG_DST); \
INSTR = (0x7C00062C | (_dst << 21) | (_reg << 16) | (_off << 11));}
#define LBZ(REG_DST, OFFSET, REG) \
{int _reg = (REG); int _dst=(REG_DST); \
INSTR = (0x88000000 | (_dst << 21) | (_reg << 16) | ((OFFSET) & 0xffff));}
#define LMW(REG_DST, OFFSET, REG) \
{int _reg = (REG); int _dst=(REG_DST); \
INSTR = (0xB8000000 | (_dst << 21) | (_reg << 16) | ((OFFSET) & 0xffff));}
/* Store ops */
#define STMW(REG_SRC, OFFSET, REG) \
{int _reg = (REG), _src=(REG_SRC); \
INSTR = (0xBC000000 | (_src << 21) | (_reg << 16) | ((OFFSET) & 0xffff));}
#define STW(REG_SRC, OFFSET, REG) \
{int _reg = (REG), _src=(REG_SRC); \
INSTR = (0x90000000 | (_src << 21) | (_reg << 16) | ((OFFSET) & 0xffff));}
#define STWBRX(REG_SRC, REG, REG_OFF) \
{int _reg = (REG), _src=(REG_SRC), _off = (REG_OFF); \
INSTR = (0x7C00052C | (_src << 21) | (_reg << 16) | (_off << 11));}
#define STH(REG_SRC, OFFSET, REG) \
{int _reg = (REG), _src=(REG_SRC); \
INSTR = (0xB0000000 | (_src << 21) | (_reg << 16) | ((OFFSET) & 0xffff));}
#define STHBRX(REG_SRC, REG, REG_OFF) \
{int _reg = (REG), _src=(REG_SRC), _off = (REG_OFF); \
INSTR = (0x7C00072C | (_src << 21) | (_reg << 16) | (_off << 11));}
#define STB(REG_SRC, OFFSET, REG) \
{int _reg = (REG), _src=(REG_SRC); \
INSTR = (0x98000000 | (_src << 21) | (_reg << 16) | ((OFFSET) & 0xffff));}
#define STWU(REG_SRC, OFFSET, REG) \
{int _reg = (REG), _src=(REG_SRC); \
INSTR = (0x94000000 | (_src << 21) | (_reg << 16) | ((OFFSET) & 0xffff));}
/* Arithmic ops */
#define ADDI(REG_DST, REG_SRC, IMM) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x38000000 | (_dst << 21) | (_src << 16) | ((IMM) & 0xffff));}
#define ADDIS(REG_DST, REG_SRC, IMM) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x3C000000 | (_dst << 21) | (_src << 16) | ((IMM) & 0xffff));}
#define MR(REG_DST, REG_SRC) \
{int __src = (REG_SRC); int __dst=(REG_DST); \
if (__src != __dst) {ADDI(__dst, __src, 0)}}
#define ADD(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000214 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define ADDO(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000614 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define ADDEO(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000514 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define ADDE(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000114 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define ADDCO(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000414 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define ADDIC(REG_DST, REG_SRC, IMM) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x30000000 | (_dst << 21) | (_src << 16) | ((IMM) & 0xffff));}
#define ADDIC_(REG_DST, REG_SRC, IMM) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x34000000 | (_dst << 21) | (_src << 16) | ((IMM) & 0xffff));}
#define ADDZE(REG_DST, REG_SRC) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x7C000194 | (_dst << 21) | (_src << 16));}
#define SUBF(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000050 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define SUBFO(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000450 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define SUBFC(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000010 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define SUBFE(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000110 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define SUBFCO(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000410 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define SUBFCO_(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000411 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define SUB(REG_DST, REG1, REG2) \
{SUBF(REG_DST, REG2, REG1)}
#define SUBO(REG_DST, REG1, REG2) \
{SUBFO(REG_DST, REG2, REG1)}
#define SUBCO(REG_DST, REG1, REG2) \
{SUBFCO(REG_DST, REG2, REG1)}
#define SUBCO_(REG_DST, REG1, REG2) \
{SUBFCO_(REG_DST, REG2, REG1)}
#define SRAWI(REG_DST, REG_SRC, SHIFT) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x7C000670 | (_src << 21) | (_dst << 16) | (SHIFT << 11));}
#define MULHW(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000096 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define MULLW(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C0001D6 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define MULHWU(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000016 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define MULLI(REG_DST, REG_SRC, IMM) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x1C000000 | (_dst << 21) | (_src << 16) | ((IMM) & 0xffff));}
#define DIVW(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C0003D6 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
#define DIVWU(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000396 | (_dst << 21) | (_reg1 << 16) | (_reg2 << 11));}
/* Branch ops */
#define B_FROM(VAR) VAR = ppcPtr
#define B_DST(VAR) *VAR = *VAR | (((s16)((u32)ppcPtr - (u32)VAR)) & 0xfffc)
#define B(DST) \
{INSTR = (0x48000000 | (((s32)(((DST)+1)<<2)) & 0x3fffffc));}
#define B_L(VAR) \
{B_FROM(VAR); INSTR = (0x48000000);}
#define BA(DST) \
{INSTR = (0x48000002 | ((s32)((DST) & 0x3fffffc)));}
#define BLA(DST) \
{INSTR = (0x48000003 | ((s32)((DST) & 0x3fffffc)));}
#define BNS(DST) \
{INSTR = (0x40830000 | (((s16)(((DST)+1)<<2)) & 0xfffc));}
#define BNE(DST) \
{INSTR = (0x40820000 | (((s16)(((DST)+1)<<2)) & 0xfffc));}
#define BNE_L(VAR) \
{B_FROM(VAR); INSTR = (0x40820000);}
#define BEQ(DST) \
{INSTR = (0x41820000 | (((s16)(((DST)+1)<<2)) & 0xfffc));}
#define BEQ_L(VAR) \
{B_FROM(VAR); INSTR = (0x41820000);}
#define BLT(DST) \
{INSTR = (0x41800000 | (((s16)(((DST)+1)<<2)) & 0xfffc));}
#define BLT_L(VAR) \
{B_FROM(VAR); INSTR = (0x41800000);}
#define BGT(DST) \
{INSTR = (0x41810000 | (((s16)(((DST)+1)<<2)) & 0xfffc));}
#define BGT_L(VAR) \
{B_FROM(VAR); INSTR = (0x41810000);}
#define BGE(DST) \
{INSTR = (0x40800000 | (((s16)(((DST)+1)<<2)) & 0xfffc));}
#define BGE_L(VAR) \
{B_FROM(VAR); INSTR = (0x40800000);}
#define BLE(DST) \
{INSTR = (0x40810000 | (((s16)(((DST)+1)<<2)) & 0xfffc));}
#define BLE_L(VAR) \
{B_FROM(VAR); INSTR = (0x40810000);}
#define BCTRL() \
{INSTR = (0x4E800421);}
#define BCTR() \
{INSTR = (0x4E800420);}
/* compare ops */
#define CMPLWI(REG, IMM) \
{int _reg = (REG); \
INSTR = (0x28000000 | (_reg << 16) | ((IMM) & 0xffff));}
#define CMPLWI2(REG, IMM) \
{int _reg = (REG); \
INSTR = (0x29000000 | (_reg << 16) | ((IMM) & 0xffff));}
#define CMPLWI7(REG, IMM) \
{int _reg = (REG); \
INSTR = (0x2B800000 | (_reg << 16) | ((IMM) & 0xffff));}
#define CMPLW(REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); \
INSTR = (0x7C000040 | (_reg1 << 16) | (_reg2 << 11));}
#define CMPLW1(REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); \
INSTR = (0x7C800040 | (_reg1 << 16) | (_reg2 << 11));}
#define CMPLW2(REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); \
INSTR = (0x7D000040 | (_reg1 << 16) | (_reg2 << 11));}
#define CMPW(REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); \
INSTR = (0x7C000000 | (_reg1 << 16) | (_reg2 << 11));}
#define CMPW1(REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); \
INSTR = (0x7C800000 | (_reg1 << 16) | (_reg2 << 11));}
#define CMPW2(REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); \
INSTR = (0x7D000000 | (_reg1 << 16) | (_reg2 << 11));}
#define CMPWI(REG, IMM) \
{int _reg = (REG); \
INSTR = (0x2C000000 | (_reg << 16) | ((IMM) & 0xffff));}
#define CMPWI2(REG, IMM) \
{int _reg = (REG); \
INSTR = (0x2D000000 | (_reg << 16) | ((IMM) & 0xffff));}
#define MTCRF(MASK, REG) \
{int _reg = (REG); \
INSTR = (0x7C000120 | (_reg << 21) | (((MASK)&0xff)<<12));}
#define MFCR(REG) \
{int _reg = (REG); \
INSTR = (0x7C000026 | (_reg << 21));}
#define CROR(CR_DST, CR1, CR2) \
{INSTR = (0x4C000382 | ((CR_DST) << 21) | ((CR1) << 16) | ((CR2) << 11));}
#define CRXOR(CR_DST, CR1, CR2) \
{INSTR = (0x4C000182 | ((CR_DST) << 21) | ((CR1) << 16) | ((CR2) << 11));}
#define CRNAND(CR_DST, CR1, CR2) \
{INSTR = (0x4C0001C2 | ((CR_DST) << 21) | ((CR1) << 16) | ((CR2) << 11));}
#define CRANDC(CR_DST, CR1, CR2) \
{INSTR = (0x4C000102 | ((CR_DST) << 21) | ((CR1) << 16) | ((CR2) << 11));}
/* shift ops */
#define RLWINM(REG_DST, REG_SRC, SHIFT, START, END) \
{int _src = (REG_SRC); int _dst = (REG_DST); \
INSTR = (0x54000000 | (_src << 21) | (_dst << 16) | (SHIFT << 11) | (START << 6) | (END << 1));}
#define RLWINM_(REG_DST, REG_SRC, SHIFT, START, END) \
{int _src = (REG_SRC); int _dst = (REG_DST); \
INSTR = (0x54000001 | (_src << 21) | (_dst << 16) | (SHIFT << 11) | (START << 6) | (END << 1));}
#define CLRRWI(REG_DST, REG_SRC, LEN) \
RLWINM(REG_DST, REG_SRC, 0, 0, 31-LEN)
#define SLWI(REG_DST, REG_SRC, SHIFT) \
{int _shift = (SHIFT); \
if (_shift==0) {MR(REG_DST, REG_SRC)} else \
{RLWINM(REG_DST, REG_SRC, _shift, 0, 31-_shift)}}
#define SRWI(REG_DST, REG_SRC, SHIFT) \
{int _shift = (SHIFT); \
if (_shift==0) {MR(REG_DST, REG_SRC)} else \
RLWINM(REG_DST, REG_SRC, 32-_shift, _shift, 31)}
#define SLW(REG_DST, REG_SRC, REG_SHIFT) \
{int _src = (REG_SRC), _shift = (REG_SHIFT); int _dst = (REG_DST); \
INSTR = (0x7C000030 | (_src << 21) | (_dst << 16) | (_shift << 11));}
#define SRW(REG_DST, REG_SRC, REG_SHIFT) \
{int _src = (REG_SRC), _shift = (REG_SHIFT); int _dst = (REG_DST); \
INSTR = (0x7C000430 | (_src << 21) | (_dst << 16) | (_shift << 11));}
#define SRAW(REG_DST, REG_SRC, REG_SHIFT) \
{int _src = (REG_SRC), _shift = (REG_SHIFT); int _dst = (REG_DST); \
INSTR = (0x7C000630 | (_src << 21) | (_dst << 16) | (_shift << 11));}
#define SRAWI(REG_DST, REG_SRC, SHIFT) \
{int _src = (REG_SRC); int _dst = (REG_DST); int _shift = (SHIFT); \
if (_shift==0) {MR(REG_DST, REG_SRC)} else \
INSTR = (0x7C000670 | (_src << 21) | (_dst << 16) | (_shift << 11));}
#define RLWNM(REG_DST, REG_SRC, REG_SHIFT, START, END) \
{int _src = (REG_SRC), _shift = (REG_SHIFT); int _dst = (REG_DST); \
INSTR = (0x5C000000 | (_src << 21) | (_dst << 16) | (_shift << 11) | (START << 6) | (END << 1));}
/* other ops */
#define ORI(REG_DST, REG_SRC, IMM) \
{int _src = (REG_SRC), _imm = (IMM); int _dst = (REG_DST); \
if (!((_imm == 0) && ((_src^_dst) == 0))) \
INSTR = (0x60000000 | (_src << 21) | (_dst << 16) | (_imm & 0xffff));}
#define ORIS(REG_DST, REG_SRC, IMM) \
{int _src = (REG_SRC), _imm = (IMM); int _dst = (REG_DST); \
if (!((_imm == 0) && ((_src^_dst) == 0))) \
INSTR = (0x64000000 | (_src << 21) | (_dst << 16) | (_imm & 0xffff));}
#define OR(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000378 | (_reg1 << 21) | (_dst << 16) | (_reg2 << 11));}
#define OR_(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000379 | (_reg1 << 21) | (_dst << 16) | (_reg2 << 11));}
#define XORI(REG_DST, REG_SRC, IMM) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x68000000 | (_src << 21) | (_dst << 16) | ((IMM) & 0xffff));}
#define XOR(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000278 | (_reg1 << 21) | (_dst << 16) | (_reg2 << 11));}
#define XOR_(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000279 | (_reg1 << 21) | (_dst << 16) | (_reg2 << 11));}
#define ANDI_(REG_DST, REG_SRC, IMM) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x70000000 | (_src << 21) | (_dst << 16) | ((IMM) & 0xffff));}
#define AND(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C000038 | (_reg1 << 21) | (_dst << 16) | (_reg2 << 11));}
#define NOR(REG_DST, REG1, REG2) \
{int _reg1 = (REG1), _reg2 = (REG2); int _dst=(REG_DST); \
INSTR = (0x7C0000f8 | (_reg1 << 21) | (_dst << 16) | (_reg2 << 11));}
#define NEG(REG_DST, REG_SRC) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x7C0000D0 | (_dst << 21) | (_src << 16));}
#define NOP() \
{INSTR = 0x60000000;}
#define MCRXR(CR_DST) \
{INSTR = (0x7C000400 | (CR_DST << 23));}
#define EXTSB(REG_DST, REG_SRC) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x7C000774 | (_src << 21) | (_dst << 16));}
#define EXTSH(REG_DST, REG_SRC) \
{int _src = (REG_SRC); int _dst=(REG_DST); \
INSTR = (0x7C000734 | (_src << 21) | (_dst << 16));}
/* floating point ops */
#define FDIVS(FPR_DST, FPR1, FPR2) \
{INSTR = (0xEC000024 | (FPR_DST << 21) | (FPR1 << 16) | (FPR2 << 11));}
#define FDIV(FPR_DST, FPR1, FPR2) \
{INSTR = (0xFC000024 | (FPR_DST << 21) | (FPR1 << 16) | (FPR2 << 11));}
#define FMULS(FPR_DST, FPR1, FPR2) \
{INSTR = (0xEC000032 | (FPR_DST << 21) | (FPR1 << 16) | (FPR2 << 11));}
#define FMUL(FPR_DST, FPR1, FPR2) \
{INSTR = (0xFC000032 | (FPR_DST << 21) | (FPR1 << 16) | (FPR2 << 11));}
#define FADDS(FPR_DST, FPR1, FPR2) \
{INSTR = (0xEC00002A | (FPR_DST << 21) | (FPR1 << 16) | (FPR2 << 11));}
#define FADD(FPR_DST, FPR1, FPR2) \
{INSTR = (0xFC00002A | (FPR_DST << 21) | (FPR1 << 16) | (FPR2 << 11));}
#define FRSP(FPR_DST, FPR_SRC) \
{INSTR = (0xFC000018 | (FPR_DST << 21) | (FPR_SRC << 11));}
#define FCTIW(FPR_DST, FPR_SRC) \
{INSTR = (0xFC00001C | (FPR_DST << 21) | (FPR_SRC << 11));}
#define LFS(FPR_DST, OFFSET, REG) \
{INSTR = (0xC0000000 | (FPR_DST << 21) | (REG << 16) | ((OFFSET) & 0xffff));}
#define STFS(FPR_DST, OFFSET, REG) \
{INSTR = (0xD0000000 | (FPR_DST << 21) | (REG << 16) | ((OFFSET) & 0xffff));}
#define LFD(FPR_DST, OFFSET, REG) \
{INSTR = (0xC8000000 | (FPR_DST << 21) | (REG << 16) | ((OFFSET) & 0xffff));}
#define STFD(FPR_DST, OFFSET, REG) \
{INSTR = (0xD8000000 | (FPR_DST << 21) | (REG << 16) | ((OFFSET) & 0xffff));}
/* extra combined opcodes */
#if 1
#define LIW(REG, IMM) /* Load Immidiate Word */ \
{ \
int __reg = (REG); u32 __imm = (u32)(IMM); \
if ((s32)__imm == (s32)((s16)__imm)) \
{ \
LI(__reg, (s32)((s16)__imm)); \
} else if (__reg == 0) { \
LIS(__reg, (((u32)__imm)>>16)); \
if ((((u32)__imm) & 0xffff) != 0) \
{ \
ORI(__reg, __reg, __imm); \
} \
} else { \
if ((((u32)__imm) & 0xffff) == 0) { \
LIS(__reg, (((u32)__imm)>>16)); \
} else { \
LI(__reg, __imm); \
if ((__imm & 0x8000) == 0) { \
ADDIS(__reg, __reg, ((u32)__imm)>>16); \
} else { \
ADDIS(__reg, __reg, ((((u32)__imm)>>16) & 0xffff) + 1); \
} \
} \
/*if ((((u32)__imm) & 0xffff) != 0) \
{ \
ORI(__reg, __reg, __imm); \
}*/ \
} \
}
#else
#define LIW(REG, IMM) /* Load Immidiate Word */ \
{ \
int __reg = (REG); u32 __imm = (u32)(IMM); \
if ((s32)__imm == (s32)((s16)__imm)) \
{ \
LI(__reg, (s32)((s16)__imm)); \
} \
else \
{ \
LIS(__reg, (((u32)__imm)>>16)); \
if ((((u32)__imm) & 0xffff) != 0) \
{ \
ORI(__reg, __reg, __imm); \
} \
} \
}
#endif

419
libpcsxcore/ppc/reguse.c Normal file
View File

@ -0,0 +1,419 @@
#include "../psxcommon.h"
#include "reguse.h"
#include "../r3000a.h"
//#define SAME_CYCLE_MODE
static const int useBSC[64] = {
/*recSPECIAL*/ REGUSE_SUB | REGUSE_SPECIAL,
/*recREGIMM*/ REGUSE_SUB | REGUSE_REGIMM,
/*recJ*/ REGUSE_JUMP,
/*recJAL*/ REGUSE_JUMP | REGUSE_R31_W,
/*recBEQ*/ REGUSE_BRANCH | REGUSE_RS_R | REGUSE_RT_R,
/*recBNE*/ REGUSE_BRANCH | REGUSE_RS_R | REGUSE_RT_R,
/*recBLEZ*/ REGUSE_BRANCH | REGUSE_RS_R,
/*recBGTZ*/ REGUSE_BRANCH | REGUSE_RS_R,
/*recADDI*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_W,
/*recADDIU*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_W,
/*recSLTI*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_W,
/*recSLTIU*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_W,
/*recANDI*/ REGUSE_LOGIC | REGUSE_RS_R | REGUSE_RT_W,
/*recORI*/ REGUSE_LOGIC | REGUSE_RS_R | REGUSE_RT_W,
/*recXORI*/ REGUSE_LOGIC | REGUSE_RS_R | REGUSE_RT_W,
/*recLUI*/ REGUSE_ACC | REGUSE_RT_W,
/*recCOP0*/ REGUSE_SUB | REGUSE_COP0,
REGUSE_NONE,
/*recCOP2*/ REGUSE_SUB | REGUSE_COP2,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
/*recLB*/ REGUSE_MEM_R | REGUSE_RS_R | REGUSE_RT_W,
/*recLH*/ REGUSE_MEM_R | REGUSE_RS_R | REGUSE_RT_W,
/*recLWL*/ REGUSE_MEM_R | REGUSE_RS_R | REGUSE_RT,
/*recLW*/ REGUSE_MEM_R | REGUSE_RS_R | REGUSE_RT_W,
/*recLBU*/ REGUSE_MEM_R | REGUSE_RS_R | REGUSE_RT_W,
/*recLHU*/ REGUSE_MEM_R | REGUSE_RS_R | REGUSE_RT_W,
/*recLWR*/ REGUSE_MEM_R | REGUSE_RS_R | REGUSE_RT,
REGUSE_NONE,
/*recSB*/ REGUSE_MEM_W | REGUSE_RS_R | REGUSE_RT_R,
/*recSH*/ REGUSE_MEM_W | REGUSE_RS_R | REGUSE_RT_R,
/*recSWL*/ REGUSE_MEM | REGUSE_RS_R | REGUSE_RT_R,
/*recSW*/ REGUSE_MEM_W | REGUSE_RS_R | REGUSE_RT_R,
REGUSE_NONE, REGUSE_NONE,
/*recSWR*/ REGUSE_MEM | REGUSE_RS_R | REGUSE_RT_R,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
/*recLWC2*/ REGUSE_MEM_R | REGUSE_RS_R | REGUSE_COP2_RT_W,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE,
/*recSWC2*/ REGUSE_MEM_W | REGUSE_RS_R | REGUSE_COP2_RT_R,
/*recHLE*/ REGUSE_UNKNOWN, // TODO: can this be done in a better way
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE
};
static const int useSPC[64] = {
/*recSLL*/ REGUSE_ACC | REGUSE_RT_R | REGUSE_RD_W,
REGUSE_NONE,
/*recSRL*/ REGUSE_ACC | REGUSE_RT_R | REGUSE_RD_W,
/*recSRA*/ REGUSE_ACC | REGUSE_RT_R | REGUSE_RD_W,
/*recSLLV*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
REGUSE_NONE,
/*recSRLV*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
/*recSRAV*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
/*recJR*/ REGUSE_JUMPR | REGUSE_RS_R,
/*recJALR*/ REGUSE_JUMPR | REGUSE_RS_R | REGUSE_RD_W,
REGUSE_NONE, REGUSE_NONE,
/*rSYSCALL*/ REGUSE_SYS | REGUSE_PC | REGUSE_COP0_STATUS | REGUSE_EXCEPTION,
/*recBREAK*/ REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE,
/*recMFHI*/ REGUSE_LOGIC | REGUSE_RD_W | REGUSE_HI_R,
/*recMTHI*/ REGUSE_LOGIC | REGUSE_RS_R | REGUSE_HI_W,
/*recMFLO*/ REGUSE_LOGIC | REGUSE_RD_W | REGUSE_LO_R,
/*recMTLO*/ REGUSE_LOGIC | REGUSE_RS_R | REGUSE_LO_W,
REGUSE_NONE, REGUSE_NONE , REGUSE_NONE, REGUSE_NONE,
/*recMULT*/ REGUSE_MULT | REGUSE_RS_R | REGUSE_RT_R | REGUSE_LO_W | REGUSE_HI_W,
/*recMULTU*/ REGUSE_MULT | REGUSE_RS_R | REGUSE_RT_R | REGUSE_LO_W | REGUSE_HI_W,
/*recDIV*/ REGUSE_MULT | REGUSE_RS_R | REGUSE_RT_R | REGUSE_LO_W | REGUSE_HI_W,
/*recDIVU*/ REGUSE_MULT | REGUSE_RS_R | REGUSE_RT_R | REGUSE_LO_W | REGUSE_HI_W,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
/*recADD*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
/*recADDU*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
/*recSUB*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
/*recSUBU*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
/*recAND*/ REGUSE_LOGIC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
/*recOR*/ REGUSE_LOGIC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
/*recXOR*/ REGUSE_LOGIC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
/*recNOR*/ REGUSE_LOGIC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
REGUSE_NONE, REGUSE_NONE,
/*recSLT*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
/*recSLTU*/ REGUSE_ACC | REGUSE_RS_R | REGUSE_RT_R | REGUSE_RD_W,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE
};
static const int useREGIMM[32] = {
/*recBLTZ*/ REGUSE_BRANCH | REGUSE_RS_R,
/*recBGEZ*/ REGUSE_BRANCH | REGUSE_RS_R,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE,
/*recBLTZAL*/REGUSE_BRANCH | REGUSE_RS_R | REGUSE_R31_W,
/*recBGEZAL*/REGUSE_BRANCH | REGUSE_RS_R | REGUSE_R31_W,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE
};
static const int useCP0[32] = {
/*recMFC0*/ REGUSE_LOGIC | REGUSE_RT_W | REGUSE_COP0_RD_R,
REGUSE_NONE,
/*recCFC0*/ REGUSE_LOGIC | REGUSE_RT_W | REGUSE_COP0_RD_R,
REGUSE_NONE,
/*recMTC0*/ REGUSE_LOGIC | REGUSE_RT_R | REGUSE_COP0_RD_W,
REGUSE_NONE,
/*recCTC0*/ REGUSE_LOGIC | REGUSE_RT_R | REGUSE_COP0_RD_W,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
/*recRFE*/ REGUSE_LOGIC | REGUSE_COP0_STATUS,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE
};
// TODO: make more explicit
static const int useCP2[64] = {
/*recBASIC*/ REGUSE_SUB | REGUSE_BASIC,
/*recRTPS*/ REGUSE_GTE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
/*recNCLIP*/ REGUSE_GTE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
/*recOP*/ REGUSE_GTE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
/*recDPCS*/ REGUSE_GTE,
/*recINTPL*/ REGUSE_GTE,
/*recMVMVA*/ REGUSE_GTE,
/*recNCDS*/ REGUSE_GTE,
/*recCDP*/ REGUSE_GTE,
REGUSE_NONE,
/*recNCDT*/ REGUSE_GTE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
/*recNCCS*/ REGUSE_GTE,
/*recCC*/ REGUSE_GTE,
REGUSE_NONE,
/*recNCS*/ REGUSE_GTE,
REGUSE_NONE,
/*recNCT*/ REGUSE_GTE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE,
/*recSQR*/ REGUSE_GTE,
/*recDCPL*/ REGUSE_GTE,
/*recDPCT*/ REGUSE_GTE,
REGUSE_NONE, REGUSE_NONE,
/*recAVSZ3*/ REGUSE_GTE,
/*recAVSZ4*/ REGUSE_GTE,
REGUSE_NONE,
/*recRTPT*/ REGUSE_GTE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE, REGUSE_NONE,
/*recGPF*/ REGUSE_GTE,
/*recGPL*/ REGUSE_GTE,
/*recNCCT*/ REGUSE_GTE
};
static const int useCP2BSC[32] = {
/*recMFC2*/ REGUSE_LOGIC | REGUSE_RT_W | REGUSE_COP2_RD_R,
REGUSE_NONE,
/*recCFC2*/ REGUSE_LOGIC | REGUSE_RT_W | REGUSE_COP2_RD_R,
REGUSE_NONE,
/*recMTC2*/ REGUSE_LOGIC | REGUSE_RT_R | REGUSE_COP2_RD_W,
REGUSE_NONE,
/*recCTC2*/ REGUSE_LOGIC | REGUSE_RT_R | REGUSE_COP2_RD_W,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE,
REGUSE_NONE
};
static int getRegUse(u32 code) __attribute__ ((__pure__));
static int getRegUse(u32 code)
{
int use = useBSC[code>>26];
switch (use & REGUSE_SUBMASK) {
case REGUSE_NONE:
break;
case REGUSE_SPECIAL:
use = useSPC[_fFunct_(code)];
break;
case REGUSE_REGIMM:
use = useREGIMM[_fRt_(code)];
break;
case REGUSE_COP0:
use = useCP0[_fRs_(code)];
break;
case REGUSE_COP2:
use = useCP2[_fFunct_(code)];
if ((use & REGUSE_SUBMASK) == REGUSE_BASIC)
use = useCP2BSC[_fRs_(code)];
break;
default:
use = REGUSE_UNKNOWN;
break;
}
if ((use & REGUSE_COP0_RD_W)) {
if (_fRd_(code) == 12 || _fRd_(code) == 13) {
use = REGUSE_UNKNOWN;
}
}
return use;
}
/* returns how psxreg is used in the code instruction */
int useOfPsxReg(u32 code, int use, int psxreg)
{
int retval = REGUSE_NONE;
// get use if it wasn't supplied
if (-1 == use) use = getRegUse(code);
// if we don't know what the usage is, assume it's read from
if (REGUSE_UNKNOWN == use) return REGUSE_READ;
if (psxreg < 32) {
// check for 3 standard types
if ((use & REGUSE_RT) && _fRt_(code) == (u32)psxreg) {
retval |= ((use & REGUSE_RT_R) ? REGUSE_READ:0) | ((use & REGUSE_RT_W) ? REGUSE_WRITE:0);
}
if ((use & REGUSE_RS) && _fRs_(code) == (u32)psxreg) {
retval |= ((use & REGUSE_RS_R) ? REGUSE_READ:0) | ((use & REGUSE_RS_W) ? REGUSE_WRITE:0);
}
if ((use & REGUSE_RD) && _fRd_(code) == (u32)psxreg) {
retval |= ((use & REGUSE_RD_R) ? REGUSE_READ:0) | ((use & REGUSE_RD_W) ? REGUSE_WRITE:0);
}
// some instructions explicitly writes to r31
if ((use & REGUSE_R31_W) && 31 == psxreg) {
retval |= REGUSE_WRITE;
}
} else if (psxreg == 32) { // Special register LO
retval |= ((use & REGUSE_LO_R) ? REGUSE_READ:0) | ((use & REGUSE_LO_W) ? REGUSE_WRITE:0);
} else if (psxreg == 33) { // Special register HI
retval |= ((use & REGUSE_HI_R) ? REGUSE_READ:0) | ((use & REGUSE_HI_W) ? REGUSE_WRITE:0);
}
return retval;
}
//#define NOREGUSE_FOLLOW
static int _nextPsxRegUse(u32 pc, int psxreg, int numInstr) __attribute__ ((__pure__, __unused__));
static int _nextPsxRegUse(u32 pc, int psxreg, int numInstr)
{
u32 *ptr, code, bPC = 0;
int i, use, reguse = 0;
for (i=0; i<numInstr; ) {
// load current instruction
ptr = PSXM(pc);
if (ptr==NULL) {
// going nowhere... might as well assume a write, since we will hopefully never reach here
reguse = REGUSE_WRITE;
break;
}
code = SWAP32(*ptr);
// get usage patterns for instruction
use = getRegUse(code);
// find the use of psxreg in the instruction
reguse = useOfPsxReg(code, use, psxreg);
// return if we have found a use
if (reguse != REGUSE_NONE)
break;
// goto next instruction
pc += 4;
i++;
// check for code branches/jumps
if (i != numInstr) {
if ((use & REGUSE_TYPEM) == REGUSE_BRANCH) {
#ifndef NOREGUSE_FOLLOW
// check delay slot
reguse = _nextPsxRegUse(pc, psxreg, 1);
if (reguse != REGUSE_NONE) break;
bPC = _fImm_(code) * 4 + pc;
reguse = _nextPsxRegUse(pc+4, psxreg, (numInstr-i-1)/2);
if (reguse != REGUSE_NONE) {
int reguse2 = _nextPsxRegUse(bPC, psxreg, (numInstr-i-1)/2);
if (reguse2 != REGUSE_NONE)
reguse |= reguse2;
else
reguse = REGUSE_NONE;
}
#endif
break;
} else if ((use & REGUSE_TYPEM) == REGUSE_JUMP) {
#ifndef NOREGUSE_FOLLOW
// check delay slot
reguse = _nextPsxRegUse(pc, psxreg, 1);
if (reguse != REGUSE_NONE) break;
bPC = _fTarget_(code) * 4 + (pc & 0xf0000000);
reguse = _nextPsxRegUse(bPC, psxreg, numInstr-i-1);
#endif
break;
} else if ((use & REGUSE_TYPEM) == REGUSE_JUMPR) {
#ifndef NOREGUSE_FOLLOW
// jump to unknown location - bail after checking delay slot
reguse = _nextPsxRegUse(pc, psxreg, 1);
#endif
break;
} else if ((use & REGUSE_TYPEM) == REGUSE_SYS) {
break;
}
}
}
return reguse;
}
int nextPsxRegUse(u32 pc, int psxreg)
{
#if 1
if (psxreg == 0)
return REGUSE_WRITE; // pretend we are writing to it to fool compiler
#ifdef SAME_CYCLE_MODE
return REGUSE_READ;
#else
return _nextPsxRegUse(pc, psxreg, 80);
#endif
#else
u32 code, bPC = 0;
int use, reguse = 0, reguse1 = 0, b = 0, i, index = 0;
retry:
for (i=index; i<80; i++) {
code = PSXMu32(pc);
use = getRegUse(code);
reguse = useOfPsxReg(code, use, psxreg);
if (reguse != REGUSE_NONE) break;
pc += 4;
if ((use & REGUSE_TYPEM) == REGUSE_BRANCH) {
if (b == 0) {
bPC = _fImm_(code) * 4 + pc;
index = i+1;
}
b += 1; // TODO: follow branches
continue;
} else if ((use & REGUSE_TYPEM) == REGUSE_JUMP) {
if (b == 0) {
bPC = _fTarget_(code) * 4 + (pc & 0xf0000000);
}
b = 2;
continue;
} else if ((use & REGUSE_TYPEM) == REGUSE_JUMPR ||
(use & REGUSE_TYPEM) == REGUSE_SYS) {
b = 2;
continue;
}
if (b == 2 && bPC && index == 0) {
pc = bPC; bPC = 0;
b = 1;
}
if (b >= 2) break; // only follow 1 branch
}
if (reguse == REGUSE_NONE) return reguse;
if (bPC) {
reguse1 = reguse;
pc = bPC; bPC = 0;
b = 1;
goto retry;
}
return reguse1 | reguse;
#endif
}
int isPsxRegUsed(u32 pc, int psxreg)
{
int use = nextPsxRegUse(pc, psxreg);
if (use == REGUSE_NONE)
return 2; // unknown use - assume it is used
else if (use & REGUSE_READ)
return 1; // the next use is a read
else
return 0; // the next use is a write, i.e. current value is not important
}

83
libpcsxcore/ppc/reguse.h Normal file
View File

@ -0,0 +1,83 @@
#ifndef __REGUSE_H__
#define __REGUSE_H__
#ifdef __cplusplus
extern "C" {
#endif
// include basic types
#include "../psxcommon.h"
#define REGUSE_NONE 0x0000
#define REGUSE_UNKNOWN 0x0001
//sub functions
#define REGUSE_SPECIAL 0x0002
#define REGUSE_REGIMM 0x0004
#define REGUSE_COP0 0x0006
#define REGUSE_COP2 0x0008
#define REGUSE_BASIC 0x000a
#define REGUSE_SUBMASK 0x000e /* sub function mask */
#define REGUSE_ACC 0x0010 /* accumulator */
#define REGUSE_LOGIC 0x0020 /* logic operations */
#define REGUSE_MULT 0x0030 /* multiplier */
#define REGUSE_JUMP 0x0040 /* jump to dest */
#define REGUSE_JUMPR 0x0050 /* jump to reg */
#define REGUSE_BRANCH 0x0060 /* branch */
#define REGUSE_MEM_R 0x0070 /* read from memory */
#define REGUSE_MEM_W 0x0080 /* write to memory */
#define REGUSE_MEM 0x0090 /* read and write to memory */
#define REGUSE_SYS 0x00a0 /* syscall */
#define REGUSE_GTE 0x00b0 /* gte operation */
#define REGUSE_SUB 0x00f0 /* sub usage */
#define REGUSE_TYPEM 0x00f0 /* type mask */
#define REGUSE_RS_R 0x0100
#define REGUSE_RS_W 0x0200
#define REGUSE_RS (REGUSE_RS_R | REGUSE_RS_W)
#define REGUSE_RT_R 0x0400
#define REGUSE_RT_W 0x0800
#define REGUSE_RT (REGUSE_RT_R | REGUSE_RT_W)
#define REGUSE_RD_R 0x1000
#define REGUSE_RD_W 0x2000
#define REGUSE_RD (REGUSE_RD_R | REGUSE_RD_W)
#define REGUSE_R31_W 0x4000 /* writes to link register (r31) */
#define REGUSE_PC 0x8000 /* reads pc */
#define REGUSE_LO_R 0x10000
#define REGUSE_LO_W 0x20000
#define REGUSE_LO (REGUSE_LO_R | REGUSE_LO_W)
#define REGUSE_HI_R 0x40000
#define REGUSE_HI_W 0x80000
#define REGUSE_HI (REGUSE_HI_R | REGUSE_HI_W)
#define REGUSE_COP0_RD_R 0x100000
#define REGUSE_COP0_RD_W 0x200000
#define REGUSE_COP0_RD (REGUSE_COP0_RD_R | REGUSE_COP0_RD_W)
#define REGUSE_COP0_STATUS 0x400000
#define REGUSE_EXCEPTION 0x800000
#define REGUSE_COP2_RT_R 0x1000000
#define REGUSE_COP2_RT_W 0x2000000
#define REGUSE_COP2_RT (REGUSE_COP2_RT_R | REGUSE_COP2_RT_W)
#define REGUSE_COP2_RD_R 0x4000000
#define REGUSE_COP2_RD_W 0x8000000
#define REGUSE_COP2_RD (REGUSE_COP2_RD_R | REGUSE_COP2_RD_W)
// specific register use
#define REGUSE_READ 1
#define REGUSE_WRITE 2
#define REGUSE_RW 3
int useOfPsxReg(u32 code, int use, int psxreg) __attribute__ ((__pure__));;
int nextPsxRegUse(u32 pc, int psxreg) __attribute__ ((__pure__));;
int isPsxRegUsed(u32 pc, int psxreg) __attribute__ ((__pure__));;
#ifdef __cplusplus
}
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More