This commit was manufactured by cvs2svn to create tag
'release_0_5_0'.
This commit is contained in:
parent
01cf7ba067
commit
e2afa9be4b
|
@ -0,0 +1,21 @@
|
|||
Original author
|
||||
---------------
|
||||
yopyop
|
||||
|
||||
Current team
|
||||
------------
|
||||
Allustar
|
||||
amponzi
|
||||
ape
|
||||
delfare
|
||||
Guillaume Duhamel
|
||||
Normmatt
|
||||
Romain Vallet
|
||||
shash
|
||||
Theo Berkau
|
||||
thoduv
|
||||
|
||||
Contributors
|
||||
------------
|
||||
Anthony Molinaro
|
||||
Mighty Max
|
|
@ -0,0 +1,340 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, 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., 59 Temple Place, Suite 330, 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.
|
|
@ -0,0 +1,59 @@
|
|||
0.3.3 -> 0.5.0
|
||||
arm:
|
||||
- Fixed MSR with immediate value opcode.
|
||||
- Fixed LSR_0 thumb opcode (C flag is correctly set now).
|
||||
- Fixed LDR*/STR* opcodes.
|
||||
- Fixed unaligned memory access on THUMB Core.
|
||||
- Added relocating SWI routines.
|
||||
bios:
|
||||
- Added decompression functions.
|
||||
- Added GetPitchTable function.
|
||||
- Added GetVolumeTable function.
|
||||
- Added GetCRC16 function.
|
||||
- Added experimental SoundBias function.
|
||||
- Added GetSineTable function.
|
||||
cart:
|
||||
- Added CompactFlash/FAT emulation.
|
||||
- Added Get ROM chip ID Cartridge command.
|
||||
gpu:
|
||||
- Added framebuffer emulation.
|
||||
- Fixed a bug in GPU (xfin could be greater than LG causing a segfault).
|
||||
- Added support for Display Mode 0(Display Off).
|
||||
- Added the basic framework for Display Mode 3(Display from Main RAM).
|
||||
spu:
|
||||
- Added sound emulation.
|
||||
- Added sound core system.
|
||||
- Added WAV write core.
|
||||
- Added dummy core.
|
||||
- Added Direct Sound core.
|
||||
linux port:
|
||||
- Added GTK+ GUI.
|
||||
- Added command line interface.
|
||||
- Added stylus and arm9 keypad support in CLI version.
|
||||
- Added FPS display.
|
||||
- Added basic frameskip.
|
||||
windows port:
|
||||
- Fixed a bug when displaying a ROM's information.
|
||||
- Added key configuration.
|
||||
- Removed the debug key.
|
||||
- Added new experimental auto frameskip/frame limit code.
|
||||
- Added sound settings dialog.
|
||||
- Added a few menu options for accessing the website, forums, and for
|
||||
submitting bugs.
|
||||
general:
|
||||
- Rewrote code in C.
|
||||
- Fixed warnings.
|
||||
- Used defines and typedef's to make things more portable and easier to
|
||||
read.
|
||||
- Added autotools stuff.
|
||||
- Changes to logging system.
|
||||
- Added screenshot function.
|
||||
- Translated most french to english.
|
||||
- Added savestate support.
|
||||
- Added firmware reading support(needs work).
|
||||
- Added Backup Memory support with autodetection.
|
||||
- Fixed some endianess issues.
|
||||
- Fixed things so Visual C++ can compile code.
|
||||
- Added bsd support.
|
||||
- Reworked ROM loading so you can load a different rom without any problems.
|
||||
- Finished NDS_Reset. Now the emulation can be reset even while running.
|
|
@ -0,0 +1 @@
|
|||
SUBDIRS = src
|
|
@ -0,0 +1,68 @@
|
|||
DeSmuME
|
||||
_________________________________________
|
||||
Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2006 DeSmuME team
|
||||
|
||||
|
||||
1) Introduction.............................................13
|
||||
2) Staff/Thanks.............................................36
|
||||
3) Contact information......................................72
|
||||
4) Disclaimer...............................................82
|
||||
|
||||
|
||||
1 Introduction________________________________________________
|
||||
|
||||
DeSmuME is a Nintendo DS emulator under GNU GPL.
|
||||
|
||||
DeSmuME can boot homebrew and games, some of which are
|
||||
playable.
|
||||
|
||||
For installation/how to use informations, check the ports
|
||||
specific README files:
|
||||
|
||||
* README.LIN for the linux port
|
||||
* README.WIN for the windows port
|
||||
|
||||
|
||||
2 Staff/Thanks________________________________________________
|
||||
|
||||
See the AUTHORS file for team members list.
|
||||
|
||||
Thanks to:
|
||||
|
||||
* yopyop (original author of DeSMUME),
|
||||
for releasing the source code of this great emulator.
|
||||
|
||||
* Martin Korth (author of GBATEK),
|
||||
for his well-written Gameboy Advance and Nintendo DS
|
||||
documentation.
|
||||
|
||||
|
||||
3 Contact information_________________________________________
|
||||
|
||||
E-mail: guillaume.duhamel@gmail.com
|
||||
Web: http://desmume.sourceforge.net
|
||||
IRC: irc://irc.freenode.net/desmume
|
||||
|
||||
Please don't ask for roms, bios files or any other
|
||||
copyrighted stuff.
|
||||
|
||||
|
||||
4 Disclaimer__________________________________________________
|
||||
|
||||
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., 59 Temple Place, Suite 330, Boston,
|
||||
MA 02111-1307 USA
|
||||
|
||||
See the GNU General Public License details in COPYING.
|
|
@ -0,0 +1,86 @@
|
|||
DeSmuME
|
||||
_________________________________________
|
||||
Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2006 DeSmuME team
|
||||
|
||||
|
||||
1) Compiling instructions...................................13
|
||||
2) How to use DeSmuME.......................................36
|
||||
3) Contact information......................................50
|
||||
4) Disclaimer...............................................69
|
||||
|
||||
|
||||
1 Compiling instructions______________________________________
|
||||
|
||||
Yabause is written in C using the gtk+ and SDL libraries.
|
||||
So you need a working C compiler, such as gcc and
|
||||
the above libraries runtime and development packages:
|
||||
|
||||
* http://www.gtk.org
|
||||
|
||||
* http://www.libsdl.org/
|
||||
|
||||
Once these libraries are installed, you should be ready to
|
||||
install DeSmuME.
|
||||
|
||||
Uncompress the DeSmuME. source archive, move to the newly
|
||||
created directory, type "./configure", then "make",
|
||||
it will generate two programs: "desmume" in the "src/gtk"
|
||||
directory and "desmume-cli" in the "src/cli" directory.
|
||||
|
||||
You can even type "make install" to install those programs on
|
||||
your system (in /usr/local/ by default), then uninstalling is
|
||||
done by typing "make uninstall".
|
||||
|
||||
|
||||
2 How to use DeSmuME__________________________________________
|
||||
|
||||
2.1 Gtk+ version______________________________________________
|
||||
|
||||
Type "desmume" in a shell, a window should appear, then open
|
||||
a rom file using the "open" button, next use the "run" button
|
||||
to start emulation.
|
||||
|
||||
|
||||
2.2 CLI version_______________________________________________
|
||||
|
||||
Just type "desmume-cli path-to-a-rom" in a shell.
|
||||
|
||||
|
||||
3 Contact information_________________________________________
|
||||
|
||||
General inquiries should go to:
|
||||
E-mail: guillaume.duhamel@gmail.com
|
||||
E-mail: cwx@cyberwarriorx.com
|
||||
|
||||
Linux Port-related inquiries should go to:
|
||||
E-mail: guillaume.duhamel@gmail.com
|
||||
|
||||
Web: http://desmume.sourceforge.net
|
||||
|
||||
Please don't ask for roms, bios files or any other copyrighted
|
||||
stuff.
|
||||
|
||||
If you want to submit a bug report, please run desmume, go into
|
||||
the "Help" menu, and click on "Submit a bug report". If you're
|
||||
having trouble with it, please feel free to email.
|
||||
|
||||
|
||||
4 Disclaimer__________________________________________________
|
||||
|
||||
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., 59 Temple Place, Suite 330, Boston,
|
||||
MA 02111-1307 USA
|
||||
|
||||
See the GNU General Public License details in COPYING.
|
|
@ -0,0 +1,133 @@
|
|||
DeSmuME
|
||||
_________________________________________
|
||||
Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2006 DeSmuME team
|
||||
|
||||
|
||||
1) Compiling instructions...................................13
|
||||
2) How to use DeSmuME.......................................37
|
||||
3) Contact information......................................97
|
||||
4) Disclaimer..............................................116
|
||||
|
||||
|
||||
1 Compiling instructions______________________________________
|
||||
|
||||
DeSmuME is written in C, so you need a working C compiler(such
|
||||
as mingw). Other supported compilers include Visual C++ 2005 and
|
||||
dev-cpp.
|
||||
|
||||
mingw:
|
||||
All you have to do now is go into your mingw shell
|
||||
environment, go into the directory where you extracted DeSmuME,
|
||||
and type: "./configure". Once that's done(and there was no
|
||||
errors), type: "make". It should now take some time to compile so
|
||||
go grab yourself a sandwich or beer - whatever suits your fancy
|
||||
and it should be done in a few minutes. Now all you have to do is
|
||||
type "./src/desmume" in order to run it.
|
||||
|
||||
dev-cpp:
|
||||
Load the project file DeSmuME.dev in the src/windows directory,
|
||||
compile, and you're set.
|
||||
|
||||
Visual C++:
|
||||
Load the project file DeSmuME.vcproj in the src/windows directory,
|
||||
compile, and you're set.
|
||||
|
||||
|
||||
2 How to use DeSmuME__________________________________________
|
||||
|
||||
Execute "desmume". A new window should pop up. The default
|
||||
settings should be fine for most people, but in case you need to
|
||||
adjust them, here's a brief explanation:
|
||||
|
||||
Under the "Config", there are a number of items:
|
||||
|
||||
Save Type:
|
||||
Here you can select which type of Backup Memory DeSmuME should
|
||||
emulate. By default, Autodetect works fine, but in some cases
|
||||
DeSmuME doesn't correctly detect the Backup Memory. In that
|
||||
case, you will want to select the correct one.
|
||||
|
||||
Control Config:
|
||||
Here you can change the default key mappings. For now only the
|
||||
keyboard is supported, but in the near future gamepads and
|
||||
joysticks will be supported.
|
||||
|
||||
Here are the default key mappings(they may be subject to change):
|
||||
Up arrow - Up
|
||||
Left arrow - Left
|
||||
Down arrow - Down
|
||||
right arrow - Right
|
||||
v - A button
|
||||
b - B button
|
||||
g - X button
|
||||
h - Y button
|
||||
c - Left Trigger
|
||||
n - Right Trigger
|
||||
enter - Start button
|
||||
space - Select button
|
||||
|
||||
Sound Settings:
|
||||
Here you can change the default sound settings. By default
|
||||
DeSmuME uses Direct Sound, a buffer size of 2940, and
|
||||
volume set to max. But if you want to mute the sound, you can
|
||||
set the sound core to none. Or if you want to save the sound
|
||||
to a file, you can set the sound core to WAV write. If you find
|
||||
the sound is crackling a lot, try increasing the buffer size. On
|
||||
the other hand, if you find the sound somewhat delayed or jumpy,
|
||||
try decreasing the buffer size.
|
||||
|
||||
Frame Skip:
|
||||
Here you can adjust the amount of frame draws to skip during
|
||||
emulation. Normally the emulator detects whether the emulator
|
||||
is running too fast or slow and skips a frame or more if it
|
||||
needs to speed things up. However some people don't like the
|
||||
results of it, so here you can adjust that.
|
||||
|
||||
After all the settings are set to your satisfaction, you can then
|
||||
load a ROM image by going into the "File" menu, and choosing
|
||||
"Open". Select which file you'd like to open, and the emulator
|
||||
will automatically load and start running the selected ROM.
|
||||
|
||||
You can save the current emulation state by press shift + one of
|
||||
the twelve F keys. To load, just press one of the twelve F keys
|
||||
(without shift pressed).
|
||||
|
||||
|
||||
3 Contact information_________________________________________
|
||||
|
||||
General inquiries should go to:
|
||||
E-mail: guillaume.duhamel@gmail.com
|
||||
E-mail: cwx@cyberwarriorx.com
|
||||
|
||||
Windows Port-related inquiries should go to:
|
||||
E-mail: cwx@cyberwarriorx.com
|
||||
|
||||
Web: http://desmume.sourceforge.net
|
||||
|
||||
Please don't ask for roms, bios files or any other copyrighted
|
||||
stuff.
|
||||
|
||||
If you want to submit a bug report, please run desmume, go into
|
||||
the "Help" menu, and click on "Submit a bug report". If you're
|
||||
having trouble with it, please feel free to email.
|
||||
|
||||
|
||||
4 Disclaimer__________________________________________________
|
||||
|
||||
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., 59 Temple Place, Suite 330, Boston,
|
||||
MA 02111-1307 USA
|
||||
|
||||
See the GNU General Public License details in COPYING.
|
|
@ -0,0 +1,38 @@
|
|||
# -*-shell-script-*-
|
||||
|
||||
[Meta]
|
||||
RootName: @desmume.sf.net/desmume:$SOFTWAREVERSION
|
||||
DisplayName: DeSmuME Nintendo DS Emulator
|
||||
ShortName: desmume
|
||||
Maintainer: Guillaume Duhamel <guillaume.duhamel@gmail.com>
|
||||
Packager: Guillaume Duhamel <guillaume.duhamel@gmail.com>
|
||||
Summary: DeSmuME is a Nintendo DS emulator.
|
||||
URL: http://desmume.sf.net/
|
||||
License: GNU General Public License, Version 2
|
||||
SoftwareVersion: @VERSION@
|
||||
AutopackageTarget: 1.0
|
||||
|
||||
[Description]
|
||||
This is a Nintendo DS emulator.
|
||||
|
||||
[BuildPrepare]
|
||||
prepareBuild
|
||||
|
||||
[BuildUnprepare]
|
||||
unprepareBuild
|
||||
|
||||
[Imports]
|
||||
echo '*' | import
|
||||
|
||||
[Prepare]
|
||||
# Dependency checking
|
||||
require @gtk.org/gtk 2.4
|
||||
|
||||
[Install]
|
||||
# Put your installation script here
|
||||
installExe bin/desmume
|
||||
installExe bin/desmume-cli
|
||||
|
||||
[Uninstall]
|
||||
# Usually just the following line is enough to uninstall everything
|
||||
uninstallFromLog
|
|
@ -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:
|
|
@ -0,0 +1,116 @@
|
|||
dnl --- Package name is first argument to AC_INIT
|
||||
dnl --- Release version is second argument to AC_INIT
|
||||
|
||||
AC_INIT(desmume, [0.5.0])
|
||||
AM_INIT_AUTOMAKE
|
||||
|
||||
dnl -- find target architecture for some os specific libraries
|
||||
AC_CANONICAL_TARGET
|
||||
case $target in
|
||||
*linux*) desmume_arch=linux;;
|
||||
*mingw*) desmume_arch=windows;;
|
||||
*darwin*) desmume_arch=linux;;
|
||||
*bsd*) desmume_arch=linux;;
|
||||
esac
|
||||
AC_SUBST(desmume_arch)
|
||||
|
||||
dnl -- make sure we have a C++ compiler
|
||||
AC_PROG_CXX
|
||||
|
||||
dnl -- use ranlib for libraries
|
||||
AC_PROG_RANLIB
|
||||
|
||||
dnl -- check for endianess
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
dnl --- Other prerequisites ---
|
||||
|
||||
dnl - Check for zlib
|
||||
AC_CHECK_LIB(z, gzopen)
|
||||
|
||||
dnl - Check for SDL
|
||||
AC_PATH_PROGS(SDLCONFIG, [sdl-config sdl11-config])
|
||||
if test ! "x$SDLCONFIG" = "x" ; then
|
||||
SDL_CFLAGS=`$SDLCONFIG --cflags`
|
||||
SDL_LIBS=`$SDLCONFIG --libs`
|
||||
AC_SUBST(SDL_CFLAGS)
|
||||
AC_SUBST(SDL_LIBS)
|
||||
HAVE_SDL="yes"
|
||||
else
|
||||
HAVE_SDL="no"
|
||||
fi
|
||||
|
||||
dnl - Check for GTK
|
||||
AC_CHECK_TOOL(HAVE_PKG, pkg-config)
|
||||
if test ! "x$HAVE_PKG" = "x" ; then
|
||||
PKG_CHECK_MODULES(GTK,
|
||||
"gtk+-2.0",
|
||||
HAVE_GTK=yes,
|
||||
HAVE_GTK=no)
|
||||
AC_SUBST(GTK_CFLAGS)
|
||||
AC_SUBST(GTK_LIBS)
|
||||
fi
|
||||
|
||||
dnl - Determine which UI's to build
|
||||
if test "x$HAVE_SDL" = "xyes"; then
|
||||
# SDL adds just a cli
|
||||
UI_DIR="cli $UI_DIR"
|
||||
if test "x$HAVE_GTK" = "xyes"; then
|
||||
# GTK requires SDL
|
||||
UI_DIR="gtk $UI_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
case $target in
|
||||
*mingw*)
|
||||
LIBS="$LIBS -ldxguid -ldxerr8 -ldsound -mwindows"
|
||||
UI_DIR="windows"
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(UI_DIR)
|
||||
|
||||
|
||||
dnl - Compiler warnings
|
||||
|
||||
# for developer use, enable lots of compile warnings,
|
||||
# but don't require this generally, because some system's
|
||||
# header files (BSD) can't handle it
|
||||
#
|
||||
# NB: must add -Werror after AC_PROG_CC, etc., so do this last
|
||||
AC_ARG_ENABLE(hardcore,
|
||||
[ --enable-hardcore turn on -W -Wall -Werror],
|
||||
[case "${enableval}" in
|
||||
yes) ENABLE_HARDCORE=1 ;;
|
||||
no) ENABLE_HARDCORE=0 ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-hardcore) ;; esac],
|
||||
[ENABLE_HARDCORE=0])
|
||||
|
||||
if test "x[$]ENABLE_HARDCORE" = "x1"; then
|
||||
AC_MSG_WARN(enable hardcore compile warnings)
|
||||
if test "x$CXX" = "x"; then
|
||||
dnl - only valid for C with newer gcc's
|
||||
CPPFLAGS="[$]CPPFLAGS -Wmissing-prototypes"
|
||||
fi
|
||||
CPPFLAGS="[$]CPPFLAGS -Werror -W -Wall -Wpointer-arith -Wcast-align -Wwrite-strings"
|
||||
fi
|
||||
|
||||
dnl - Enable debug mode
|
||||
AC_ARG_ENABLE(debug,
|
||||
AC_HELP_STRING(--enable-debug, enable debug information),
|
||||
AC_DEFINE(DEBUG))
|
||||
|
||||
dnl -- set maintainer mode
|
||||
AM_MAINTAINER_MODE
|
||||
AC_SUBST(USE_MAINTAINER_MODE)
|
||||
|
||||
|
||||
dnl --- Finally, output all the makefiles
|
||||
AC_CONFIG_FILES([Makefile
|
||||
src/Makefile
|
||||
src/cli/Makefile
|
||||
src/gtk/Makefile
|
||||
src/windows/Makefile
|
||||
autopackage/default.apspec
|
||||
])
|
||||
AC_OUTPUT
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef ARM9_H
|
||||
#define ARM9_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef struct {
|
||||
//ARM9 mem
|
||||
u8 ARM9_ITCM[0x8000];
|
||||
u8 ARM9_DTCM[0x4000];
|
||||
u8 ARM9_WRAM[0x1000000];
|
||||
u8 MAIN_MEM[0x400000];
|
||||
u8 ARM9_REG[0x1000000];
|
||||
u8 ARM9_BIOS[0x8000];
|
||||
u8 ARM9_VMEM[0x800];
|
||||
u8 ARM9_ABG[0x80000];
|
||||
u8 ARM9_BBG[0x20000];
|
||||
u8 ARM9_AOBJ[0x40000];
|
||||
u8 ARM9_BOBJ[0x20000];
|
||||
u8 ARM9_LCD[0xA4000];
|
||||
u8 ARM9_OAM[0x800];
|
||||
|
||||
u8 * ExtPal[2][4];
|
||||
u8 * ObjExtPal[2][2];
|
||||
u8 * texPalSlot[4];
|
||||
} ARM9_struct;
|
||||
|
||||
extern ARM9_struct ARM9Mem;
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,40 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef DISASSEMBLER_H
|
||||
#define DISASSEMBLER_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern char * (* des_arm_instructions_set[4096])(u32 adr, u32 i, char * txt);
|
||||
extern char * (* des_thumb_instructions_set[1024])(u32 adr, u32 i, char * txt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "FIFO.h"
|
||||
|
||||
void FIFOInit(FIFO * fifo)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
fifo->begin = 0;
|
||||
fifo->end = 0;
|
||||
for(i = 0; i<0x2000; ++i)
|
||||
fifo->data[i] = 0;
|
||||
fifo->full = FALSE;
|
||||
fifo->empty = TRUE;
|
||||
fifo->error = FALSE;
|
||||
}
|
||||
|
||||
void FIFOAdd(FIFO * fifo, u32 v)
|
||||
{
|
||||
if(fifo->full)
|
||||
{
|
||||
fifo->error = TRUE;
|
||||
return;
|
||||
}
|
||||
fifo->data[fifo->end] = v;
|
||||
fifo->end = (fifo->end + 1)& 0x1FFF;
|
||||
fifo->full = (fifo->end == fifo->begin);
|
||||
fifo->empty = FALSE;
|
||||
}
|
||||
|
||||
u32 FIFOValue(FIFO * fifo)
|
||||
{
|
||||
u32 v;
|
||||
|
||||
if(fifo->empty)
|
||||
{
|
||||
fifo->error = TRUE;
|
||||
return 0;
|
||||
}
|
||||
v = fifo->data[fifo->begin];
|
||||
fifo->begin = (fifo->begin + 1)& 0x1FFF;
|
||||
fifo->empty = (fifo->begin == fifo->end);
|
||||
return v;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef FIFO_H
|
||||
#define FIFO_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 data[0x2000];
|
||||
u32 begin;
|
||||
u32 end;
|
||||
BOOL full;
|
||||
BOOL empty;
|
||||
BOOL error;
|
||||
} FIFO;
|
||||
|
||||
void FIFOInit(FIFO * fifo);
|
||||
void FIFOAdd(FIFO * fifo, u32 v);
|
||||
u32 FIFOValue(FIFO * fifo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,235 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
Copyright (C) 2006 Theo Berkau
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef GPU_H
|
||||
#define GPU_H
|
||||
|
||||
#include "ARM9.h"
|
||||
#include <stdio.h>
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define GPU_MAIN 0
|
||||
#define GPU_SUB 1
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u16 attr0;
|
||||
u16 attr1;
|
||||
u16 attr2;
|
||||
u16 attr3;
|
||||
} OAM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
s16 x;
|
||||
s16 y;
|
||||
} size;
|
||||
|
||||
typedef struct _GPU GPU;
|
||||
|
||||
struct _GPU
|
||||
{
|
||||
//GPU(u8 l);
|
||||
|
||||
u32 prop;
|
||||
|
||||
u16 BGProp[4];
|
||||
|
||||
#define BGBmpBB BG_bmp_ram
|
||||
#define BGChBB BG_tile_ram
|
||||
|
||||
u8 *(BG_bmp_ram[4]);
|
||||
u8 *(BG_tile_ram[4]);
|
||||
u8 *(BG_map_ram[4]);
|
||||
|
||||
u8 BGExtPalSlot[4];
|
||||
u32 BGSize[4][2];
|
||||
u16 BGSX[4];
|
||||
u16 BGSY[4];
|
||||
|
||||
s32 BGX[4];
|
||||
s32 BGY[4];
|
||||
s16 BGPA[4];
|
||||
s16 BGPB[4];
|
||||
s16 BGPC[4];
|
||||
s16 BGPD[4];
|
||||
|
||||
u8 lcd;
|
||||
u8 core;
|
||||
|
||||
u8 dispMode;
|
||||
u8 vramBlock;
|
||||
|
||||
u8 nbBGActif;
|
||||
u8 BGIndex[4];
|
||||
u8 ordre[4];
|
||||
BOOL dispBG[4];
|
||||
|
||||
OAM * oam;
|
||||
u8 * sprMem;
|
||||
u8 sprBlock;
|
||||
u8 sprBMPBlock;
|
||||
u8 sprBMPMode;
|
||||
|
||||
void (*spriteRender)(GPU * gpu, u16 l, u8 * dst, u8 * prioTab);
|
||||
};
|
||||
|
||||
extern u8 GPU_screen[4*256*192];
|
||||
|
||||
GPU * GPU_Init(u8 l);
|
||||
void GPU_Reset(GPU *g, u8 l);
|
||||
void GPU_DeInit(GPU *);
|
||||
|
||||
void textBG(GPU * gpu, u8 num, u8 * DST);
|
||||
void rotBG(GPU * gpu, u8 num, u8 * DST);
|
||||
void extRotBG(GPU * gpu, u8 num, u8 * DST);
|
||||
void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab);
|
||||
void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab);
|
||||
|
||||
extern short sizeTab[4][4][2];
|
||||
extern size sprSizeTab[4][4];
|
||||
extern s8 mode2type[8][4];
|
||||
extern void (*modeRender[8][4])(GPU * gpu, u8 num, u16 l, u8 * DST);
|
||||
|
||||
typedef struct {
|
||||
GPU * gpu;
|
||||
u16 offset;
|
||||
} Screen;
|
||||
|
||||
extern Screen MainScreen;
|
||||
extern Screen SubScreen;
|
||||
|
||||
void Screen_Init(void);
|
||||
void Screen_Reset(void);
|
||||
void Screen_DeInit(void);
|
||||
|
||||
static INLINE void GPU_ligne(Screen * screen, u16 l)
|
||||
{
|
||||
GPU * gpu = screen->gpu;
|
||||
u8 * dst = GPU_screen + (screen->offset + l) * 512;
|
||||
u8 spr[512];
|
||||
u8 sprPrio[256];
|
||||
u8 bgprio;
|
||||
int i;
|
||||
u8 i8;
|
||||
u16 i16;
|
||||
u32 c;
|
||||
|
||||
// This could almost be changed to use function pointers
|
||||
switch (gpu->dispMode)
|
||||
{
|
||||
case 1: // Display BG and OBJ layers
|
||||
break;
|
||||
case 0: // Display Off(Display white)
|
||||
{
|
||||
for (i=0; i<256; i++)
|
||||
{
|
||||
T2WriteWord(dst, i << 1, 0x7FFF);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 2: // Display framebuffer
|
||||
{
|
||||
int ii = l * 256 * 2;
|
||||
for (i=0; i<(256 * 2); i+=2)
|
||||
{
|
||||
u8 * vram = ARM9Mem.ARM9_LCD + (gpu->vramBlock * 0x20000);
|
||||
|
||||
T2WriteWord(dst, i, T1ReadWord(vram, ii));
|
||||
ii+=2;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 3: // Display from Main RAM(FIX ME)
|
||||
return;
|
||||
}
|
||||
|
||||
c = T1ReadWord(ARM9Mem.ARM9_VMEM, gpu->lcd * 0x400);
|
||||
c |= (c<<16);
|
||||
|
||||
for(i8 = 0; i8< 128; ++i8)
|
||||
{
|
||||
T2WriteLong(dst, i8 << 2, c);
|
||||
T2WriteLong(spr, i8 << 2, c);
|
||||
T1WriteWord(sprPrio, i8 << 1, (4 << 8) | (4));
|
||||
}
|
||||
|
||||
if(!gpu->nbBGActif)
|
||||
{
|
||||
gpu->spriteRender(gpu, l, dst, sprPrio);
|
||||
return;
|
||||
}
|
||||
|
||||
gpu->spriteRender(gpu, l, spr, sprPrio);
|
||||
|
||||
if((gpu->BGProp[gpu->ordre[0]]&3)!=3)
|
||||
{
|
||||
for(i16 = 0; i16 < 128; ++i16) {
|
||||
T2WriteLong(dst, i16 << 2, T2ReadLong(spr, i16 << 2));
|
||||
}
|
||||
}
|
||||
|
||||
for(i8 = 0; i8 < gpu->nbBGActif; ++i8)
|
||||
{
|
||||
modeRender[gpu->prop&7][gpu->ordre[i8]](gpu, gpu->ordre[i8], l, dst);
|
||||
bgprio = gpu->BGProp[gpu->ordre[i8]]&3;
|
||||
for(i16 = 0; i16 < 256; ++i16)
|
||||
if(bgprio>=sprPrio[i16])
|
||||
T2WriteWord(dst, i16 << 1, T2ReadWord(spr, i16 << 1));
|
||||
}
|
||||
}
|
||||
|
||||
void GPU_setVideoProp(GPU *, u32 p);
|
||||
void GPU_setBGProp(GPU *, u16 num, u16 p);
|
||||
void GPU_scrollX(GPU *, u8 num, u16 v);
|
||||
void GPU_scrollY(GPU *, u8 num, u16 v);
|
||||
void GPU_scrollXY(GPU *, u8 num, u32 v);
|
||||
|
||||
void GPU_setX(GPU *, u8 num, u32 v);
|
||||
void GPU_setXH(GPU *, u8 num, u16 v);
|
||||
void GPU_setXL(GPU *, u8 num, u16 v);
|
||||
void GPU_setY(GPU *, u8 num, u32 v);
|
||||
void GPU_setYH(GPU *, u8 num, u16 v);
|
||||
void GPU_setYL(GPU *, u8 num, u16 v);
|
||||
void GPU_setPA(GPU *, u8 num, u16 v);
|
||||
void GPU_setPB(GPU *, u8 num, u16 v);
|
||||
void GPU_setPC(GPU *, u8 num, u16 v);
|
||||
void GPU_setPD(GPU *, u8 num, u16 v);
|
||||
void GPU_setPAPB(GPU *, u8 num, u32 v);
|
||||
void GPU_setPCPD(GPU *, u8 num, u32 v);
|
||||
|
||||
void GPU_remove(GPU *, u8 num);
|
||||
void GPU_addBack(GPU *, u8 num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,130 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef MMU_H
|
||||
#define MMU_H
|
||||
|
||||
#include "FIFO.h"
|
||||
#include "dscard.h"
|
||||
|
||||
#include "ARM9.h"
|
||||
#include "mc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern char szRomPath[512];
|
||||
extern char szRomBaseName[512];
|
||||
|
||||
/* theses macros are designed for reading/writing in memory (m is a pointer to memory, like MMU.MMU_MEM[proc], and a is an adress, like 0x04000000 */
|
||||
#define MEM_8(m, a) (((u8*)(m[((a)>>20)&0xff]))[((a)&0xfff)])
|
||||
|
||||
/* theses ones for reading in rom data */
|
||||
#define ROM_8(m, a) (((u8*)(m))[(a)])
|
||||
|
||||
#define IPCFIFO 0
|
||||
|
||||
typedef struct {
|
||||
//ARM7 mem
|
||||
u8 ARM7_BIOS[0x4000];
|
||||
u8 ARM7_ERAM[0x10000];
|
||||
u8 ARM7_REG[0x10000];
|
||||
u8 ARM7_WIRAM[0x10000];
|
||||
|
||||
//Shared ram
|
||||
u8 SWIRAM[0x8000];
|
||||
|
||||
//Card rom & ram
|
||||
u8 * CART_ROM;
|
||||
u8 CART_RAM[0x10000];
|
||||
|
||||
//Unused ram
|
||||
u8 UNUSED_RAM[4];
|
||||
|
||||
u8 * * MMU_MEM[2];
|
||||
u32 * MMU_MASK[2];
|
||||
|
||||
u8 ARM9_RW_MODE;
|
||||
|
||||
FIFO fifos[16];
|
||||
|
||||
u32 * MMU_WAIT16[2];
|
||||
u32 * MMU_WAIT32[2];
|
||||
|
||||
u32 DTCMRegion;
|
||||
u32 ITCMRegion;
|
||||
|
||||
u16 timer[2][4];
|
||||
s32 timerMODE[2][4];
|
||||
u32 timerON[2][4];
|
||||
u32 timerRUN[2][4];
|
||||
u16 timerReload[2][4];
|
||||
|
||||
u32 reg_IME[2];
|
||||
u32 reg_IE[2];
|
||||
u32 reg_IF[2];
|
||||
|
||||
u32 DMAStartTime[2][4];
|
||||
s32 DMACycle[2][4];
|
||||
u32 DMACrt[2][4];
|
||||
BOOL DMAing[2][4];
|
||||
|
||||
memory_chip_t fw;
|
||||
memory_chip_t bupmem;
|
||||
|
||||
nds_dscard dscard[2];
|
||||
|
||||
} MMU_struct;
|
||||
|
||||
extern MMU_struct MMU;
|
||||
|
||||
void MMUInit(void);
|
||||
void MMUDeInit(void);
|
||||
|
||||
void MMU_clearMem();
|
||||
|
||||
void MMU_setRom(u8 * rom, u32 mask);
|
||||
void MMU_unsetRom();
|
||||
|
||||
#define MMU_readByte MMU_read8
|
||||
#define MMU_readHWord MMU_read16
|
||||
#define MMU_readWord MMU_read32
|
||||
|
||||
u8 FASTCALL MMU_read8(u32 proc, u32 adr);
|
||||
u16 FASTCALL MMU_read16(u32 proc, u32 adr);
|
||||
u32 FASTCALL MMU_read32(u32 proc, u32 adr);
|
||||
|
||||
#define MMU_writeByte MMU_write8
|
||||
#define MMU_writeHWord MMU_write16
|
||||
#define MMU_writeWord MMU_write32
|
||||
|
||||
void FASTCALL MMU_write8(u32 proc, u32 adr, u8 val);
|
||||
void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val);
|
||||
void FASTCALL MMU_write32(u32 proc, u32 adr, u32 val);
|
||||
|
||||
void FASTCALL MMU_doDMA(u32 proc, u32 num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,17 @@
|
|||
SUBDIRS = . $(UI_DIR)
|
||||
noinst_LIBRARIES = libdesmume.a
|
||||
libdesmume_a_SOURCES = \
|
||||
armcpu.c armcpu.h ARM9.h \
|
||||
arm_instructions.c arm_instructions.h \
|
||||
bios.c bios.h cp15.c cp15.h \
|
||||
cflash.c cflash.h fs.h \
|
||||
debug.c debug.h \
|
||||
Disassembler.c Disassembler.h \
|
||||
FIFO.c FIFO.h \
|
||||
GPU.c GPU.h \
|
||||
mc.c mc.h \
|
||||
MMU.c MMU.h NDSSystem.c NDSSystem.h registers.h \
|
||||
saves.c saves.h \
|
||||
SPU.c SPU.h \
|
||||
thumb_instructions.c thumb_instructions.h
|
||||
libdesmume_a_LIBADD = fs-$(desmume_arch).$(OBJEXT)
|
|
@ -0,0 +1,536 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "NDSSystem.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
NDSSystem nds;
|
||||
|
||||
int NDS_Init(void) {
|
||||
nds.ARM9Cycle = 0;
|
||||
nds.ARM7Cycle = 0;
|
||||
nds.cycles = 0;
|
||||
MMU_Init();
|
||||
nds.nextHBlank = 3168;
|
||||
nds.VCount = 0;
|
||||
nds.lignerendu = FALSE;
|
||||
|
||||
Screen_Init();
|
||||
|
||||
armcpu_new(&NDS_ARM7,1);
|
||||
armcpu_new(&NDS_ARM9,0);
|
||||
|
||||
if (SPU_Init(SNDCORE_DUMMY, 735) != 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NDS_DeInit(void) {
|
||||
if(MMU.CART_ROM != MMU.UNUSED_RAM)
|
||||
NDS_FreeROM();
|
||||
|
||||
nds.nextHBlank = 3168;
|
||||
SPU_DeInit();
|
||||
Screen_DeInit();
|
||||
MMU_DeInit();
|
||||
}
|
||||
|
||||
BOOL NDS_SetROM(u8 * rom, u32 mask)
|
||||
{
|
||||
MMU_setRom(rom, mask);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NDS_header * NDS_getROMHeader(void)
|
||||
{
|
||||
NDS_header * header = malloc(sizeof(NDS_header));
|
||||
|
||||
memcpy(header->gameTile, MMU.CART_ROM, 12);
|
||||
memcpy(header->gameCode, MMU.CART_ROM + 12, 4);
|
||||
header->makerCode = T1ReadWord(MMU.CART_ROM, 16);
|
||||
header->unitCode = MMU.CART_ROM[18];
|
||||
header->deviceCode = MMU.CART_ROM[19];
|
||||
header->cardSize = MMU.CART_ROM[20];
|
||||
memcpy(header->cardInfo, MMU.CART_ROM + 21, 8);
|
||||
header->flags = MMU.CART_ROM[29];
|
||||
header->ARM9src = T1ReadLong(MMU.CART_ROM, 32);
|
||||
header->ARM9exe = T1ReadLong(MMU.CART_ROM, 36);
|
||||
header->ARM9cpy = T1ReadLong(MMU.CART_ROM, 40);
|
||||
header->ARM9binSize = T1ReadLong(MMU.CART_ROM, 44);
|
||||
header->ARM7src = T1ReadLong(MMU.CART_ROM, 48);
|
||||
header->ARM7exe = T1ReadLong(MMU.CART_ROM, 52);
|
||||
header->ARM7cpy = T1ReadLong(MMU.CART_ROM, 56);
|
||||
header->ARM7binSize = T1ReadLong(MMU.CART_ROM, 60);
|
||||
header->FNameTblOff = T1ReadLong(MMU.CART_ROM, 64);
|
||||
header->FNameTblSize = T1ReadLong(MMU.CART_ROM, 68);
|
||||
header->FATOff = T1ReadLong(MMU.CART_ROM, 72);
|
||||
header->FATSize = T1ReadLong(MMU.CART_ROM, 76);
|
||||
header->ARM9OverlayOff = T1ReadLong(MMU.CART_ROM, 80);
|
||||
header->ARM9OverlaySize = T1ReadLong(MMU.CART_ROM, 84);
|
||||
header->ARM7OverlayOff = T1ReadLong(MMU.CART_ROM, 88);
|
||||
header->ARM7OverlaySize = T1ReadLong(MMU.CART_ROM, 92);
|
||||
header->unknown2a = T1ReadLong(MMU.CART_ROM, 96);
|
||||
header->unknown2b = T1ReadLong(MMU.CART_ROM, 100);
|
||||
header->IconOff = T1ReadLong(MMU.CART_ROM, 104);
|
||||
header->CRC16 = T1ReadWord(MMU.CART_ROM, 108);
|
||||
header->ROMtimeout = T1ReadWord(MMU.CART_ROM, 110);
|
||||
header->ARM9unk = T1ReadLong(MMU.CART_ROM, 112);
|
||||
header->ARM7unk = T1ReadLong(MMU.CART_ROM, 116);
|
||||
memcpy(header->unknown3c, MMU.CART_ROM + 120, 8);
|
||||
header->ROMSize = T1ReadLong(MMU.CART_ROM, 128);
|
||||
header->HeaderSize = T1ReadLong(MMU.CART_ROM, 132);
|
||||
memcpy(header->unknown5, MMU.CART_ROM + 136, 56);
|
||||
memcpy(header->logo, MMU.CART_ROM + 192, 156);
|
||||
header->logoCRC16 = T1ReadWord(MMU.CART_ROM, 348);
|
||||
header->headerCRC16 = T1ReadWord(MMU.CART_ROM, 350);
|
||||
memcpy(header->reserved, MMU.CART_ROM + 352, 160);
|
||||
|
||||
return header;
|
||||
|
||||
//return (NDS_header *)MMU.CART_ROM;
|
||||
}
|
||||
|
||||
void NDS_setTouchPos(u16 x, u16 y)
|
||||
{
|
||||
nds.touchX = (x <<4);
|
||||
nds.touchY = (y <<4);
|
||||
|
||||
MMU.ARM7_REG[0x136] &= 0xBF;
|
||||
}
|
||||
|
||||
void NDS_releasTouch(void)
|
||||
{
|
||||
nds.touchX = 0;
|
||||
nds.touchY = 0;
|
||||
|
||||
MMU.ARM7_REG[0x136] |= 0x40;
|
||||
}
|
||||
|
||||
void debug()
|
||||
{
|
||||
//if(NDS_ARM9.R[15]==0x020520DC) execute = FALSE;
|
||||
//DSLinux
|
||||
//if(NDS_ARM9.CPSR.bits.mode == 0) execute = FALSE;
|
||||
//if((NDS_ARM9.R[15]&0xFFFFF000)==0) execute = FALSE;
|
||||
//if((NDS_ARM9.R[15]==0x0201B4F4)/*&&(NDS_ARM9.R[1]==0x0)*/) execute = FALSE;
|
||||
//AOE
|
||||
//if((NDS_ARM9.R[15]==0x01FFE194)&&(NDS_ARM9.R[0]==0)) execute = FALSE;
|
||||
//if((NDS_ARM9.R[15]==0x01FFE134)&&(NDS_ARM9.R[0]==0)) execute = FALSE;
|
||||
|
||||
//BBMAN
|
||||
//if(NDS_ARM9.R[15]==0x02098B4C) execute = FALSE;
|
||||
//if(NDS_ARM9.R[15]==0x02004924) execute = FALSE;
|
||||
//if(NDS_ARM9.R[15]==0x02004890) execute = FALSE;
|
||||
|
||||
//if(NDS_ARM9.R[15]==0x0202B800) execute = FALSE;
|
||||
//if(NDS_ARM9.R[15]==0x0202B3DC) execute = FALSE;
|
||||
//if((NDS_ARM9.R[1]==0x9AC29AC1)&&(!fait)) {execute = FALSE;fait = TRUE;}
|
||||
//if(NDS_ARM9.R[1]==0x0400004A) {execute = FALSE;fait = TRUE;}
|
||||
/*if(NDS_ARM9.R[4]==0x2E33373C) execute = FALSE;
|
||||
if(NDS_ARM9.R[15]==0x02036668) //execute = FALSE;
|
||||
{
|
||||
nds.logcount++;
|
||||
sprintf(logbuf, "%d %08X", nds.logcount, NDS_ARM9.R[13]);
|
||||
log::ajouter(logbuf);
|
||||
if(nds.logcount==89) execute=FALSE;
|
||||
}*/
|
||||
//if(NDS_ARM9.instruction==0) execute = FALSE;
|
||||
//if((NDS_ARM9.R[15]>>28)) execute = FALSE;
|
||||
}
|
||||
|
||||
#define DSGBA_EXTENSTION ".ds.gba"
|
||||
#define DSGBA_LOADER_SIZE 512
|
||||
enum
|
||||
{
|
||||
ROM_NDS = 0,
|
||||
ROM_DSGBA
|
||||
};
|
||||
|
||||
int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize)
|
||||
{
|
||||
int i;
|
||||
int type;
|
||||
const char *p = filename;
|
||||
FILE *file;
|
||||
u32 size, mask;
|
||||
u8 *data;
|
||||
|
||||
if (filename == NULL)
|
||||
return -1;
|
||||
|
||||
type = ROM_NDS;
|
||||
|
||||
p += strlen(p);
|
||||
p -= strlen(DSGBA_EXTENSTION);
|
||||
|
||||
if(memcmp(p, DSGBA_EXTENSTION, strlen(DSGBA_EXTENSTION)) == 0)
|
||||
type = ROM_DSGBA;
|
||||
|
||||
if ((file = fopen(filename, "rb")) == NULL)
|
||||
return -1;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
if(type == ROM_DSGBA)
|
||||
{
|
||||
fseek(file, DSGBA_LOADER_SIZE, SEEK_SET);
|
||||
size -= DSGBA_LOADER_SIZE;
|
||||
}
|
||||
|
||||
mask = size;
|
||||
mask |= (mask >>1);
|
||||
mask |= (mask >>2);
|
||||
mask |= (mask >>4);
|
||||
mask |= (mask >>8);
|
||||
mask |= (mask >>16);
|
||||
|
||||
// Make sure old ROM is freed first(at least this way we won't be eating
|
||||
// up a ton of ram before the old ROM is freed)
|
||||
if(MMU.CART_ROM != MMU.UNUSED_RAM)
|
||||
NDS_FreeROM();
|
||||
|
||||
if ((data = (u8*)malloc(mask + 1)) == NULL)
|
||||
{
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
i = fread(data, 1, size, file);
|
||||
|
||||
fclose(file);
|
||||
|
||||
MMU_unsetRom();
|
||||
NDS_SetROM(data, mask);
|
||||
NDS_Reset();
|
||||
|
||||
/* I guess any directory can be used
|
||||
* so the current one should be ok */
|
||||
strcpy(szRomPath, ".");
|
||||
cflash_close();
|
||||
cflash_init();
|
||||
|
||||
strcpy(szRomBaseName, filename);
|
||||
|
||||
if(type == ROM_DSGBA)
|
||||
szRomBaseName[strlen(szRomBaseName)-strlen(DSGBA_EXTENSTION)] = 0x00;
|
||||
else
|
||||
szRomBaseName[strlen(szRomBaseName)-4] = 0x00;
|
||||
|
||||
// Setup Backup Memory
|
||||
p = strdup(filename);
|
||||
|
||||
if(type == ROM_DSGBA)
|
||||
strcpy(p+strlen(p)-strlen(DSGBA_EXTENSTION), ".sav");
|
||||
else
|
||||
strcpy(p+strlen(p)-4, ".sav");
|
||||
|
||||
mc_realloc(&MMU.bupmem, bmtype, bmsize);
|
||||
mc_load_file(&MMU.bupmem, p);
|
||||
free(p);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void NDS_FreeROM(void)
|
||||
{
|
||||
if (MMU.CART_ROM != MMU.UNUSED_RAM)
|
||||
free(MMU.CART_ROM);
|
||||
MMU_unsetRom();
|
||||
if (MMU.bupmem.fp)
|
||||
fclose(MMU.bupmem.fp);
|
||||
MMU.bupmem.fp = NULL;
|
||||
}
|
||||
|
||||
void NDS_Reset(void)
|
||||
{
|
||||
BOOL oldexecute=execute;
|
||||
int i;
|
||||
u32 src;
|
||||
u32 dst;
|
||||
NDS_header * header = NDS_getROMHeader();
|
||||
|
||||
execute = FALSE;
|
||||
|
||||
MMU_clearMem();
|
||||
|
||||
src = header->ARM9src;
|
||||
dst = header->ARM9cpy;
|
||||
|
||||
for(i = 0; i < (header->ARM9binSize>>2); ++i)
|
||||
{
|
||||
MMU_writeWord(0, dst, T1ReadLong(MMU.CART_ROM, src));
|
||||
dst += 4;
|
||||
src += 4;
|
||||
}
|
||||
|
||||
src = header->ARM7src;
|
||||
dst = header->ARM7cpy;
|
||||
|
||||
for(i = 0; i < (header->ARM7binSize>>2); ++i)
|
||||
{
|
||||
MMU_writeWord(1, dst, T1ReadLong(MMU.CART_ROM, src));
|
||||
dst += 4;
|
||||
src += 4;
|
||||
}
|
||||
|
||||
armcpu_init(&NDS_ARM7, header->ARM7exe);
|
||||
armcpu_init(&NDS_ARM9, header->ARM9exe);
|
||||
|
||||
nds.ARM9Cycle = 0;
|
||||
nds.ARM7Cycle = 0;
|
||||
nds.cycles = 0;
|
||||
memset(nds.timerCycle, 0, sizeof(s32) * 2 * 4);
|
||||
memset(nds.timerOver, 0, sizeof(BOOL) * 2 * 4);
|
||||
nds.nextHBlank = 3168;
|
||||
nds.VCount = 0;
|
||||
nds.old = 0;
|
||||
nds.diff = 0;
|
||||
nds.lignerendu = FALSE;
|
||||
nds.touchX = nds.touchY = 0;
|
||||
|
||||
MMU_writeHWord(0, 0x04000130, 0x3FF);
|
||||
MMU_writeHWord(1, 0x04000130, 0x3FF);
|
||||
MMU_writeByte(1, 0x04000136, 0x43);
|
||||
|
||||
MMU_writeByte(0, 0x027FFCDC, 0x20);
|
||||
MMU_writeByte(0, 0x027FFCDD, 0x20);
|
||||
MMU_writeByte(0, 0x027FFCE2, 0xE0);
|
||||
MMU_writeByte(0, 0x027FFCE3, 0x80);
|
||||
|
||||
MMU_writeHWord(0, 0x027FFCD8, 0x20<<4);
|
||||
MMU_writeHWord(0, 0x027FFCDA, 0x20<<4);
|
||||
MMU_writeHWord(0, 0x027FFCDE, 0xE0<<4);
|
||||
MMU_writeHWord(0, 0x027FFCE0, 0x80<<4);
|
||||
|
||||
MMU_writeWord(0, 0x027FFE40, 0xE188);
|
||||
MMU_writeWord(0, 0x027FFE44, 0x9);
|
||||
MMU_writeWord(0, 0x027FFE48, 0xE194);
|
||||
MMU_writeWord(0, 0x027FFE4C, 0x0);
|
||||
// logcount = 0;
|
||||
|
||||
MMU_writeByte(0, 0x023FFC80, 1);
|
||||
MMU_writeByte(0, 0x023FFC82, 10);
|
||||
MMU_writeByte(0, 0x023FFC83, 7);
|
||||
MMU_writeByte(0, 0x023FFC84, 15);
|
||||
|
||||
MMU_writeHWord(0, 0x023FFC86, 'y');
|
||||
MMU_writeHWord(0, 0x023FFC88, 'o');
|
||||
MMU_writeHWord(0, 0x023FFC8A, 'p');
|
||||
MMU_writeHWord(0, 0x023FFC8C, 'y');
|
||||
MMU_writeHWord(0, 0x023FFC8E, 'o');
|
||||
MMU_writeHWord(0, 0x023FFC90, 'p');
|
||||
MMU_writeHWord(0, 0x023FFC9A, 6);
|
||||
|
||||
MMU_writeHWord(0, 0x023FFC9C, 'H');
|
||||
MMU_writeHWord(0, 0x023FFC9E, 'i');
|
||||
MMU_writeHWord(0, 0x023FFCA0, ',');
|
||||
MMU_writeHWord(0, 0x023FFCA2, 'i');
|
||||
MMU_writeHWord(0, 0x023FFCA4, 't');
|
||||
MMU_writeHWord(0, 0x023FFCA6, '\'');
|
||||
MMU_writeHWord(0, 0x023FFCA8, 's');
|
||||
MMU_writeHWord(0, 0x023FFCAA, ' ');
|
||||
MMU_writeHWord(0, 0x023FFCAC, 'm');
|
||||
MMU_writeHWord(0, 0x023FFCAE, 'e');
|
||||
MMU_writeHWord(0, 0x023FFCB0, '!');
|
||||
MMU_writeHWord(0, 0x023FFCD0, 11);
|
||||
|
||||
MMU_writeHWord(0, 0x023FFCE4, 2);
|
||||
|
||||
MMU_writeWord(0, 0x027FFE40, header->FNameTblOff);
|
||||
MMU_writeWord(0, 0x027FFE44, header->FNameTblSize);
|
||||
MMU_writeWord(0, 0x027FFE48, header->FATOff);
|
||||
MMU_writeWord(0, 0x027FFE4C, header->FATSize);
|
||||
|
||||
MMU_writeWord(0, 0x027FFE50, header->ARM9OverlayOff);
|
||||
MMU_writeWord(0, 0x027FFE54, header->ARM9OverlaySize);
|
||||
MMU_writeWord(0, 0x027FFE58, header->ARM7OverlayOff);
|
||||
MMU_writeWord(0, 0x027FFE5C, header->ARM7OverlaySize);
|
||||
|
||||
MMU_writeWord(0, 0x027FFE60, header->unknown2a);
|
||||
MMU_writeWord(0, 0x027FFE64, header->unknown2b); //merci <20>EACKiX
|
||||
|
||||
MMU_writeWord(0, 0x027FFE70, header->ARM9unk);
|
||||
MMU_writeWord(0, 0x027FFE74, header->ARM7unk);
|
||||
|
||||
MMU_writeWord(0, 0x027FFF9C, 0x027FFF90); // ?????? besoin d'avoir la vrai valeur sur ds
|
||||
|
||||
MainScreen.offset = 192;
|
||||
SubScreen.offset = 0;
|
||||
|
||||
//MMU_writeWord(0, 0x02007FFC, 0xE92D4030);
|
||||
|
||||
//ARM7 BIOS IRQ HANDLER
|
||||
MMU_writeWord(1, 0x00, 0xE25EF002);
|
||||
MMU_writeWord(1, 0x04, 0xEAFFFFFE);
|
||||
MMU_writeWord(1, 0x18, 0xEA000000);
|
||||
MMU_writeWord(1, 0x20, 0xE92D500F);
|
||||
MMU_writeWord(1, 0x24, 0xE3A00301);
|
||||
MMU_writeWord(1, 0x28, 0xE28FE000);
|
||||
MMU_writeWord(1, 0x2C, 0xE510F004);
|
||||
MMU_writeWord(1, 0x30, 0xE8BD500F);
|
||||
MMU_writeWord(1, 0x34, 0xE25EF004);
|
||||
|
||||
//ARM9 BIOS IRQ HANDLER
|
||||
MMU_writeWord(0, 0xFFF0018, 0xEA000000);
|
||||
MMU_writeWord(0, 0xFFF0020, 0xE92D500F);
|
||||
MMU_writeWord(0, 0xFFF0024, 0xEE190F11);
|
||||
MMU_writeWord(0, 0xFFF0028, 0xE1A00620);
|
||||
MMU_writeWord(0, 0xFFF002C, 0xE1A00600);
|
||||
MMU_writeWord(0, 0xFFF0030, 0xE2800C40);
|
||||
MMU_writeWord(0, 0xFFF0034, 0xE28FE000);
|
||||
MMU_writeWord(0, 0xFFF0038, 0xE510F004);
|
||||
MMU_writeWord(0, 0xFFF003C, 0xE8BD500F);
|
||||
MMU_writeWord(0, 0xFFF0040, 0xE25EF004);
|
||||
|
||||
MMU_writeWord(0, 0x0000004, 0xE3A0010E);
|
||||
MMU_writeWord(0, 0x0000008, 0xE3A01020);
|
||||
// MMU_writeWord(0, 0x000000C, 0xE1B02110);
|
||||
MMU_writeWord(0, 0x000000C, 0xE1B02040);
|
||||
MMU_writeWord(0, 0x0000010, 0xE3B02020);
|
||||
// MMU_writeWord(0, 0x0000010, 0xE2100202);
|
||||
|
||||
free(header);
|
||||
|
||||
GPU_Reset(MainScreen.gpu, 0);
|
||||
GPU_Reset(SubScreen.gpu, 1);
|
||||
SPU_Reset();
|
||||
|
||||
execute = oldexecute;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 size;
|
||||
s32 width;
|
||||
s32 height;
|
||||
u16 planes;
|
||||
u16 bpp;
|
||||
u32 cmptype;
|
||||
u32 imgsize;
|
||||
s32 hppm;
|
||||
s32 vppm;
|
||||
u32 numcol;
|
||||
u32 numimpcol;
|
||||
} bmpimgheader_struct;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
u16 id;
|
||||
u32 size;
|
||||
u16 reserved1;
|
||||
u16 reserved2;
|
||||
u32 imgoffset;
|
||||
} bmpfileheader_struct;
|
||||
#pragma pack(pop)
|
||||
#else
|
||||
typedef struct
|
||||
{
|
||||
u16 id __PACKED;
|
||||
u32 size __PACKED;
|
||||
u16 reserved1 __PACKED;
|
||||
u16 reserved2 __PACKED;
|
||||
u32 imgoffset __PACKED;
|
||||
} bmpfileheader_struct;
|
||||
#endif
|
||||
|
||||
int NDS_WriteBMP(const char *filename)
|
||||
{
|
||||
bmpfileheader_struct fileheader;
|
||||
bmpimgheader_struct imageheader;
|
||||
FILE *file;
|
||||
int i,j,k;
|
||||
u16 * bmp = GPU_screen;
|
||||
|
||||
memset(&fileheader, 0, sizeof(fileheader));
|
||||
fileheader.size = sizeof(fileheader);
|
||||
fileheader.id = 'B' | ('M' << 8);
|
||||
fileheader.imgoffset = sizeof(fileheader)+sizeof(imageheader);
|
||||
|
||||
memset(&imageheader, 0, sizeof(imageheader));
|
||||
imageheader.size = sizeof(imageheader);
|
||||
imageheader.width = 256;
|
||||
imageheader.height = 192*2;
|
||||
imageheader.planes = 1;
|
||||
imageheader.bpp = 24;
|
||||
imageheader.cmptype = 0; // None
|
||||
imageheader.imgsize = imageheader.width * imageheader.height * 3;
|
||||
|
||||
if ((file = fopen(filename,"wb")) == NULL)
|
||||
return 0;
|
||||
|
||||
fwrite(&fileheader, 1, sizeof(fileheader), file);
|
||||
fwrite(&imageheader, 1, sizeof(imageheader), file);
|
||||
|
||||
for(j=0;j<192*2;j++)
|
||||
{
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
u8 r,g,b;
|
||||
u16 pixel = bmp[(192*2-j-1)*256+i];
|
||||
r = pixel>>10;
|
||||
pixel-=r<<10;
|
||||
g = pixel>>5;
|
||||
pixel-=g<<5;
|
||||
b = pixel;
|
||||
r*=255/31;
|
||||
g*=255/31;
|
||||
b*=255/31;
|
||||
fwrite(&r, 1, sizeof(u8), file);
|
||||
fwrite(&g, 1, sizeof(u8), file);
|
||||
fwrite(&b, 1, sizeof(u8), file);
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int NDS_LoadFirmware(const char *filename)
|
||||
{
|
||||
int i;
|
||||
long size;
|
||||
FILE *file;
|
||||
|
||||
if ((file = fopen(filename, "rb")) == NULL)
|
||||
return -1;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
if(size > MMU.fw.size)
|
||||
{
|
||||
fclose(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
i = fread(MMU.fw.data, size, 1, file);
|
||||
fclose(file);
|
||||
|
||||
return i;
|
||||
}
|
|
@ -0,0 +1,751 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef NDSSYSTEM_H
|
||||
#define NDSSYSTEM_H
|
||||
|
||||
#include "armcpu.h"
|
||||
#include "MMU.h"
|
||||
|
||||
#include "GPU.h"
|
||||
#include "SPU.h"
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern volatile BOOL execute;
|
||||
extern BOOL click;
|
||||
|
||||
//#define LOG_ARM9
|
||||
//#define LOG_ARM7
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char gameTile[12];
|
||||
char gameCode[4];
|
||||
u16 makerCode;
|
||||
u8 unitCode;
|
||||
u8 deviceCode;
|
||||
u8 cardSize;
|
||||
u8 cardInfo[8];
|
||||
u8 flags;
|
||||
|
||||
u32 ARM9src;
|
||||
u32 ARM9exe;
|
||||
u32 ARM9cpy;
|
||||
u32 ARM9binSize;
|
||||
|
||||
u32 ARM7src;
|
||||
u32 ARM7exe;
|
||||
u32 ARM7cpy;
|
||||
u32 ARM7binSize;
|
||||
|
||||
u32 FNameTblOff;
|
||||
u32 FNameTblSize;
|
||||
|
||||
u32 FATOff;
|
||||
u32 FATSize;
|
||||
|
||||
u32 ARM9OverlayOff;
|
||||
u32 ARM9OverlaySize;
|
||||
u32 ARM7OverlayOff;
|
||||
u32 ARM7OverlaySize;
|
||||
|
||||
u32 unknown2a;
|
||||
u32 unknown2b;
|
||||
|
||||
u32 IconOff;
|
||||
u16 CRC16;
|
||||
u16 ROMtimeout;
|
||||
u32 ARM9unk;
|
||||
u32 ARM7unk;
|
||||
|
||||
u8 unknown3c[8];
|
||||
u32 ROMSize;
|
||||
u32 HeaderSize;
|
||||
u8 unknown5[56];
|
||||
u8 logo[156];
|
||||
u16 logoCRC16;
|
||||
u16 headerCRC16;
|
||||
u8 reserved[160];
|
||||
} NDS_header;
|
||||
|
||||
extern void debug();
|
||||
|
||||
typedef struct
|
||||
{
|
||||
s32 ARM9Cycle;
|
||||
s32 ARM7Cycle;
|
||||
s32 cycles;
|
||||
s32 timerCycle[2][4];
|
||||
BOOL timerOver[2][4];
|
||||
s32 nextHBlank;
|
||||
u32 VCount;
|
||||
u32 old;
|
||||
s32 diff;
|
||||
BOOL lignerendu;
|
||||
|
||||
u16 touchX;
|
||||
u16 touchY;
|
||||
} NDSSystem;
|
||||
|
||||
extern NDSSystem nds;
|
||||
|
||||
int NDSInit(void);
|
||||
void NDSDeInit(void);
|
||||
|
||||
BOOL NDS_SetROM(u8 * rom, u32 mask);
|
||||
NDS_header * NDS_getROMHeader(void);
|
||||
|
||||
void NDS_setTouchPos(u16 x, u16 y);
|
||||
void NDS_releasTouch(void);
|
||||
|
||||
int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize);
|
||||
void NDS_FreeROM(void);
|
||||
void NDS_Reset(void);
|
||||
|
||||
int NDS_WriteBMP(const char *filename);
|
||||
int NDS_LoadFirmware(const char *filename);
|
||||
|
||||
static INLINE void NDS_ARM9HBlankInt(void)
|
||||
{
|
||||
if(T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0x10)
|
||||
{
|
||||
MMU.reg_IF[0] |= 2;// & (MMU.reg_IME[0] << 1);// (MMU.reg_IE[0] & (1<<1));
|
||||
NDS_ARM9.wIRQ = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void NDS_ARM7HBlankInt(void)
|
||||
{
|
||||
if(T1ReadWord(MMU.ARM7_REG, 4) & 0x10)
|
||||
{
|
||||
MMU.reg_IF[1] |= 2;// & (MMU.reg_IME[1] << 1);// (MMU.reg_IE[1] & (1<<1));
|
||||
NDS_ARM7.wIRQ = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void NDS_ARM9VBlankInt(void)
|
||||
{
|
||||
if(T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0x8)
|
||||
{
|
||||
MMU.reg_IF[0] |= 1;// & (MMU.reg_IME[0]);// (MMU.reg_IE[0] & 1);
|
||||
NDS_ARM9.wIRQ = TRUE;
|
||||
//execute = FALSE;
|
||||
/*logcount++;*/
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void NDS_ARM7VBlankInt(void)
|
||||
{
|
||||
if(T1ReadWord(MMU.ARM7_REG, 4) & 0x8)
|
||||
MMU.reg_IF[1] |= 1;// & (MMU.reg_IME[1]);// (MMU.reg_IE[1] & 1);
|
||||
NDS_ARM7.wIRQ = TRUE;
|
||||
//execute = FALSE;
|
||||
}
|
||||
|
||||
static INLINE void NDS_swapScreen(void)
|
||||
{
|
||||
u16 tmp = MainScreen.offset;
|
||||
MainScreen.offset = SubScreen.offset;
|
||||
SubScreen.offset = tmp;
|
||||
}
|
||||
|
||||
#define INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF))
|
||||
static INLINE u32 NDS_exec(s32 nb, BOOL force)
|
||||
{
|
||||
nb += nds.cycles;//(nds.cycles>>26)<<26;
|
||||
|
||||
for(; (nb >= nds.cycles) && ((force)||(execute)); )
|
||||
{
|
||||
if(nds.ARM9Cycle<=nds.cycles)
|
||||
{
|
||||
#ifdef LOG_ARM9
|
||||
if(logcount==3){
|
||||
if(NDS_ARM9.CPSR.bits.T)
|
||||
des_thumb_instructions_set[(NDS_ARM9.instruction)>>6](NDS_ARM9.instruct_adr, NDS_ARM9.instruction, logbuf);
|
||||
else
|
||||
des_arm_instructions_set[INDEX(NDS_ARM9.instruction)](NDS_ARM9.instruct_adr, NDS_ARM9.instruction, logbuf);
|
||||
sprintf(logbuf, "%s\t%08X\n\t R00: %08X, R01: %08X, R02: %08X, R03: %08X, R04: %08X, R05: %08X, R06: %08X, R07: %08X,\n\t R08: %08X, R09: %08X, R10: %08X, R11: %08X, R12: %08X, R13: %08X, R14: %08X, R15: %08X,\n\t CPSR: %08X , SPSR: %08X",
|
||||
logbuf, NDS_ARM9.instruction, NDS_ARM9.R[0], NDS_ARM9.R[1], NDS_ARM9.R[2], NDS_ARM9.R[3], NDS_ARM9.R[4], NDS_ARM9.R[5], NDS_ARM9.R[6], NDS_ARM9.R[7],
|
||||
NDS_ARM9.R[8], NDS_ARM9.R[9], NDS_ARM9.R[10], NDS_ARM9.R[11], NDS_ARM9.R[12], NDS_ARM9.R[13], NDS_ARM9.R[14], NDS_ARM9.R[15],
|
||||
NDS_ARM9.CPSR, NDS_ARM9.SPSR);
|
||||
LOG(logbuf);
|
||||
}
|
||||
#endif
|
||||
if(NDS_ARM9.waitIRQ)
|
||||
nds.ARM9Cycle += 100;
|
||||
else
|
||||
//nds.ARM9Cycle += NDS_ARM9.exec();
|
||||
nds.ARM9Cycle += armcpu_exec(&NDS_ARM9);
|
||||
}
|
||||
if(nds.ARM7Cycle<=nds.cycles)
|
||||
{
|
||||
#ifdef LOG_ARM7
|
||||
if(logcount==1){
|
||||
if(NDS_ARM7.CPSR.bits.T)
|
||||
des_thumb_instructions_set[(NDS_ARM7.instruction)>>6](NDS_ARM7.instruct_adr, NDS_ARM7.instruction, logbuf);
|
||||
else
|
||||
des_arm_instructions_set[INDEX(NDS_ARM7.instruction)](NDS_ARM7.instruct_adr, NDS_ARM7.instruction, logbuf);
|
||||
sprintf(logbuf, "%s\n\t R00: %08X, R01: %08X, R02: %08X, R03: %08X, R04: %08X, R05: %08X, R06: %08X, R07: %08X,\n\t R08: %08X, R09: %08X, R10: %08X, R11: %08X, R12: %08X, R13: %08X, R14: %08X, R15: %08X,\n\t CPSR: %08X , SPSR: %08X",
|
||||
logbuf, NDS_ARM7.R[0], NDS_ARM7.R[1], NDS_ARM7.R[2], NDS_ARM7.R[3], NDS_ARM7.R[4], NDS_ARM7.R[5], NDS_ARM7.R[6], NDS_ARM7.R[7],
|
||||
NDS_ARM7.R[8], NDS_ARM7.R[9], NDS_ARM7.R[10], NDS_ARM7.R[11], NDS_ARM7.R[12], NDS_ARM7.R[13], NDS_ARM7.R[14], NDS_ARM7.R[15],
|
||||
NDS_ARM7.CPSR, NDS_ARM7.SPSR);
|
||||
LOG(logbuf);
|
||||
}
|
||||
#endif
|
||||
if(NDS_ARM7.waitIRQ)
|
||||
nds.ARM7Cycle += 100;
|
||||
else
|
||||
//nds.ARM7Cycle += (NDS_ARM7.exec()<<1);
|
||||
nds.ARM7Cycle += (armcpu_exec(&NDS_ARM7)<<1);
|
||||
}
|
||||
nds.cycles = (nds.ARM9Cycle<nds.ARM7Cycle)?nds.ARM9Cycle : nds.ARM7Cycle;
|
||||
|
||||
debug();
|
||||
|
||||
if(nds.cycles>=nds.nextHBlank)
|
||||
{
|
||||
if(!nds.lignerendu)
|
||||
{
|
||||
if(nds.VCount<192)
|
||||
{
|
||||
GPU_ligne(&MainScreen, nds.VCount);
|
||||
GPU_ligne(&SubScreen, nds.VCount);
|
||||
T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) | 2);
|
||||
T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 2);
|
||||
NDS_ARM9HBlankInt();
|
||||
NDS_ARM7HBlankInt();
|
||||
if(MMU.DMAStartTime[0][0] == 2)
|
||||
MMU_doDMA(0, 0);
|
||||
if(MMU.DMAStartTime[0][1] == 2)
|
||||
MMU_doDMA(0, 1);
|
||||
if(MMU.DMAStartTime[0][2] == 2)
|
||||
MMU_doDMA(0, 2);
|
||||
if(MMU.DMAStartTime[0][3] == 2)
|
||||
MMU_doDMA(0, 3);
|
||||
}
|
||||
nds.lignerendu = TRUE;
|
||||
}
|
||||
if(nds.cycles>=nds.nextHBlank+1092)
|
||||
{
|
||||
u32 vmatch;
|
||||
|
||||
++nds.VCount;
|
||||
nds.nextHBlank += 4260;
|
||||
T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0xFFFD);
|
||||
T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) & 0xFFFD);
|
||||
|
||||
if(MMU.DMAStartTime[0][0] == 3)
|
||||
MMU_doDMA(0, 0);
|
||||
if(MMU.DMAStartTime[0][1] == 3)
|
||||
MMU_doDMA(0, 1);
|
||||
if(MMU.DMAStartTime[0][2] == 3)
|
||||
MMU_doDMA(0, 2);
|
||||
if(MMU.DMAStartTime[0][3] == 3)
|
||||
MMU_doDMA(0, 3);
|
||||
|
||||
nds.lignerendu = FALSE;
|
||||
if(nds.VCount==193)
|
||||
{
|
||||
T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) | 1);
|
||||
T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 1);
|
||||
NDS_ARM9VBlankInt();
|
||||
NDS_ARM7VBlankInt();
|
||||
|
||||
if(MMU.DMAStartTime[0][0] == 1)
|
||||
MMU_doDMA(0, 0);
|
||||
if(MMU.DMAStartTime[0][1] == 1)
|
||||
MMU_doDMA(0, 1);
|
||||
if(MMU.DMAStartTime[0][2] == 1)
|
||||
MMU_doDMA(0, 2);
|
||||
if(MMU.DMAStartTime[0][3] == 1)
|
||||
MMU_doDMA(0, 3);
|
||||
|
||||
if(MMU.DMAStartTime[1][0] == 1)
|
||||
MMU_doDMA(1, 0);
|
||||
if(MMU.DMAStartTime[1][1] == 1)
|
||||
MMU_doDMA(1, 1);
|
||||
if(MMU.DMAStartTime[1][2] == 1)
|
||||
MMU_doDMA(1, 2);
|
||||
if(MMU.DMAStartTime[1][3] == 1)
|
||||
MMU_doDMA(1, 3);
|
||||
}
|
||||
else
|
||||
if(nds.VCount==263)
|
||||
{
|
||||
nds.nextHBlank = 3168;
|
||||
nds.VCount = 0;
|
||||
T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0xFFFE);
|
||||
T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) & 0xFFFE);
|
||||
|
||||
nds.cycles -= (560190<<1);
|
||||
nds.ARM9Cycle -= (560190<<1);
|
||||
nds.ARM7Cycle -= (560190<<1);
|
||||
nb -= (560190<<1);
|
||||
if(MMU.timerON[0][0])
|
||||
nds.timerCycle[0][0] -= (560190<<1);
|
||||
if(MMU.timerON[0][1])
|
||||
nds.timerCycle[0][1] -= (560190<<1);
|
||||
if(MMU.timerON[0][2])
|
||||
nds.timerCycle[0][2] -= (560190<<1);
|
||||
if(MMU.timerON[0][3])
|
||||
nds.timerCycle[0][3] -= (560190<<1);
|
||||
|
||||
if(MMU.timerON[1][0])
|
||||
nds.timerCycle[1][0] -= (560190<<1);
|
||||
if(MMU.timerON[1][1])
|
||||
nds.timerCycle[1][1] -= (560190<<1);
|
||||
if(MMU.timerON[1][2])
|
||||
nds.timerCycle[1][2] -= (560190<<1);
|
||||
if(MMU.timerON[1][3])
|
||||
nds.timerCycle[1][3] -= (560190<<1);
|
||||
if(MMU.DMAing[0][0])
|
||||
MMU.DMACycle[0][0] -= (560190<<1);
|
||||
if(MMU.DMAing[0][1])
|
||||
MMU.DMACycle[0][1] -= (560190<<1);
|
||||
if(MMU.DMAing[0][2])
|
||||
MMU.DMACycle[0][2] -= (560190<<1);
|
||||
if(MMU.DMAing[0][3])
|
||||
MMU.DMACycle[0][3] -= (560190<<1);
|
||||
if(MMU.DMAing[1][0])
|
||||
MMU.DMACycle[1][0] -= (560190<<1);
|
||||
if(MMU.DMAing[1][1])
|
||||
MMU.DMACycle[1][1] -= (560190<<1);
|
||||
if(MMU.DMAing[1][2])
|
||||
MMU.DMACycle[1][2] -= (560190<<1);
|
||||
if(MMU.DMAing[1][3])
|
||||
MMU.DMACycle[1][3] -= (560190<<1);
|
||||
}
|
||||
|
||||
T1WriteWord(ARM9Mem.ARM9_REG, 6, nds.VCount);
|
||||
T1WriteWord(MMU.ARM7_REG, 6, nds.VCount);
|
||||
|
||||
vmatch = T1ReadWord(ARM9Mem.ARM9_REG, 4);
|
||||
if((nds.VCount==(vmatch>>8)|((vmatch<<1)&(1<<8))))
|
||||
{
|
||||
T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) | 4);
|
||||
if(T1ReadWord(ARM9Mem.ARM9_REG, 4) & 32)
|
||||
NDS_makeARM9Int(2);
|
||||
}
|
||||
else
|
||||
T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0xFFFB);
|
||||
|
||||
vmatch = T1ReadWord(MMU.ARM7_REG, 4);
|
||||
if((nds.VCount==(vmatch>>8)|((vmatch<<1)&(1<<8))))
|
||||
{
|
||||
T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 4);
|
||||
if(T1ReadWord(MMU.ARM7_REG, 4) & 32)
|
||||
NDS_makeARM7Int(2);
|
||||
}
|
||||
else
|
||||
T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) & 0xFFFB);
|
||||
}
|
||||
}
|
||||
if(MMU.timerON[0][0])
|
||||
{
|
||||
if(MMU.timerRUN[0][0])
|
||||
{
|
||||
switch(MMU.timerMODE[0][0])
|
||||
{
|
||||
case 0xFFFF :
|
||||
break;
|
||||
default :
|
||||
{
|
||||
nds.diff = (nds.cycles - nds.timerCycle[0][0])>>MMU.timerMODE[0][0];
|
||||
nds.old = MMU.timer[0][0];
|
||||
MMU.timer[0][0] += nds.diff;
|
||||
nds.timerCycle[0][0] += (nds.diff << MMU.timerMODE[0][0]);
|
||||
nds.timerOver[0][0] = nds.old>MMU.timer[0][0];
|
||||
if(nds.timerOver[0][0])
|
||||
{
|
||||
if(T1ReadWord(ARM9Mem.ARM9_REG, 0x102) & 0x40)
|
||||
NDS_makeARM9Int(3);
|
||||
MMU.timer[0][0] += MMU.timerReload[0][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MMU.timerRUN[0][0] = TRUE;
|
||||
nds.timerCycle[0][0] = nds.cycles;
|
||||
}
|
||||
}
|
||||
if(MMU.timerON[0][1])
|
||||
{
|
||||
if(MMU.timerRUN[0][1])
|
||||
{
|
||||
switch(MMU.timerMODE[0][1])
|
||||
{
|
||||
case 0xFFFF :
|
||||
if(nds.timerOver[0][0])
|
||||
{
|
||||
++(MMU.timer[0][1]);
|
||||
nds.timerOver[0][1] = !MMU.timer[0][1];
|
||||
if (nds.timerOver[0][1])
|
||||
{
|
||||
if(T1ReadWord(ARM9Mem.ARM9_REG, 0x106) & 0x40)
|
||||
NDS_makeARM9Int(4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
{
|
||||
nds.diff = (nds.cycles - nds.timerCycle[0][1])>>MMU.timerMODE[0][1];
|
||||
nds.old = MMU.timer[0][1];
|
||||
MMU.timer[0][1] += nds.diff;
|
||||
nds.timerCycle[0][1] += nds.diff << MMU.timerMODE[0][1];
|
||||
nds.timerOver[0][1] = nds.old>MMU.timer[0][1];
|
||||
if(nds.timerOver[0][1])
|
||||
{
|
||||
if(T1ReadWord(ARM9Mem.ARM9_REG, 0x106) & 0x40)
|
||||
NDS_makeARM9Int(4);
|
||||
MMU.timer[0][1] += MMU.timerReload[0][1];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MMU.timerRUN[0][1] = TRUE;
|
||||
nds.timerCycle[0][1] = nds.cycles;
|
||||
}
|
||||
}
|
||||
if(MMU.timerON[0][2])
|
||||
{
|
||||
if(MMU.timerRUN[0][2])
|
||||
{
|
||||
switch(MMU.timerMODE[0][2])
|
||||
{
|
||||
case 0xFFFF :
|
||||
if(nds.timerOver[0][1])
|
||||
{
|
||||
++(MMU.timer[0][2]);
|
||||
nds.timerOver[0][2] = !MMU.timer[0][2];
|
||||
if (nds.timerOver[0][2])
|
||||
{
|
||||
if(T1ReadWord(ARM9Mem.ARM9_REG, 0x10A) & 0x40)
|
||||
NDS_makeARM9Int(5);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
{
|
||||
nds.diff = (nds.cycles - nds.timerCycle[0][2])>>MMU.timerMODE[0][2];
|
||||
nds.old = MMU.timer[0][2];
|
||||
MMU.timer[0][2] += nds.diff;
|
||||
nds.timerCycle[0][2] += nds.diff << MMU.timerMODE[0][2];
|
||||
nds.timerOver[0][2] = nds.old>MMU.timer[0][2];
|
||||
if(nds.timerOver[0][2])
|
||||
{
|
||||
if(T1ReadWord(ARM9Mem.ARM9_REG, 0x10A) & 0x40)
|
||||
NDS_makeARM9Int(5);
|
||||
MMU.timer[0][2] += MMU.timerReload[0][2];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MMU.timerRUN[0][2] = TRUE;
|
||||
nds.timerCycle[0][2] = nds.cycles;
|
||||
}
|
||||
}
|
||||
if(MMU.timerON[0][3])
|
||||
{
|
||||
if(MMU.timerRUN[0][3])
|
||||
{
|
||||
switch(MMU.timerMODE[0][3])
|
||||
{
|
||||
case 0xFFFF :
|
||||
if(nds.timerOver[0][2])
|
||||
{
|
||||
++(MMU.timer[0][3]);
|
||||
nds.timerOver[0][3] = !MMU.timer[0][3];
|
||||
if (nds.timerOver[0][3])
|
||||
{
|
||||
if(T1ReadWord(ARM9Mem.ARM9_REG, 0x10E) & 0x40)
|
||||
NDS_makeARM9Int(6);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
{
|
||||
nds.diff = (nds.cycles - nds.timerCycle[0][3])>>MMU.timerMODE[0][3];
|
||||
nds.old = MMU.timer[0][3];
|
||||
MMU.timer[0][3] += nds.diff;
|
||||
nds.timerCycle[0][3] += nds.diff << MMU.timerMODE[0][3];
|
||||
nds.timerOver[0][3] = nds.old>MMU.timer[0][3];
|
||||
if(nds.timerOver[0][3])
|
||||
{
|
||||
if(T1ReadWord(ARM9Mem.ARM9_REG, 0x10E) & 0x40)
|
||||
NDS_makeARM9Int(6);
|
||||
MMU.timer[0][3] += MMU.timerReload[0][3];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MMU.timerRUN[0][3] = TRUE;
|
||||
nds.timerCycle[0][3] = nds.cycles;
|
||||
}
|
||||
}
|
||||
|
||||
if(MMU.timerON[1][0])
|
||||
{
|
||||
if(MMU.timerRUN[1][0])
|
||||
{
|
||||
switch(MMU.timerMODE[1][0])
|
||||
{
|
||||
case 0xFFFF :
|
||||
break;
|
||||
default :
|
||||
{
|
||||
nds.diff = (nds.cycles - nds.timerCycle[1][0])>>MMU.timerMODE[1][0];
|
||||
nds.old = MMU.timer[1][0];
|
||||
MMU.timer[1][0] += nds.diff;
|
||||
nds.timerCycle[1][0] += nds.diff << MMU.timerMODE[1][0];
|
||||
nds.timerOver[1][0] = nds.old>MMU.timer[1][0];
|
||||
if(nds.timerOver[1][0])
|
||||
{
|
||||
if(T1ReadWord(MMU.ARM7_REG, 0x102) & 0x40)
|
||||
NDS_makeARM7Int(3);
|
||||
MMU.timer[1][0] += MMU.timerReload[1][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MMU.timerRUN[1][0] = TRUE;
|
||||
nds.timerCycle[1][0] = nds.cycles;
|
||||
}
|
||||
}
|
||||
if(MMU.timerON[1][1])
|
||||
{
|
||||
if(MMU.timerRUN[1][1])
|
||||
{
|
||||
switch(MMU.timerMODE[1][1])
|
||||
{
|
||||
case 0xFFFF :
|
||||
if(nds.timerOver[1][0])
|
||||
{
|
||||
++(MMU.timer[1][1]);
|
||||
nds.timerOver[1][1] = !MMU.timer[1][1];
|
||||
if (nds.timerOver[1][1])
|
||||
{
|
||||
if(T1ReadWord(MMU.ARM7_REG, 0x106) & 0x40)
|
||||
NDS_makeARM7Int(4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
{
|
||||
nds.diff = (nds.cycles - nds.timerCycle[1][1])>>MMU.timerMODE[1][1];
|
||||
nds.old = MMU.timer[1][1];
|
||||
MMU.timer[1][1] += nds.diff;
|
||||
nds.timerCycle[1][1] += nds.diff << MMU.timerMODE[1][1];
|
||||
nds.timerOver[1][1] = nds.old>MMU.timer[1][1];
|
||||
if(nds.timerOver[1][1])
|
||||
{
|
||||
if(T1ReadWord(MMU.ARM7_REG, 0x106) & 0x40)
|
||||
NDS_makeARM7Int(4);
|
||||
MMU.timer[1][1] += MMU.timerReload[1][1];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MMU.timerRUN[1][1] = TRUE;
|
||||
nds.timerCycle[1][1] = nds.cycles;
|
||||
}
|
||||
}
|
||||
if(MMU.timerON[1][2])
|
||||
{
|
||||
if(MMU.timerRUN[1][2])
|
||||
{
|
||||
switch(MMU.timerMODE[1][2])
|
||||
{
|
||||
case 0xFFFF :
|
||||
if(nds.timerOver[1][1])
|
||||
{
|
||||
++(MMU.timer[1][2]);
|
||||
nds.timerOver[1][2] = !MMU.timer[1][2];
|
||||
if (nds.timerOver[1][2])
|
||||
{
|
||||
if(T1ReadWord(MMU.ARM7_REG, 0x10A) & 0x40)
|
||||
NDS_makeARM7Int(5);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
{
|
||||
nds.diff = (nds.cycles - nds.timerCycle[1][2])>>MMU.timerMODE[1][2];
|
||||
nds.old = MMU.timer[1][2];
|
||||
MMU.timer[1][2] += nds.diff;
|
||||
nds.timerCycle[1][2] += nds.diff << MMU.timerMODE[1][2];
|
||||
nds.timerOver[1][2] = nds.old>MMU.timer[1][2];
|
||||
if(nds.timerOver[1][2])
|
||||
{
|
||||
if(T1ReadWord(MMU.ARM7_REG, 0x10A) & 0x40)
|
||||
NDS_makeARM7Int(5);
|
||||
MMU.timer[1][2] += MMU.timerReload[1][2];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MMU.timerRUN[1][2] = TRUE;
|
||||
nds.timerCycle[1][2] = nds.cycles;
|
||||
}
|
||||
}
|
||||
if(MMU.timerON[1][3])
|
||||
{
|
||||
if(MMU.timerRUN[1][3])
|
||||
{
|
||||
switch(MMU.timerMODE[1][3])
|
||||
{
|
||||
case 0xFFFF :
|
||||
if(nds.timerOver[1][2])
|
||||
{
|
||||
++(MMU.timer[1][3]);
|
||||
nds.timerOver[1][3] = !MMU.timer[1][3];
|
||||
if (nds.timerOver[1][3])
|
||||
{
|
||||
if(T1ReadWord(MMU.ARM7_REG, 0x10E) & 0x40)
|
||||
NDS_makeARM7Int(6);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
{
|
||||
nds.diff = (nds.cycles - nds.timerCycle[1][3])>>MMU.timerMODE[1][3];
|
||||
nds.old = MMU.timer[1][3];
|
||||
MMU.timer[1][3] += nds.diff;
|
||||
nds.timerCycle[1][3] += nds.diff << MMU.timerMODE[1][3];
|
||||
nds.timerOver[1][3] = nds.old>MMU.timer[1][3];
|
||||
if(nds.timerOver[1][3])
|
||||
{
|
||||
if(T1ReadWord(MMU.ARM7_REG, 0x10E) & 0x40)
|
||||
NDS_makeARM7Int(6);
|
||||
MMU.timer[1][3] += MMU.timerReload[1][3];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MMU.timerRUN[1][3] = TRUE;
|
||||
nds.timerCycle[1][3] = nds.cycles;
|
||||
}
|
||||
}
|
||||
|
||||
if((MMU.DMAing[0][0])&&(MMU.DMACycle[0][0]<=nds.cycles))
|
||||
{
|
||||
T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*0), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*0)) & 0x7FFFFFFF);
|
||||
if((MMU.DMACrt[0][0])&(1<<30)) NDS_makeARM9Int(8);
|
||||
MMU.DMAing[0][0] = FALSE;
|
||||
}
|
||||
|
||||
if((MMU.DMAing[0][1])&&(MMU.DMACycle[0][1]<=nds.cycles))
|
||||
{
|
||||
T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*1), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*1)) & 0x7FFFFFFF);
|
||||
if((MMU.DMACrt[0][1])&(1<<30)) NDS_makeARM9Int(9);
|
||||
MMU.DMAing[0][1] = FALSE;
|
||||
}
|
||||
|
||||
if((MMU.DMAing[0][2])&&(MMU.DMACycle[0][2]<=nds.cycles))
|
||||
{
|
||||
T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*2), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*2)) & 0x7FFFFFFF);
|
||||
if((MMU.DMACrt[0][2])&(1<<30)) NDS_makeARM9Int(10);
|
||||
MMU.DMAing[0][2] = FALSE;
|
||||
}
|
||||
|
||||
if((MMU.DMAing[0][3])&&(MMU.DMACycle[0][3]<=nds.cycles))
|
||||
{
|
||||
T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*3), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*3)) & 0x7FFFFFFF);
|
||||
if((MMU.DMACrt[0][3])&(1<<30)) NDS_makeARM9Int(11);
|
||||
MMU.DMAing[0][3] = FALSE;
|
||||
}
|
||||
|
||||
if((MMU.DMAing[1][0])&&(MMU.DMACycle[1][0]<=nds.cycles))
|
||||
{
|
||||
T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*0), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*0)) & 0x7FFFFFFF);
|
||||
if((MMU.DMACrt[1][0])&(1<<30)) NDS_makeARM7Int(8);
|
||||
MMU.DMAing[1][0] = FALSE;
|
||||
}
|
||||
|
||||
if((MMU.DMAing[1][1])&&(MMU.DMACycle[1][1]<=nds.cycles))
|
||||
{
|
||||
T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*1), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*1)) & 0x7FFFFFFF);
|
||||
if((MMU.DMACrt[1][1])&(1<<30)) NDS_makeARM7Int(9);
|
||||
MMU.DMAing[1][1] = FALSE;
|
||||
}
|
||||
|
||||
if((MMU.DMAing[1][2])&&(MMU.DMACycle[1][2]<=nds.cycles))
|
||||
{
|
||||
T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*2), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*2)) & 0x7FFFFFFF);
|
||||
if((MMU.DMACrt[1][2])&(1<<30)) NDS_makeARM7Int(10);
|
||||
MMU.DMAing[1][2] = FALSE;
|
||||
}
|
||||
|
||||
if((MMU.DMAing[1][3])&&(MMU.DMACycle[1][3]<=nds.cycles))
|
||||
{
|
||||
T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*3), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*3)) & 0x7FFFFFFF);
|
||||
if((MMU.DMACrt[1][3])&(1<<30)) NDS_makeARM7Int(11);
|
||||
MMU.DMAing[1][3] = FALSE;
|
||||
}
|
||||
|
||||
if((MMU.reg_IF[0]&MMU.reg_IE[0]) && (MMU.reg_IME[0]))
|
||||
//if(NDS_ARM9.irqExeption())
|
||||
if(armcpu_irqExeption(&NDS_ARM9))
|
||||
{
|
||||
nds.ARM9Cycle = nds.cycles;
|
||||
}
|
||||
|
||||
if((MMU.reg_IF[1]&MMU.reg_IE[1]) && (MMU.reg_IME[1]))
|
||||
if (armcpu_irqExeption(&NDS_ARM7))
|
||||
nds.ARM7Cycle = nds.cycles;
|
||||
|
||||
}
|
||||
return nds.cycles;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,92 @@
|
|||
/* Copyright (C) 2006 Theo Berkau
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef SPU_H
|
||||
#define SPU_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define SNDCORE_DEFAULT -1
|
||||
#define SNDCORE_DUMMY 0
|
||||
#define SNDCORE_FILEWRITE 1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int id;
|
||||
const char *Name;
|
||||
int (*Init)(int buffersize);
|
||||
void (*DeInit)();
|
||||
void (*UpdateAudio)(s16 *buffer, u32 num_samples);
|
||||
u32 (*GetAudioSpace)();
|
||||
void (*MuteAudio)();
|
||||
void (*UnMuteAudio)();
|
||||
void (*SetVolume)(int volume);
|
||||
} SoundInterface_struct;
|
||||
|
||||
extern SoundInterface_struct SNDDummy;
|
||||
extern SoundInterface_struct SNDFile;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 vol;
|
||||
u8 datashift;
|
||||
u8 hold;
|
||||
u8 pan;
|
||||
u8 waveduty;
|
||||
u8 repeat;
|
||||
u8 format;
|
||||
u8 status;
|
||||
u32 addr;
|
||||
u16 timer;
|
||||
u16 loopstart;
|
||||
u32 length;
|
||||
s8 *buf8;
|
||||
s16 *buf16;
|
||||
double sampcnt;
|
||||
double sampinc;
|
||||
// ADPCM specific
|
||||
int lastsampcnt;
|
||||
s16 pcm16b;
|
||||
int index;
|
||||
} channel_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 bufpos;
|
||||
u32 buflength;
|
||||
s32 *sndbuf;
|
||||
s16 *outbuf;
|
||||
u32 bufsize;
|
||||
channel_struct chan[16];
|
||||
} SPU_struct;
|
||||
|
||||
extern SPU_struct *SPU;
|
||||
|
||||
int SPU_ChangeSoundCore(int coreid, int buffersize);
|
||||
int SPU_Init(int coreid, int buffersize);
|
||||
void SPU_SetVolume(int volume);
|
||||
void SPU_Reset(void);
|
||||
void SPU_DeInit(void);
|
||||
void SPU_KeyOn(int channel);
|
||||
void SPU_WriteByte(u32 addr, u8 val);
|
||||
void SPU_WriteWord(u32 addr, u16 val);
|
||||
void SPU_WriteLong(u32 addr, u32 val);
|
||||
void SPU_Emulate(void);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef ARMINSTRUCTION_H
|
||||
#define ARMINSTRUCTION_H
|
||||
|
||||
#include "types.h"
|
||||
#include "armcpu.h"
|
||||
|
||||
extern u32 (*FASTCALL arm_instructions_set[4096])(armcpu_t * cpu);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,257 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "arm_instructions.h"
|
||||
#include "thumb_instructions.h"
|
||||
#include "cp15.h"
|
||||
#include "bios.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
armcpu_t NDS_ARM7;
|
||||
armcpu_t NDS_ARM9;
|
||||
|
||||
#define SWAP(a, b, c) c=a;\
|
||||
a=b;\
|
||||
b=c;
|
||||
|
||||
int armcpu_new(armcpu_t *armcpu, u32 id)
|
||||
{
|
||||
|
||||
armcpu->proc_ID = id;
|
||||
|
||||
if(id==0) armcpu->swi_tab = ARM9_swi_tab;
|
||||
else armcpu->swi_tab = ARM7_swi_tab;
|
||||
|
||||
armcpu_init(armcpu, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void armcpu_init(armcpu_t *armcpu, u32 adr)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
armcpu->LDTBit = (armcpu->proc_ID==0); //Si ARM9 utiliser le syte v5 pour le load
|
||||
armcpu->intVector = 0xFFFF0000 * (armcpu->proc_ID==0);
|
||||
armcpu->waitIRQ = FALSE;
|
||||
armcpu->wirq = FALSE;
|
||||
|
||||
if(armcpu->coproc[15]) free(armcpu->coproc[15]);
|
||||
|
||||
for(i = 0; i < 15; ++i)
|
||||
{
|
||||
armcpu->R[i] = 0;
|
||||
armcpu->coproc[i] = NULL;
|
||||
}
|
||||
|
||||
armcpu->CPSR.val = armcpu->SPSR.val = SYS;
|
||||
|
||||
armcpu->R13_usr = armcpu->R14_usr = 0;
|
||||
armcpu->R13_svc = armcpu->R14_svc = 0;
|
||||
armcpu->R13_abt = armcpu->R14_abt = 0;
|
||||
armcpu->R13_und = armcpu->R14_und = 0;
|
||||
armcpu->R13_irq = armcpu->R14_irq = 0;
|
||||
armcpu->R8_fiq = armcpu->R9_fiq = armcpu->R10_fiq = armcpu->R11_fiq = armcpu->R12_fiq = armcpu->R13_fiq = armcpu->R14_fiq = 0;
|
||||
|
||||
armcpu->SPSR_svc.val = armcpu->SPSR_abt.val = armcpu->SPSR_und.val = armcpu->SPSR_irq.val = armcpu->SPSR_fiq.val = 0;
|
||||
armcpu->next_instruction = adr;
|
||||
armcpu->R[15] = adr;
|
||||
armcpu->coproc[15] = (armcp_t*)armcp15_new(armcpu);
|
||||
|
||||
armcpu_prefetch(armcpu);
|
||||
}
|
||||
|
||||
u32 armcpu_switchMode(armcpu_t *armcpu, u8 mode)
|
||||
{
|
||||
u32 oldmode = armcpu->CPSR.bits.mode;
|
||||
|
||||
switch(oldmode)
|
||||
{
|
||||
case USR :
|
||||
case SYS :
|
||||
armcpu->R13_usr = armcpu->R[13];
|
||||
armcpu->R14_usr = armcpu->R[14];
|
||||
break;
|
||||
|
||||
case FIQ :
|
||||
{
|
||||
u32 tmp;
|
||||
SWAP(armcpu->R[8], armcpu->R8_fiq, tmp);
|
||||
SWAP(armcpu->R[9], armcpu->R9_fiq, tmp);
|
||||
SWAP(armcpu->R[10], armcpu->R10_fiq, tmp);
|
||||
SWAP(armcpu->R[11], armcpu->R11_fiq, tmp);
|
||||
SWAP(armcpu->R[12], armcpu->R12_fiq, tmp);
|
||||
armcpu->R13_fiq = armcpu->R[13];
|
||||
armcpu->R14_fiq = armcpu->R[14];
|
||||
armcpu->SPSR_fiq = armcpu->SPSR;
|
||||
break;
|
||||
}
|
||||
case IRQ :
|
||||
armcpu->R13_irq = armcpu->R[13];
|
||||
armcpu->R14_irq = armcpu->R[14];
|
||||
armcpu->SPSR_irq = armcpu->SPSR;
|
||||
break;
|
||||
|
||||
case SVC :
|
||||
armcpu->R13_svc = armcpu->R[13];
|
||||
armcpu->R14_svc = armcpu->R[14];
|
||||
armcpu->SPSR_svc = armcpu->SPSR;
|
||||
break;
|
||||
|
||||
case ABT :
|
||||
armcpu->R13_abt = armcpu->R[13];
|
||||
armcpu->R14_abt = armcpu->R[14];
|
||||
armcpu->SPSR_abt = armcpu->SPSR;
|
||||
break;
|
||||
|
||||
case UND :
|
||||
armcpu->R13_und = armcpu->R[13];
|
||||
armcpu->R14_und = armcpu->R[14];
|
||||
armcpu->SPSR_und = armcpu->SPSR;
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case USR :
|
||||
case SYS :
|
||||
armcpu->R[13] = armcpu->R13_usr;
|
||||
armcpu->R[14] = armcpu->R14_usr;
|
||||
//SPSR = CPSR;
|
||||
break;
|
||||
|
||||
case FIQ :
|
||||
{
|
||||
u32 tmp;
|
||||
SWAP(armcpu->R[8], armcpu->R8_fiq, tmp);
|
||||
SWAP(armcpu->R[9], armcpu->R9_fiq, tmp);
|
||||
SWAP(armcpu->R[10], armcpu->R10_fiq, tmp);
|
||||
SWAP(armcpu->R[11], armcpu->R11_fiq, tmp);
|
||||
SWAP(armcpu->R[12], armcpu->R12_fiq, tmp);
|
||||
armcpu->R[13] = armcpu->R13_fiq;
|
||||
armcpu->R[14] = armcpu->R14_fiq;
|
||||
armcpu->SPSR = armcpu->SPSR_fiq;
|
||||
break;
|
||||
}
|
||||
|
||||
case IRQ :
|
||||
armcpu->R[13] = armcpu->R13_irq;
|
||||
armcpu->R[14] = armcpu->R14_irq;
|
||||
armcpu->SPSR = armcpu->SPSR_irq;
|
||||
break;
|
||||
|
||||
case SVC :
|
||||
armcpu->R[13] = armcpu->R13_svc;
|
||||
armcpu->R[14] = armcpu->R14_svc;
|
||||
armcpu->SPSR = armcpu->SPSR_svc;
|
||||
break;
|
||||
|
||||
case ABT :
|
||||
armcpu->R[13] = armcpu->R13_abt;
|
||||
armcpu->R[14] = armcpu->R14_abt;
|
||||
armcpu->SPSR = armcpu->SPSR_abt;
|
||||
break;
|
||||
|
||||
case UND :
|
||||
armcpu->R[13] = armcpu->R13_und;
|
||||
armcpu->R[14] = armcpu->R14_und;
|
||||
armcpu->SPSR = armcpu->SPSR_und;
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
armcpu->CPSR.bits.mode = mode & 0x1F;
|
||||
return oldmode;
|
||||
}
|
||||
|
||||
u32 armcpu_prefetch(armcpu_t *armcpu)
|
||||
{
|
||||
if(armcpu->CPSR.bits.T == 0)
|
||||
{
|
||||
armcpu->instruction = MMU_readWord(armcpu->proc_ID, armcpu->next_instruction);
|
||||
armcpu->instruct_adr = armcpu->next_instruction;
|
||||
armcpu->next_instruction += 4;
|
||||
armcpu->R[15] = armcpu->next_instruction + 4;
|
||||
return MMU.MMU_WAIT32[armcpu->proc_ID][(armcpu->instruct_adr>>24)&0xF];
|
||||
}
|
||||
armcpu->instruction = MMU_readHWord(armcpu->proc_ID, armcpu->next_instruction);
|
||||
armcpu->instruct_adr = armcpu->next_instruction;
|
||||
armcpu->next_instruction = armcpu->next_instruction + 2;
|
||||
armcpu->R[15] = armcpu->next_instruction + 2;
|
||||
return MMU.MMU_WAIT16[armcpu->proc_ID][(armcpu->instruct_adr>>24)&0xF];
|
||||
}
|
||||
|
||||
u32 armcpu_exec(armcpu_t *armcpu)
|
||||
{
|
||||
u32 c = 1;
|
||||
if(armcpu->CPSR.bits.T == 0)
|
||||
{
|
||||
if((TEST_COND(CONDITION(armcpu->instruction), armcpu->CPSR)) || ((CONDITION(armcpu->instruction)==0xF)&&(CODE(armcpu->instruction)==0x5)))
|
||||
{
|
||||
c = arm_instructions_set[INSTRUCTION_INDEX(armcpu->instruction)](armcpu);
|
||||
}
|
||||
c += armcpu_prefetch(armcpu);
|
||||
return c;
|
||||
}
|
||||
c = thumb_instructions_set[armcpu->instruction>>6](armcpu);
|
||||
c += armcpu_prefetch(armcpu);
|
||||
return c;
|
||||
}
|
||||
|
||||
BOOL armcpu_irqExeption(armcpu_t *armcpu)
|
||||
{
|
||||
Status_Reg tmp;
|
||||
if(armcpu->CPSR.bits.I) return FALSE;
|
||||
tmp = armcpu->CPSR;
|
||||
armcpu_switchMode(armcpu, IRQ);
|
||||
armcpu->R[14] = armcpu->instruct_adr + 4;
|
||||
armcpu->SPSR = tmp;
|
||||
armcpu->CPSR.bits.T = 0;
|
||||
armcpu->CPSR.bits.I = 1;
|
||||
armcpu->next_instruction = armcpu->intVector + 0x18;
|
||||
armcpu->R[15] = armcpu->next_instruction;
|
||||
armcpu->waitIRQ = 0;
|
||||
armcpu_prefetch(armcpu);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL armcpu_prefetchExeption(armcpu_t *armcpu)
|
||||
{
|
||||
Status_Reg tmp;
|
||||
if(armcpu->CPSR.bits.I) return FALSE;
|
||||
tmp = armcpu->CPSR;
|
||||
armcpu_switchMode(armcpu, ABT);
|
||||
armcpu->R[14] = armcpu->instruct_adr + 4;
|
||||
armcpu->SPSR = tmp;
|
||||
armcpu->CPSR.bits.T = 0;
|
||||
armcpu->CPSR.bits.I = 1;
|
||||
armcpu->next_instruction = armcpu->intVector + 0xC;
|
||||
armcpu->R[15] = armcpu->next_instruction;
|
||||
armcpu->waitIRQ = 0;
|
||||
armcpu_prefetch(armcpu);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef ARM_CPU
|
||||
#define ARM_CPU
|
||||
|
||||
#include "types.h"
|
||||
#include "bits.h"
|
||||
#include "MMU.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ARMCPU_ARM7 1
|
||||
#define ARMCPU_ARM9 0
|
||||
|
||||
#define CODE(i) (((i)>>25)&0X7)
|
||||
#define OPCODE(i) (((i)>>21)&0xF)
|
||||
#define SIGNEBIT(i) BIT_N(i,20)
|
||||
|
||||
#define INSTRUCTION_INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF))
|
||||
|
||||
#define ROR(i, j) ((((u32)(i))>>(j)) | (((u32)(i))<<(32-(j))))
|
||||
|
||||
#define UNSIGNED_OVERFLOW(a,b,c) ((BIT31(a)&BIT31(b)) | \
|
||||
((BIT31(a)|BIT31(b))&BIT31(~c)))
|
||||
|
||||
#define UNSIGNED_UNDERFLOW(a,b,c) ((BIT31(~a)&BIT31(b)) | \
|
||||
((BIT31(~a)|BIT31(b))&BIT31(c)))
|
||||
|
||||
#define SIGNED_OVERFLOW(a,b,c) ((BIT31(a)&BIT31(b)&BIT31(~c))|\
|
||||
(BIT31(~a)&BIT31(~(b))&BIT31(c)))
|
||||
|
||||
#define SIGNED_UNDERFLOW(a,b,c) ((BIT31(a)&BIT31(~(b))&BIT31(~c))|\
|
||||
(BIT31(~a)&BIT31(b)&BIT31(c)))
|
||||
|
||||
#define EQ 0x0
|
||||
#define NE 0x1
|
||||
#define CS 0x2
|
||||
#define CC 0x3
|
||||
#define MI 0x4
|
||||
#define PL 0x5
|
||||
#define VS 0x6
|
||||
#define VC 0x7
|
||||
#define HI 0x8
|
||||
#define LS 0x9
|
||||
#define GE 0xA
|
||||
#define LT 0xB
|
||||
#define GT 0xC
|
||||
#define LE 0xD
|
||||
#define AL 0xE
|
||||
|
||||
#define TEST_COND(cond, CPSR) (((cond)==AL) ||\
|
||||
(((cond)==EQ) && ( CPSR.bits.Z))||\
|
||||
(((cond)==NE) && (!CPSR.bits.Z))||\
|
||||
(((cond)==CS) && ( CPSR.bits.C))||\
|
||||
(((cond)==CC) && (!CPSR.bits.C))||\
|
||||
(((cond)==MI) && ( CPSR.bits.N))||\
|
||||
(((cond)==PL) && (!CPSR.bits.N))||\
|
||||
(((cond)==VS) && ( CPSR.bits.V))||\
|
||||
(((cond)==VC) && (!CPSR.bits.V))||\
|
||||
(((cond)==HI) && (CPSR.bits.C) && (!CPSR.bits.Z))||\
|
||||
(((cond)==LS) && ((CPSR.bits.Z) || (!CPSR.bits.C)))||\
|
||||
(((cond)==GE) && (CPSR.bits.N==CPSR.bits.V))||\
|
||||
(((cond)==LT) && (CPSR.bits.N!=CPSR.bits.V))||\
|
||||
(((cond)==GT) && (CPSR.bits.Z==0) && (CPSR.bits.N==CPSR.bits.V))||\
|
||||
(((cond)==LE) && ((CPSR.bits.Z) || (CPSR.bits.N!=CPSR.bits.V))))
|
||||
|
||||
enum Mode
|
||||
{
|
||||
USR = 0x10,
|
||||
FIQ = 0x11,
|
||||
IRQ = 0x12,
|
||||
SVC = 0x13,
|
||||
ABT = 0x17,
|
||||
UND = 0x1B,
|
||||
SYS = 0x1F
|
||||
};
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 N : 1,
|
||||
Z : 1,
|
||||
C : 1,
|
||||
V : 1,
|
||||
Q : 1,
|
||||
RAZ : 19,
|
||||
I : 1,
|
||||
F : 1,
|
||||
T : 1,
|
||||
mode : 5;
|
||||
} bits;
|
||||
u32 val;
|
||||
} Status_Reg;
|
||||
#else
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 mode : 5,
|
||||
T : 1,
|
||||
F : 1,
|
||||
I : 1,
|
||||
RAZ : 19,
|
||||
Q : 1,
|
||||
V : 1,
|
||||
C : 1,
|
||||
Z : 1,
|
||||
N : 1;
|
||||
} bits;
|
||||
u32 val;
|
||||
} Status_Reg;
|
||||
#endif
|
||||
|
||||
typedef void* armcp_t;
|
||||
|
||||
typedef struct armcpu_t
|
||||
{
|
||||
u32 proc_ID;
|
||||
u32 instruction; //4
|
||||
u32 instruct_adr; //8
|
||||
u32 next_instruction; //12
|
||||
|
||||
u32 R[16]; //16
|
||||
Status_Reg CPSR; //80
|
||||
Status_Reg SPSR;
|
||||
|
||||
u32 R13_usr, R14_usr;
|
||||
u32 R13_svc, R14_svc;
|
||||
u32 R13_abt, R14_abt;
|
||||
u32 R13_und, R14_und;
|
||||
u32 R13_irq, R14_irq;
|
||||
u32 R8_fiq, R9_fiq, R10_fiq, R11_fiq, R12_fiq, R13_fiq, R14_fiq;
|
||||
Status_Reg SPSR_svc, SPSR_abt, SPSR_und, SPSR_irq, SPSR_fiq;
|
||||
|
||||
armcp_t *coproc[16];
|
||||
|
||||
u32 intVector;
|
||||
u8 LDTBit; //1 : ARMv5 style 0 : non ARMv5
|
||||
BOOL waitIRQ;
|
||||
BOOL wIRQ;
|
||||
BOOL wirq;
|
||||
|
||||
|
||||
u32 (* *swi_tab)(struct armcpu_t * cpu);
|
||||
|
||||
} armcpu_t;
|
||||
|
||||
int armcpu_new(armcpu_t *armcpu, u32 id);
|
||||
void armcpu_init(armcpu_t *armcpu, u32 adr);
|
||||
u32 armcpu_switchMode(armcpu_t *armcpu, u8 mode);
|
||||
u32 armcpu_prefetch(armcpu_t *armcpu);
|
||||
u32 armcpu_exec(armcpu_t *armcpu);
|
||||
BOOL armcpu_irqExeption(armcpu_t *armcpu);
|
||||
BOOL armcpu_prefetchExeption(armcpu_t *armcpu);
|
||||
|
||||
extern armcpu_t NDS_ARM7;
|
||||
extern armcpu_t NDS_ARM9;
|
||||
|
||||
static INLINE void NDS_makeARM9Int(u32 num)
|
||||
{
|
||||
MMU.reg_IF[0] |= (1<<num);// & (MMU.reg_IME[0] << num);//& (MMU.reg_IE[0] & (1<<num));
|
||||
NDS_ARM9.wIRQ = TRUE;
|
||||
}
|
||||
|
||||
static INLINE void NDS_makeARM7Int(u32 num)
|
||||
{
|
||||
MMU.reg_IF[1] |= (1<<num);// & (MMU.reg_IME[1] << num);// (MMU.reg_IE[1] & (1<<num));
|
||||
NDS_ARM7.wIRQ = TRUE;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,32 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef BIOS_H
|
||||
#define BIOS_H
|
||||
|
||||
#include "armcpu.h"
|
||||
|
||||
extern u32 (* ARM9_swi_tab[32])(armcpu_t * cpu);
|
||||
extern u32 (* ARM7_swi_tab[32])(armcpu_t * cpu);
|
||||
extern u32 wait4IRQ(armcpu_t * cpu);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef BITS_H
|
||||
#define BITS_H
|
||||
|
||||
#define BIT(n) (1<<(n))
|
||||
|
||||
#define BIT_N(i,n) (((i)>>(n))&1)
|
||||
#define BIT0(i) ((i)&1)
|
||||
#define BIT1(i) BIT_N(i,1)
|
||||
#define BIT2(i) BIT_N(i,2)
|
||||
#define BIT3(i) BIT_N(i,3)
|
||||
#define BIT4(i) BIT_N(i,4)
|
||||
#define BIT5(i) BIT_N(i,5)
|
||||
#define BIT6(i) BIT_N(i,6)
|
||||
#define BIT7(i) BIT_N(i,7)
|
||||
#define BIT8(i) BIT_N(i,8)
|
||||
#define BIT9(i) BIT_N(i,9)
|
||||
#define BIT10(i) BIT_N(i,10)
|
||||
#define BIT11(i) BIT_N(i,11)
|
||||
#define BIT12(i) BIT_N(i,12)
|
||||
#define BIT13(i) BIT_N(i,13)
|
||||
#define BIT14(i) BIT_N(i,14)
|
||||
#define BIT15(i) BIT_N(i,15)
|
||||
#define BIT16(i) BIT_N(i,16)
|
||||
#define BIT17(i) BIT_N(i,17)
|
||||
#define BIT18(i) BIT_N(i,18)
|
||||
#define BIT19(i) BIT_N(i,19)
|
||||
#define BIT20(i) BIT_N(i,20)
|
||||
#define BIT21(i) BIT_N(i,21)
|
||||
#define BIT22(i) BIT_N(i,22)
|
||||
#define BIT23(i) BIT_N(i,23)
|
||||
#define BIT24(i) BIT_N(i,24)
|
||||
#define BIT25(i) BIT_N(i,25)
|
||||
#define BIT26(i) BIT_N(i,26)
|
||||
#define BIT27(i) BIT_N(i,27)
|
||||
#define BIT28(i) BIT_N(i,28)
|
||||
#define BIT29(i) BIT_N(i,29)
|
||||
#define BIT30(i) BIT_N(i,30)
|
||||
#define BIT31(i) ((i)>>31)
|
||||
|
||||
#define CONDITION(i) (i)>>28
|
||||
|
||||
#define REG_POS(i,n) (((i)>>n)&0xF)
|
||||
|
||||
#endif
|
|
@ -0,0 +1,4 @@
|
|||
configure
|
||||
make clean
|
||||
make
|
||||
pause
|
|
@ -0,0 +1,675 @@
|
|||
/*
|
||||
CFLASH.C
|
||||
CompactFlash/FAT emulation routines for DeSmuME
|
||||
/Mic, 2006
|
||||
|
||||
Logical memory layout:
|
||||
|
||||
----------------------
|
||||
| MBR |
|
||||
----------------------
|
||||
| FAT |
|
||||
----------------------
|
||||
| Root entries |
|
||||
----------------------
|
||||
| Subdirectories |
|
||||
----------------------
|
||||
| File data |
|
||||
----------------------
|
||||
|
||||
*/
|
||||
|
||||
#include "fs.h"
|
||||
#include "cflash.h"
|
||||
#include "NDSSystem.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define SECPERFAT 128
|
||||
#define SECPERCLUS 16
|
||||
#define MAXFILES 32768
|
||||
#define SECRESV 2
|
||||
#define NUMSECTORS 0x80000
|
||||
#define NUMCLUSTERS (NUMSECTORS/SECPERCLUS)
|
||||
#define BYTESPERCLUS (512*SECPERCLUS)
|
||||
#define DIRENTSPERCLUS ((BYTESPERCLUS)/32)
|
||||
|
||||
|
||||
u16 cf_reg_data,cf_reg_err,cf_reg_sec,cf_reg_lba1,cf_reg_lba2,
|
||||
cf_reg_lba3,cf_reg_lba4,cf_reg_cmd,cf_reg_sts;
|
||||
unsigned int CF_REG_DATA,CF_REG_ERR,CF_REG_SEC,CF_REG_LBA1,CF_REG_LBA2,
|
||||
CF_REG_LBA3,CF_REG_LBA4,CF_REG_CMD,CF_REG_STS;
|
||||
|
||||
BOOT_RECORD MBR;
|
||||
DIR_ENT *files,*dirEntries,**dirEntryPtr;
|
||||
FILE_INFO *fileLink,*dirEntryLink;
|
||||
u32 currLBA;
|
||||
u32 filesysFAT,filesysRootDir,filesysData;
|
||||
u16 FAT16[SECPERFAT*256];
|
||||
u16 numExtraEntries[SECPERFAT*256];
|
||||
DIR_ENT *extraDirEntries[SECPERFAT*256];
|
||||
int numFiles,maxLevel,dirNum,numRootFiles;
|
||||
int *dirEntriesInCluster,clusterNum,
|
||||
firstDirEntCluster,lastDirEntCluster,
|
||||
lastFileDataCluster;
|
||||
char *sRomPath;
|
||||
int activeDirEnt=-1;
|
||||
u32 bufferStart;
|
||||
u32 fileStartLBA,fileEndLBA;
|
||||
u16 freadBuffer[256];
|
||||
u32 dwBytesRead;
|
||||
FILE * hFile;
|
||||
char fpath[255+1];
|
||||
BOOL cflashDeviceEnabled = FALSE;
|
||||
char buffer[256];
|
||||
u32 dummy;
|
||||
|
||||
|
||||
int lfn_checksum() {
|
||||
int i;
|
||||
u8 chk;
|
||||
|
||||
chk = 0;
|
||||
for (i=0; i < 11; i++) {
|
||||
chk = ((chk & 1) ? 0x80 : 0) + (chk >> 1) + (i < 8 ? files[numFiles].name[i] : files[numFiles].ext[i - 8]);
|
||||
}
|
||||
return chk;
|
||||
}
|
||||
|
||||
|
||||
const int lfnPos[13] = {1,3,5,7,9,14,16,18,20,22,24,28,30};
|
||||
|
||||
|
||||
/* Add a DIR_ENT for the files */
|
||||
void add_file(char *fname, FsEntry * entry, int fileLevel) {
|
||||
int i,j,k,n;
|
||||
u8 chk;
|
||||
char *p;
|
||||
|
||||
if (numFiles < MAXFILES-1) {
|
||||
if (strcmp(fname,"..") != 0) {
|
||||
for (i=strlen(fname)-1; i>=0; i--)
|
||||
if (fname[i]=='.') break;
|
||||
if ((i==0)&&(strcmp(fname,".")==0)) i = 1;
|
||||
if (i<0) i = strlen(fname);
|
||||
for (j=0; j<i; j++)
|
||||
files[numFiles].name[j] = fname[j];
|
||||
for (; j<8; j++)
|
||||
files[numFiles].name[j] = 0x20;
|
||||
for (j=0; j<3; j++) {
|
||||
if ((j+i+1)>=strlen(fname)) break;
|
||||
files[numFiles].ext[j] = fname[j+i+1];
|
||||
}
|
||||
for (; j<3; j++)
|
||||
files[numFiles].ext[j] = 0x20;
|
||||
|
||||
fileLink[fileLevel].filesInDir += 1;
|
||||
|
||||
// See if LFN entries need to be added
|
||||
if (strlen(entry->cAlternateFileName)>0) {
|
||||
chk = lfn_checksum();
|
||||
k = (strlen(entry->cFileName)/13) + (((strlen(entry->cFileName)%13)!=0)?1:0);
|
||||
numFiles += k;
|
||||
|
||||
fileLink[fileLevel].filesInDir += k;
|
||||
|
||||
n = 0;
|
||||
j = 13;
|
||||
for (i=0; i<strlen(entry->cFileName); i++) {
|
||||
if (j == 13) {
|
||||
n++;
|
||||
p = (char*)&files[numFiles-n].name[0];
|
||||
fileLink[numFiles-n].parent = fileLevel;
|
||||
p[0] = n;
|
||||
((DIR_ENT*)p)->attrib = ATTRIB_LFN;
|
||||
p[0xD] = chk;
|
||||
j = 0;
|
||||
}
|
||||
*(p + lfnPos[j]) = entry->cFileName[i];
|
||||
*(p + lfnPos[j]+1) = 0;
|
||||
j++;
|
||||
}
|
||||
for (; j<13; j++) {
|
||||
*(p + lfnPos[j]) = entry->cFileName[i];
|
||||
*(p + lfnPos[j]+1) = 0;
|
||||
}
|
||||
p[0] |= 0x40; // END
|
||||
for (i=strlen(fname)-1; i>=0; i--)
|
||||
if (fname[i]=='.') break;
|
||||
if ((i==0)&&(strcmp(fname,".")==0)) i = 1;
|
||||
if (i<0) i = strlen(fname);
|
||||
for (j=0; j<i; j++)
|
||||
files[numFiles].name[j] = fname[j];
|
||||
for (; j<8; j++)
|
||||
files[numFiles].name[j] = 0x20;
|
||||
for (j=0; j<3; j++) {
|
||||
if ((j+i+1)>=strlen(fname)) break;
|
||||
files[numFiles].ext[j] = fname[j+i+1];
|
||||
}
|
||||
for (; j<3; j++)
|
||||
files[numFiles].ext[j] = 0x20;
|
||||
}
|
||||
|
||||
//files[numFiles].fileSize = entry->nFileSizeLow;
|
||||
files[numFiles].fileSize = 0;
|
||||
|
||||
if (entry->flags & FS_IS_DIR) {
|
||||
if (strcmp(fname,".")==0)
|
||||
fileLink[numFiles].level = maxLevel;
|
||||
else
|
||||
fileLink[numFiles].level = maxLevel+1;
|
||||
files[numFiles].attrib = ATTRIB_DIR;
|
||||
} else {
|
||||
files[numFiles].attrib = 0;
|
||||
}
|
||||
|
||||
fileLink[numFiles].parent = fileLevel;
|
||||
|
||||
numFiles++;
|
||||
} else if (fileLevel > 0) {
|
||||
fileLink[fileLevel].filesInDir += 1;
|
||||
strncpy((char*)&files[numFiles].name[0],".. ",8);
|
||||
strncpy((char*)&files[numFiles].ext[0]," ",3);
|
||||
fileLink[numFiles].parent = fileLevel;
|
||||
files[numFiles].attrib = 0x10;
|
||||
numFiles++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* List all files and subdirectories recursively */
|
||||
void list_files(char *fpath) {
|
||||
void * hFind;
|
||||
FsEntry entry;
|
||||
char DirSpec[255 + 1],SubDir[255+1];
|
||||
u32 dwError;
|
||||
char *fname;
|
||||
int i,j;
|
||||
int fileLevel;
|
||||
|
||||
maxLevel++;
|
||||
fileLevel = maxLevel;
|
||||
|
||||
strncpy(DirSpec, fpath, strlen(fpath)+1);
|
||||
|
||||
hFind = FsReadFirst(DirSpec, &entry);
|
||||
|
||||
if (hFind == NULL) {
|
||||
return;
|
||||
} else {
|
||||
fname = (strlen(entry.cAlternateFileName)>0)?entry.cAlternateFileName:entry.cFileName;
|
||||
add_file(fname, &entry, fileLevel);
|
||||
|
||||
while (FsReadNext(hFind, &entry) != 0) {
|
||||
fname = (strlen(entry.cAlternateFileName)>0)?entry.cAlternateFileName:entry.cFileName;
|
||||
add_file(fname, &entry, fileLevel);
|
||||
|
||||
if (numFiles==MAXFILES-1) break;
|
||||
|
||||
if ((entry.flags & FS_IS_DIR) && (strcmp(fname, ".")) && (strcmp(fname, ".."))) {
|
||||
sprintf(SubDir, "%s%c%s", fpath, FS_SEPARATOR, fname);
|
||||
list_files(SubDir);
|
||||
}
|
||||
}
|
||||
|
||||
dwError = FsError();
|
||||
FsClose(hFind);
|
||||
if (dwError != FS_ERR_NO_MORE_FILES) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (numFiles < MAXFILES) {
|
||||
fileLink[numFiles].parent = fileLevel;
|
||||
files[numFiles++].name[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Set up the MBR, FAT and DIR_ENTs */
|
||||
BOOL cflash_build_fat() {
|
||||
int i,j,k,l,
|
||||
clust,baseCluster,numClusters,
|
||||
clusterNum2,rootCluster;
|
||||
int fileLevel;
|
||||
|
||||
numFiles = 0;
|
||||
fileLevel = -1;
|
||||
maxLevel = -1;
|
||||
|
||||
sRomPath = szRomPath; // From MMU.cpp
|
||||
files = (DIR_ENT *) malloc(MAXFILES*sizeof(DIR_ENT));
|
||||
fileLink = (FILE_INFO *) malloc(MAXFILES*sizeof(FILE_INFO));
|
||||
if ((files == NULL) || (fileLink == NULL))
|
||||
return FALSE;
|
||||
|
||||
for (i=0; i<MAXFILES; i++) {
|
||||
files[i].attrib = 0;
|
||||
files[i].name[0] = FILE_FREE;
|
||||
files[i].fileSize = 0;
|
||||
|
||||
fileLink[i].filesInDir = 0;
|
||||
|
||||
extraDirEntries[i] = NULL;
|
||||
numExtraEntries[i] = 0;
|
||||
}
|
||||
|
||||
list_files(sRomPath);
|
||||
|
||||
k = 0;
|
||||
clusterNum = rootCluster = (SECRESV + SECPERFAT)/SECPERCLUS;
|
||||
numClusters = 0;
|
||||
clust = 0;
|
||||
numRootFiles = 0;
|
||||
|
||||
// Allocate memory to hold information about the files
|
||||
dirEntries = (DIR_ENT *) malloc(numFiles*sizeof(DIR_ENT));
|
||||
dirEntryLink = (FILE_INFO *) malloc(numFiles*sizeof(FILE_INFO));
|
||||
dirEntriesInCluster = (int *) malloc(NUMCLUSTERS*sizeof(int));
|
||||
dirEntryPtr = (DIR_ENT **) malloc(NUMCLUSTERS*sizeof(DIR_ENT*));
|
||||
if ((dirEntries==NULL) || (dirEntriesInCluster==NULL) || (dirEntryPtr==NULL))
|
||||
return FALSE;
|
||||
|
||||
for (i=0; i<NUMCLUSTERS; i++) {
|
||||
dirEntriesInCluster[i] = 0;
|
||||
dirEntryPtr[i] = NULL;
|
||||
}
|
||||
|
||||
// Change the hierarchical layout to a flat one
|
||||
for (i=0; i<=maxLevel; i++) {
|
||||
clusterNum2 = clusterNum;
|
||||
for (j=0; j<numFiles; j++) {
|
||||
if (fileLink[j].parent == i) {
|
||||
if (dirEntryPtr[clusterNum] == NULL)
|
||||
dirEntryPtr[clusterNum] = &dirEntries[k];
|
||||
dirEntryLink[k] = fileLink[j];
|
||||
dirEntries[k++] = files[j];
|
||||
if ((files[j].attrib & ATTRIB_LFN)==0) {
|
||||
if (files[j].attrib & ATTRIB_DIR) {
|
||||
if (strncmp((char*)&files[j].name[0],". ",8)==0) {
|
||||
dirEntries[k-1].startCluster = dirEntryLink[k-1].level;
|
||||
} else if (strncmp((char*)&files[j].name[0],".. ",8)==0) {
|
||||
dirEntries[k-1].startCluster = dirEntryLink[k-1].parent;
|
||||
} else {
|
||||
clust++;
|
||||
dirEntries[k-1].startCluster = clust;
|
||||
l = (fileLink[fileLink[j].level].filesInDir)>>8;
|
||||
clust += l;
|
||||
numClusters += l;
|
||||
}
|
||||
} else {
|
||||
dirEntries[k-1].startCluster = clusterNum;
|
||||
}
|
||||
}
|
||||
if (i==0) numRootFiles++;
|
||||
dirEntriesInCluster[clusterNum]++;
|
||||
if (dirEntriesInCluster[clusterNum]==256) {
|
||||
clusterNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
clusterNum = clusterNum2 + ((fileLink[i].filesInDir)>>8) + 1;
|
||||
numClusters++;
|
||||
}
|
||||
|
||||
// Free the file indexing buffer
|
||||
free(files);
|
||||
free(fileLink);
|
||||
|
||||
// Set up the MBR
|
||||
MBR.bytesPerSector = 512;
|
||||
MBR.numFATs = 1;
|
||||
strcpy((char*)&MBR.OEMName[0],"DESMUM");
|
||||
strcpy((char*)&MBR.fat16.fileSysType[0],"FAT16 ");
|
||||
MBR.reservedSectors = SECRESV;
|
||||
MBR.numSectors = 524288;
|
||||
MBR.numSectorsSmall = 0;
|
||||
MBR.sectorsPerCluster = SECPERCLUS;
|
||||
MBR.sectorsPerFAT = SECPERFAT;
|
||||
MBR.rootEntries = 512;
|
||||
MBR.fat16.signature = 0xAA55;
|
||||
MBR.mediaDesc = 1;
|
||||
|
||||
filesysFAT = 0 + MBR.reservedSectors;
|
||||
filesysRootDir = filesysFAT + (MBR.numFATs * MBR.sectorsPerFAT);
|
||||
filesysData = filesysRootDir + ((MBR.rootEntries * sizeof(DIR_ENT)) / 512);
|
||||
|
||||
// Set up the cluster values for all subdirectories
|
||||
clust = filesysData / SECPERCLUS;
|
||||
firstDirEntCluster = clust;
|
||||
for (i=1; i<numFiles; i++) {
|
||||
if (((dirEntries[i].attrib & ATTRIB_DIR)!=0) &&
|
||||
((dirEntries[i].attrib & ATTRIB_LFN)==0)) {
|
||||
if (dirEntries[i].startCluster > rootCluster)
|
||||
dirEntries[i].startCluster += clust-rootCluster;
|
||||
}
|
||||
}
|
||||
lastDirEntCluster = clust+numClusters-1;
|
||||
|
||||
// Set up the cluster values for all files
|
||||
clust += numClusters; //clusterNum;
|
||||
for (i=0; i<numFiles; i++) {
|
||||
if (((dirEntries[i].attrib & ATTRIB_DIR)==0) &&
|
||||
((dirEntries[i].attrib & ATTRIB_LFN)==0)) {
|
||||
dirEntries[i].startCluster = clust;
|
||||
clust += (dirEntries[i].fileSize/(512*SECPERCLUS));
|
||||
clust++;
|
||||
}
|
||||
}
|
||||
lastFileDataCluster = clust-1;
|
||||
|
||||
// Set up the FAT16
|
||||
memset(FAT16,0,SECPERFAT*256*sizeof(u16));
|
||||
FAT16[0] = 0xFF01;
|
||||
FAT16[1] = 0xFFFF;
|
||||
for (i=2; i<=lastDirEntCluster; i++)
|
||||
FAT16[i] = 0xFFFF;
|
||||
k = 2;
|
||||
for (i=0; i<numFiles; i++) {
|
||||
if (((dirEntries[i].attrib & ATTRIB_LFN)==0) &&
|
||||
(dirEntries[i].name[0] != FILE_FREE)) {
|
||||
j = 0;
|
||||
l = dirEntries[i].fileSize - (512*SECPERCLUS);
|
||||
while (l > 0) {
|
||||
if (dirEntries[i].startCluster+j < MAXFILES)
|
||||
FAT16[dirEntries[i].startCluster+j] = dirEntries[i].startCluster+j+1;
|
||||
j++;
|
||||
l -= (512*16);
|
||||
}
|
||||
if ((dirEntries[i].attrib & ATTRIB_DIR)==0) {
|
||||
if (dirEntries[i].startCluster+j < MAXFILES)
|
||||
FAT16[dirEntries[i].startCluster+j] = 0xFFFF;
|
||||
}
|
||||
k = dirEntries[i].startCluster+j;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=(filesysData/SECPERCLUS); i<NUMCLUSTERS; i++) {
|
||||
if (dirEntriesInCluster[i]==256)
|
||||
FAT16[i] = i+1;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOL cflash_init() {
|
||||
cflashDeviceEnabled = FALSE;
|
||||
currLBA = 0;
|
||||
|
||||
/* Set up addresses for M3CF */
|
||||
/*CF_REG_DATA = 0x8800000;
|
||||
CF_REG_ERR = 0x8820000;
|
||||
CF_REG_SEC = 0x8840000;
|
||||
CF_REG_LBA1 = 0x8860000;
|
||||
CF_REG_LBA2 = 0x8880000;
|
||||
CF_REG_LBA3 = 0x88A0000;
|
||||
CF_REG_LBA4 = 0x88C0000;
|
||||
CF_REG_CMD = 0x88E0000;
|
||||
CF_REG_STS = 0x80C0000;*/
|
||||
|
||||
/* Set up addresses for GBAMP */
|
||||
CF_REG_DATA = 0x9000000;
|
||||
CF_REG_ERR = 0x9020000;
|
||||
CF_REG_SEC = 0x9040000;
|
||||
CF_REG_LBA1 = 0x9060000;
|
||||
CF_REG_LBA2 = 0x9080000;
|
||||
CF_REG_LBA3 = 0x90A0000;
|
||||
CF_REG_LBA4 = 0x90C0000;
|
||||
CF_REG_CMD = 0x90E0000;
|
||||
CF_REG_STS = 0x98C0000;
|
||||
|
||||
if (activeDirEnt != -1)
|
||||
fclose(hFile);
|
||||
activeDirEnt = -1;
|
||||
fileStartLBA = fileEndLBA = 0xFFFFFFFF;
|
||||
if (!cflash_build_fat())
|
||||
return FALSE;
|
||||
cf_reg_sts = 0x58; // READY
|
||||
|
||||
cflashDeviceEnabled = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Convert a space-padded 8.3 filename into an asciiz string */
|
||||
void fatstring_to_asciiz(int dirent,char *out,DIR_ENT *d) {
|
||||
int i,j;
|
||||
DIR_ENT *pd;
|
||||
|
||||
if (d == NULL)
|
||||
pd = &dirEntries[dirent];
|
||||
else
|
||||
pd = d;
|
||||
|
||||
for (i=0; i<8; i++) {
|
||||
if (pd->name[i] == ' ') break;
|
||||
out[i] = pd->name[i];
|
||||
}
|
||||
if ((pd->attrib & 0x10)==0) {
|
||||
out[i++] = '.';
|
||||
for (j=0; j<3; j++) {
|
||||
if (pd->ext[j] == ' ') break;
|
||||
out[i++] = pd->ext[j];
|
||||
}
|
||||
}
|
||||
out[i] = '\0';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Resolve the path of a files by working backwards through the directory entries */
|
||||
void resolve_path(int dirent) {
|
||||
int i;
|
||||
char dirname[128];
|
||||
|
||||
while (dirEntryLink[dirent].parent > 0) {
|
||||
for (i=0; i<dirent; i++) {
|
||||
if ((dirEntryLink[dirent].parent==dirEntryLink[i].level) &&
|
||||
((dirEntries[i].attrib&ATTRIB_DIR)!=0)) {
|
||||
fatstring_to_asciiz(i,dirname,NULL);
|
||||
strcat(fpath,dirname);
|
||||
strcat(fpath,"\\");
|
||||
dirent = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read from a file using a 512 byte buffer */
|
||||
u16 fread_buffered(int dirent,u32 cluster,u32 offset) {
|
||||
char fname[32];
|
||||
int i,j;
|
||||
|
||||
offset += cluster*512*SECPERCLUS;
|
||||
|
||||
if (dirent == activeDirEnt) {
|
||||
if ((offset < bufferStart) || (offset >= bufferStart + 512)) {
|
||||
//SetFilePointer(hFile,offset,NULL,FILE_BEGIN);
|
||||
fseek(hFile, offset, SEEK_SET);
|
||||
//ReadFile(hFile,&freadBuffer,512,&dwBytesRead,NULL);
|
||||
fread(&freadBuffer, 1, 512, hFile);
|
||||
bufferStart = offset;
|
||||
}
|
||||
|
||||
return freadBuffer[(offset-bufferStart)>>1];
|
||||
}
|
||||
if (activeDirEnt != -1)
|
||||
//CloseHandle(hFile);
|
||||
fclose(hFile);
|
||||
|
||||
strcpy(fpath,sRomPath);
|
||||
strcat(fpath,"\\");
|
||||
|
||||
resolve_path(dirent);
|
||||
|
||||
fatstring_to_asciiz(dirent,fname,NULL);
|
||||
strcat(fpath,fname);
|
||||
|
||||
hFile = fopen(fpath, "w");
|
||||
if (!hFile)
|
||||
return 0;
|
||||
fread(&freadBuffer, 1, 512, hFile);
|
||||
|
||||
bufferStart = offset;
|
||||
activeDirEnt = dirent;
|
||||
fileStartLBA = (dirEntries[dirent].startCluster*512*SECPERCLUS);
|
||||
fileEndLBA = fileStartLBA + dirEntries[dirent].fileSize;
|
||||
|
||||
return freadBuffer[(offset-bufferStart)>>1];
|
||||
}
|
||||
|
||||
/* Read from one of the CF device registers */
|
||||
unsigned int cflash_read(unsigned int address) {
|
||||
unsigned char *p;
|
||||
u16 s;
|
||||
int i;
|
||||
u32 cluster,cluster2,cluster3,fileLBA;
|
||||
|
||||
if (address == CF_REG_STS) {
|
||||
s = cf_reg_sts;
|
||||
return s;
|
||||
|
||||
} else if (address == CF_REG_DATA) {
|
||||
cluster = (currLBA / (512 * SECPERCLUS));
|
||||
cluster2 = (((currLBA/512) - filesysData) / SECPERCLUS) + 2;
|
||||
|
||||
if (cf_reg_cmd == 0x20) {
|
||||
// Reading from the MBR
|
||||
if (currLBA < 512) {
|
||||
p = (unsigned char*)&MBR;
|
||||
s = T1ReadWord(p, currLBA);
|
||||
|
||||
// Reading the FAT
|
||||
} else if ((currLBA >= filesysFAT*512) && (currLBA < filesysRootDir*512)) {
|
||||
p = (unsigned char*)&FAT16[0];
|
||||
s = T1ReadWord(p, currLBA - filesysFAT * 512);
|
||||
|
||||
// Reading directory entries
|
||||
} else if ((currLBA >= filesysRootDir*512) &&
|
||||
(cluster <= lastDirEntCluster)) {
|
||||
cluster3 = ((currLBA - (SECRESV * 512)) / (512 * SECPERCLUS));
|
||||
i = (currLBA-(((cluster3-(filesysRootDir/SECPERCLUS))*SECPERCLUS+filesysRootDir)*512)); //(currLBA - cluster*BYTESPERCLUS);
|
||||
if (i < (dirEntriesInCluster[cluster3]*32)) {
|
||||
|
||||
p = (unsigned char*)dirEntryPtr[cluster3];
|
||||
s = T1ReadWord(p, i);
|
||||
} else {
|
||||
i /= 32;
|
||||
i -= dirEntriesInCluster[cluster3];
|
||||
if ((i>=0)&&(i<numExtraEntries[cluster3])) {
|
||||
p = (unsigned char*)extraDirEntries[cluster3];
|
||||
s = T1ReadWord(p, i * 32 + (currLBA & 0x1F));
|
||||
} else if ((currLBA&0x1F)==0) {
|
||||
s = FILE_FREE;
|
||||
} else {
|
||||
s = 0;
|
||||
}
|
||||
}
|
||||
// Reading file data
|
||||
} else if ((cluster2 > lastDirEntCluster) && (cluster2 <= lastFileDataCluster)) { //else if ((cluster>lastDirEntCluster)&&(cluster<=lastFileDataCluster)) {
|
||||
fileLBA = currLBA - (filesysData-32)*512; // 32 = # sectors used for the root entries
|
||||
|
||||
// Check if the read is from the currently opened file
|
||||
if ((fileLBA >= fileStartLBA) && (fileLBA < fileEndLBA)) {
|
||||
cluster = (fileLBA / (512 * SECPERCLUS));
|
||||
s = fread_buffered(activeDirEnt,cluster-dirEntries[activeDirEnt].startCluster,(fileLBA-fileStartLBA)&(BYTESPERCLUS-1));
|
||||
} else {
|
||||
for (i=0; i<numFiles; i++) {
|
||||
if ((fileLBA>=(dirEntries[i].startCluster*512*SECPERCLUS)) &&
|
||||
(fileLBA <(dirEntries[i].startCluster*512*SECPERCLUS)+dirEntries[i].fileSize) &&
|
||||
((dirEntries[i].attrib & (ATTRIB_DIR|ATTRIB_LFN))==0)) {
|
||||
cluster = (fileLBA / (512 * SECPERCLUS));
|
||||
s = fread_buffered(i,cluster-dirEntries[i].startCluster,fileLBA&(BYTESPERCLUS-1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
currLBA += 2;
|
||||
return s;
|
||||
}
|
||||
|
||||
} else if (address == CF_REG_CMD) {
|
||||
s = 0;
|
||||
return 0;
|
||||
|
||||
} else if (address == CF_REG_LBA1) {
|
||||
s = cf_reg_lba1;
|
||||
return s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Write to one of the CF device registers */
|
||||
void cflash_write(unsigned int address,unsigned int data) {
|
||||
u32 cluster,cluster2,cluster3,fileLBA;
|
||||
int i,j,k,l;
|
||||
unsigned char *p;
|
||||
u16 s;
|
||||
DIR_ENT *d;
|
||||
|
||||
if (address==CF_REG_STS) {
|
||||
cf_reg_sts = data&0xFFFF;
|
||||
|
||||
} else if (address==CF_REG_DATA) {
|
||||
|
||||
} else if (address==CF_REG_CMD) {
|
||||
cf_reg_cmd = data&0xFF;
|
||||
cf_reg_sts = 0x58; // READY
|
||||
|
||||
} else if (address==CF_REG_LBA1) {
|
||||
cf_reg_lba1 = data&0xFF;
|
||||
currLBA = (currLBA&0xFFFFFF00)|cf_reg_lba1;
|
||||
|
||||
} else if (address==CF_REG_LBA2) {
|
||||
cf_reg_lba2 = data&0xFF;
|
||||
currLBA = (currLBA&0xFFFF00FF)|(cf_reg_lba2<<8);
|
||||
|
||||
} else if (address==CF_REG_LBA3) {
|
||||
cf_reg_lba3 = data&0xFF;
|
||||
currLBA = (currLBA&0xFF00FFFF)|(cf_reg_lba3<<16);
|
||||
|
||||
} else if (address==CF_REG_LBA4) {
|
||||
cf_reg_lba4 = data&0xFF;
|
||||
currLBA = (currLBA&0x00FFFFFF)|((cf_reg_lba4&0x0F)<<24);
|
||||
currLBA *= 512;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void cflash_close() {
|
||||
int i;
|
||||
|
||||
if (cflashDeviceEnabled) {
|
||||
cflashDeviceEnabled = FALSE;
|
||||
|
||||
for (i=0; i<MAXFILES; i++) {
|
||||
if (extraDirEntries[i] != NULL)
|
||||
free(extraDirEntries[i]);
|
||||
}
|
||||
|
||||
if (dirEntries != NULL)
|
||||
free(dirEntries);
|
||||
|
||||
if (dirEntryLink != NULL)
|
||||
free(dirEntryLink);
|
||||
|
||||
if (activeDirEnt != -1)
|
||||
fclose(hFile);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
CFLASH.H
|
||||
Mic, 2006
|
||||
*/
|
||||
|
||||
#ifndef __CFLASH_H__
|
||||
#define __CFLASH_H__
|
||||
|
||||
#include "fat.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int level,parent,filesInDir;
|
||||
} FILE_INFO;
|
||||
|
||||
|
||||
BOOL cflash_init();
|
||||
|
||||
unsigned int cflash_read(unsigned int address);
|
||||
|
||||
void cflash_write(unsigned int address,unsigned int data);
|
||||
|
||||
void cflash_close();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,4 @@
|
|||
bin_PROGRAMS = desmume-cli
|
||||
desmume_cli_SOURCES = main.c ../sndsdl.c
|
||||
desmume_cli_LDADD = ../libdesmume.a $(SDL_LIBS)
|
||||
desmume_cli_CFLAGS = $(SDL_CFLAGS)
|
|
@ -0,0 +1,138 @@
|
|||
#include "SDL.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include "../MMU.h"
|
||||
#include "../NDSSystem.h"
|
||||
#include "../cflash.h"
|
||||
#include "../debug.h"
|
||||
#include "../sndsdl.h"
|
||||
|
||||
volatile BOOL execute = FALSE;
|
||||
|
||||
SDL_Surface * surface;
|
||||
|
||||
SoundInterface_struct *SNDCoreList[] = {
|
||||
&SNDDummy,
|
||||
&SNDFile,
|
||||
&SNDSDL,
|
||||
NULL
|
||||
};
|
||||
|
||||
int Draw() {
|
||||
SDL_Surface *rawImage;
|
||||
|
||||
rawImage = SDL_CreateRGBSurfaceFrom((void*)&GPU_screen, 256, 384, 16, 512, 0x001F, 0x03E0, 0x7C00, 0);
|
||||
if(rawImage == NULL) return 1;
|
||||
|
||||
SDL_BlitSurface(rawImage, 0, surface, 0);
|
||||
SDL_UpdateRect(surface, 0, 0, 0, 0);
|
||||
|
||||
SDL_FreeSurface(rawImage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
BOOL click;
|
||||
unsigned short keypad;
|
||||
SDL_Event event;
|
||||
int end = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
LogStart();
|
||||
#endif
|
||||
NDS_Init();
|
||||
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "usage: %s filename\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (NDS_LoadROM(argv[1], MC_TYPE_AUTODETECT, 1) < 0) {
|
||||
fprintf(stderr, "error while loading %s\n", argv[1]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* // This has to get fixed yet
|
||||
strcpy(szRomPath, dirname(argv[1]));
|
||||
cflash_close();
|
||||
cflash_init();
|
||||
*/
|
||||
|
||||
execute = TRUE;
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
SDL_WM_SetCaption("Desmume SDL", NULL);
|
||||
|
||||
surface = SDL_SetVideoMode(256, 384, 32, SDL_SWSURFACE);
|
||||
|
||||
while(!end) {
|
||||
|
||||
|
||||
|
||||
|
||||
keypad=0x0000;
|
||||
|
||||
Uint8 *keys;
|
||||
keys = SDL_GetKeyState(NULL);
|
||||
if(keys[SDLK_UP]) keypad |= 0x40;
|
||||
if(keys[SDLK_DOWN]) keypad |= 0x80;
|
||||
if(keys[SDLK_RIGHT]) keypad |= 0x10;
|
||||
if(keys[SDLK_LEFT]) keypad |= 0x20;
|
||||
if(keys[SDLK_SPACE]) keypad |= 0x1;
|
||||
if(keys['b']) keypad |= 0x2;
|
||||
if(keys[SDLK_BACKSPACE]) keypad |= 0x4;
|
||||
if(keys[SDLK_RETURN]) keypad |= 0x8;
|
||||
if(keys['0']) keypad |= 0x200;
|
||||
if(keys['.']) keypad |= 0x100;
|
||||
|
||||
((unsigned short *)ARM9Mem.ARM9_REG)[0x130>>1] = ~keypad;
|
||||
((unsigned short *)MMU.ARM7_REG)[0x130>>1] = ~keypad;
|
||||
|
||||
|
||||
if (SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_QUIT:
|
||||
end = 1;
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN: // Un bouton fut appuyé
|
||||
if(event.button.button==1) click=TRUE;
|
||||
|
||||
case SDL_MOUSEMOTION: // La souris a été déplacée sur l?écran
|
||||
|
||||
if(!click) break;
|
||||
|
||||
if(event.button.y>=192)
|
||||
{
|
||||
signed long x = event.button.x;
|
||||
signed long y = event.button.y - 192;
|
||||
if(x<0) x = 0; else if(x>255) x = 255;
|
||||
if(y<0) y = 0; else if(y>192) y = 192;
|
||||
NDS_setTouchPos(x, y);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP: // Le bouton de la souris a été relaché
|
||||
if(click)NDS_releasTouch();
|
||||
click=FALSE;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
NDS_exec(1120380, FALSE);
|
||||
SPU_Emulate();
|
||||
Draw();
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
NDS_DeInit();
|
||||
#ifdef DEBUG
|
||||
LogStop();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef __CONFIG_H__
|
||||
#define __CONFIG_H__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#endif /*__CONFIG_H__*/
|
||||
|
|
@ -0,0 +1,388 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "cp15.h"
|
||||
#include "debug.h"
|
||||
#include "MMU.h"
|
||||
|
||||
armcp15_t *armcp15_new(armcpu_t * c)
|
||||
{
|
||||
armcp15_t *armcp15 = (armcp15_t*)malloc(sizeof(armcp15_t));
|
||||
if(!armcp15) return NULL;
|
||||
|
||||
armcp15->cpu = c;
|
||||
armcp15->IDCode = 0x41049460;
|
||||
armcp15->cacheType = 0x0F0D2112;
|
||||
armcp15->TCMSize = 0x00140140;
|
||||
armcp15->ctrl = 0x00000000;
|
||||
armcp15->DCConfig = 0x0;
|
||||
armcp15->ICConfig = 0x0;
|
||||
armcp15->writeBuffCtrl = 0x0;
|
||||
armcp15->und = 0x0;
|
||||
armcp15->DaccessPerm = 0x22222222;
|
||||
armcp15->IaccessPerm = 0x22222222;
|
||||
armcp15->protectBaseSize0 = 0x0;
|
||||
armcp15->protectBaseSize1 = 0x0;
|
||||
armcp15->protectBaseSize2 = 0x0;
|
||||
armcp15->protectBaseSize3 = 0x0;
|
||||
armcp15->protectBaseSize4 = 0x0;
|
||||
armcp15->protectBaseSize5 = 0x0;
|
||||
armcp15->protectBaseSize6 = 0x0;
|
||||
armcp15->protectBaseSize7 = 0x0;
|
||||
armcp15->cacheOp = 0x0;
|
||||
armcp15->DcacheLock = 0x0;
|
||||
armcp15->IcacheLock = 0x0;
|
||||
armcp15->ITCMRegion = 0x0C;
|
||||
armcp15->DTCMRegion = 0x0080000A;
|
||||
armcp15->processID = 0;
|
||||
|
||||
return armcp15;
|
||||
}
|
||||
|
||||
|
||||
BOOL armcp15_dataProcess(armcp15_t *armcp15, u8 CRd, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL armcp15_load(armcp15_t *armcp15, u8 CRd, u8 adr)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL armcp15_store(armcp15_t *armcp15, u8 CRd, u8 adr)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL armcp15_moveCP2ARM(armcp15_t *armcp15, u32 * R, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2)
|
||||
{
|
||||
if(armcp15->cpu->CPSR.bits.mode == USR) return FALSE;
|
||||
|
||||
switch(CRn)
|
||||
{
|
||||
case 0 :
|
||||
if((opcode1 == 0)&&(CRm==0))
|
||||
{
|
||||
switch(opcode2)
|
||||
{
|
||||
case 1 :
|
||||
*R = armcp15->cacheType;
|
||||
return TRUE;
|
||||
case 2 :
|
||||
*R = armcp15->TCMSize;
|
||||
return TRUE;
|
||||
default :
|
||||
*R = armcp15->IDCode;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
case 1 :
|
||||
if((opcode1==0) && (opcode2==0) && (CRm==0))
|
||||
{
|
||||
*R = armcp15->ctrl;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case 2 :
|
||||
if((opcode1==0) && (CRm==0))
|
||||
{
|
||||
switch(opcode2)
|
||||
{
|
||||
case 0 :
|
||||
*R = armcp15->DCConfig;
|
||||
return TRUE;
|
||||
case 1 :
|
||||
*R = armcp15->ICConfig;
|
||||
return TRUE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
case 3 :
|
||||
if((opcode1==0) && (opcode2==0) && (CRm==0))
|
||||
{
|
||||
*R = armcp15->writeBuffCtrl;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
case 5 :
|
||||
if((opcode1==0) && (CRm==0))
|
||||
{
|
||||
switch(opcode2)
|
||||
{
|
||||
case 2 :
|
||||
*R = armcp15->DaccessPerm;
|
||||
return TRUE;
|
||||
case 3 :
|
||||
*R = armcp15->IaccessPerm;
|
||||
return TRUE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
case 6 :
|
||||
if((opcode1==0) && (opcode2==0))
|
||||
{
|
||||
switch(CRm)
|
||||
{
|
||||
case 0 :
|
||||
*R = armcp15->protectBaseSize0;
|
||||
return TRUE;
|
||||
case 1 :
|
||||
*R = armcp15->protectBaseSize1;
|
||||
return TRUE;
|
||||
case 2 :
|
||||
*R = armcp15->protectBaseSize2;
|
||||
return TRUE;
|
||||
case 3 :
|
||||
*R = armcp15->protectBaseSize3;
|
||||
return TRUE;
|
||||
case 4 :
|
||||
*R = armcp15->protectBaseSize4;
|
||||
return TRUE;
|
||||
case 5 :
|
||||
*R = armcp15->protectBaseSize5;
|
||||
return TRUE;
|
||||
case 6 :
|
||||
*R = armcp15->protectBaseSize6;
|
||||
return TRUE;
|
||||
case 7 :
|
||||
*R = armcp15->protectBaseSize7;
|
||||
return TRUE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
case 9 :
|
||||
if((opcode1==0))
|
||||
{
|
||||
switch(CRm)
|
||||
{
|
||||
case 0 :
|
||||
switch(opcode2)
|
||||
{
|
||||
case 0 :
|
||||
*R = armcp15->DcacheLock;
|
||||
return TRUE;
|
||||
case 1 :
|
||||
*R = armcp15->IcacheLock;
|
||||
return TRUE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
case 1 :
|
||||
switch(opcode2)
|
||||
{
|
||||
case 0 :
|
||||
*R = armcp15->DTCMRegion;
|
||||
return TRUE;
|
||||
case 1 :
|
||||
*R = armcp15->ITCMRegion;
|
||||
return TRUE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
u32 CP15wait4IRQ(armcpu_t *cpu)
|
||||
{
|
||||
if(cpu->wirq)
|
||||
{
|
||||
if(!cpu->waitIRQ)
|
||||
{
|
||||
cpu->waitIRQ = 0;
|
||||
cpu->wirq = 0;
|
||||
//cpu->switchMode(oldmode[cpu->proc_ID]);
|
||||
return 1;
|
||||
}
|
||||
cpu->R[15] = cpu->instruct_adr;
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
return 1;
|
||||
}
|
||||
cpu->waitIRQ = 1;
|
||||
cpu->wirq = 1;
|
||||
cpu->R[15] = cpu->instruct_adr;
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
MMU.reg_IME[0] = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL armcp15_moveARM2CP(armcp15_t *armcp15, u32 val, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2)
|
||||
{
|
||||
if(armcp15->cpu->CPSR.bits.mode == USR) return FALSE;
|
||||
|
||||
switch(CRn)
|
||||
{
|
||||
case 1 :
|
||||
if((opcode1==0) && (opcode2==0) && (CRm==0))
|
||||
{
|
||||
armcp15->ctrl = val;
|
||||
MMU.ARM9_RW_MODE = BIT7(val);
|
||||
armcp15->cpu->intVector = 0x0FFF0000 * (BIT13(val));
|
||||
armcp15->cpu->LDTBit = !BIT15(val); //TBit
|
||||
/*if(BIT17(val))
|
||||
{
|
||||
log::ajouter("outch !!!!!!!");
|
||||
}
|
||||
if(BIT19(val))
|
||||
{
|
||||
log::ajouter("outch !!!!!!!");
|
||||
}*/
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
case 2 :
|
||||
if((opcode1==0) && (CRm==0))
|
||||
{
|
||||
switch(opcode2)
|
||||
{
|
||||
case 0 :
|
||||
armcp15->DCConfig = val;
|
||||
return TRUE;
|
||||
case 1 :
|
||||
armcp15->ICConfig = val;
|
||||
return TRUE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
case 3 :
|
||||
if((opcode1==0) && (opcode2==0) && (CRm==0))
|
||||
{
|
||||
armcp15->writeBuffCtrl = val;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
if((opcode1==0) && (CRm==0))
|
||||
{
|
||||
switch(opcode2)
|
||||
{
|
||||
case 2 :
|
||||
armcp15->DaccessPerm = val;
|
||||
return TRUE;
|
||||
case 3 :
|
||||
armcp15->IaccessPerm = val;
|
||||
return TRUE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
case 6 :
|
||||
if((opcode1==0) && (opcode2==0))
|
||||
{
|
||||
switch(CRm)
|
||||
{
|
||||
case 0 :
|
||||
armcp15->protectBaseSize0 = val;
|
||||
return TRUE;
|
||||
case 1 :
|
||||
armcp15->protectBaseSize1 = val;
|
||||
return TRUE;
|
||||
case 2 :
|
||||
armcp15->protectBaseSize2 = val;
|
||||
return TRUE;
|
||||
case 3 :
|
||||
armcp15->protectBaseSize3 = val;
|
||||
return TRUE;
|
||||
case 4 :
|
||||
armcp15->protectBaseSize4 = val;
|
||||
return TRUE;
|
||||
case 5 :
|
||||
armcp15->protectBaseSize5 = val;
|
||||
return TRUE;
|
||||
case 6 :
|
||||
armcp15->protectBaseSize6 = val;
|
||||
return TRUE;
|
||||
case 7 :
|
||||
armcp15->protectBaseSize7 = val;
|
||||
return TRUE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
case 7 :
|
||||
if((CRm==0)&&(opcode1==0)&&((opcode2==4)))
|
||||
{
|
||||
CP15wait4IRQ(armcp15->cpu);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
case 9 :
|
||||
if((opcode1==0))
|
||||
{
|
||||
switch(CRm)
|
||||
{
|
||||
case 0 :
|
||||
switch(opcode2)
|
||||
{
|
||||
case 0 :
|
||||
armcp15->DcacheLock = val;
|
||||
return TRUE;
|
||||
case 1 :
|
||||
armcp15->IcacheLock = val;
|
||||
return TRUE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
case 1 :
|
||||
switch(opcode2)
|
||||
{
|
||||
case 0 :
|
||||
armcp15->DTCMRegion = val;
|
||||
MMU.DTCMRegion = val & 0x0FFFFFFC0;
|
||||
/*sprintf(logbuf, "%08X", val);
|
||||
log::ajouter(logbuf);*/
|
||||
return TRUE;
|
||||
case 1 :
|
||||
armcp15->ITCMRegion = val;
|
||||
MMU.ITCMRegion = val & 0x0FFFFFFC0;
|
||||
return TRUE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __CP15_H__
|
||||
#define __CP15_H__
|
||||
|
||||
#include "armcpu.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 IDCode;
|
||||
u32 cacheType;
|
||||
u32 TCMSize;
|
||||
u32 ctrl;
|
||||
u32 DCConfig;
|
||||
u32 ICConfig;
|
||||
u32 writeBuffCtrl;
|
||||
u32 und;
|
||||
u32 DaccessPerm;
|
||||
u32 IaccessPerm;
|
||||
u32 protectBaseSize0;
|
||||
u32 protectBaseSize1;
|
||||
u32 protectBaseSize2;
|
||||
u32 protectBaseSize3;
|
||||
u32 protectBaseSize4;
|
||||
u32 protectBaseSize5;
|
||||
u32 protectBaseSize6;
|
||||
u32 protectBaseSize7;
|
||||
u32 cacheOp;
|
||||
u32 DcacheLock;
|
||||
u32 IcacheLock;
|
||||
u32 ITCMRegion;
|
||||
u32 DTCMRegion;
|
||||
u32 processID;
|
||||
u32 RAM_TAG;
|
||||
u32 testState;
|
||||
u32 cacheDbg;
|
||||
|
||||
armcpu_t * cpu;
|
||||
|
||||
} armcp15_t;
|
||||
|
||||
armcp15_t *armcp15_new(armcpu_t *c);
|
||||
BOOL armcp15_dataProcess(armcp15_t *armcp15, u8 CRd, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2);
|
||||
BOOL armcp15_load(armcp15_t *armcp15, u8 CRd, u8 adr);
|
||||
BOOL armcp15_store(armcp15_t *armcp15, u8 CRd, u8 adr);
|
||||
BOOL armcp15_moveCP2ARM(armcp15_t *armcp15, u32 * R, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2);
|
||||
BOOL armcp15_moveARM2CP(armcp15_t *armcp15, u32 val, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2);
|
||||
|
||||
#endif /* __CP15_H__*/
|
|
@ -0,0 +1,160 @@
|
|||
/* Copyright 2005 Guillaume Duhamel
|
||||
|
||||
This file is part of DeSmuME.
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Debug * DebugInit(const char * n, DebugOutType t, char * s) {
|
||||
Debug * d;
|
||||
|
||||
if ((d = (Debug *) malloc(sizeof(Debug))) == NULL)
|
||||
return NULL;
|
||||
|
||||
d->output_type = t;
|
||||
|
||||
if ((d->name = strdup(n)) == NULL)
|
||||
{
|
||||
free(d);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch(t) {
|
||||
case DEBUG_STREAM:
|
||||
d->output.stream = fopen(s, "w");
|
||||
break;
|
||||
case DEBUG_STRING:
|
||||
d->output.string = s;
|
||||
break;
|
||||
case DEBUG_STDOUT:
|
||||
d->output.stream = stdout;
|
||||
break;
|
||||
case DEBUG_STDERR:
|
||||
d->output.stream = stderr;
|
||||
break;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DebugDeInit(Debug * d) {
|
||||
if (d == NULL)
|
||||
return;
|
||||
|
||||
switch(d->output_type) {
|
||||
case DEBUG_STREAM:
|
||||
if (d->output.stream)
|
||||
fclose(d->output.stream);
|
||||
break;
|
||||
case DEBUG_STRING:
|
||||
case DEBUG_STDOUT:
|
||||
case DEBUG_STDERR:
|
||||
break;
|
||||
}
|
||||
if (d->name)
|
||||
free(d->name);
|
||||
free(d);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DebugChangeOutput(Debug * d, DebugOutType t, char * s) {
|
||||
if (t != d->output_type) {
|
||||
if (d->output_type == DEBUG_STREAM)
|
||||
{
|
||||
if (d->output.stream)
|
||||
fclose(d->output.stream);
|
||||
}
|
||||
d->output_type = t;
|
||||
}
|
||||
switch(t) {
|
||||
case DEBUG_STREAM:
|
||||
d->output.stream = fopen(s, "w");
|
||||
break;
|
||||
case DEBUG_STRING:
|
||||
d->output.string = s;
|
||||
break;
|
||||
case DEBUG_STDOUT:
|
||||
d->output.stream = stdout;
|
||||
break;
|
||||
case DEBUG_STDERR:
|
||||
d->output.stream = stderr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DebugPrintf(Debug * d, const char * file, u32 line, const char * format, ...) {
|
||||
va_list l;
|
||||
|
||||
if (d == NULL)
|
||||
return;
|
||||
|
||||
va_start(l, format);
|
||||
|
||||
switch(d->output_type) {
|
||||
case DEBUG_STDOUT:
|
||||
case DEBUG_STDERR:
|
||||
case DEBUG_STREAM:
|
||||
if (d->output.stream == NULL)
|
||||
break;
|
||||
fprintf(d->output.stream, "%s (%s:%ld): ", d->name, file, line);
|
||||
vfprintf(d->output.stream, format, l);
|
||||
break;
|
||||
case DEBUG_STRING:
|
||||
{
|
||||
int i;
|
||||
if (d->output.string == NULL)
|
||||
break;
|
||||
|
||||
i = sprintf(d->output.string, "%s (%s:%ld): ", d->name, file, line);
|
||||
vsprintf(d->output.string + i, format, l);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
va_end(l);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Debug * MainLog;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void LogStart(void) {
|
||||
MainLog = DebugInit("main", DEBUG_STDERR, NULL);
|
||||
// MainLog = DebugInit("main", DEBUG_STREAM, "stdout.txt");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void LogStop(void) {
|
||||
DebugDeInit(MainLog);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
#include "types.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum { DEBUG_STRING, DEBUG_STREAM , DEBUG_STDOUT, DEBUG_STDERR } DebugOutType;
|
||||
|
||||
typedef struct {
|
||||
DebugOutType output_type;
|
||||
union {
|
||||
FILE * stream;
|
||||
char * string;
|
||||
} output;
|
||||
char * name;
|
||||
} Debug;
|
||||
|
||||
Debug * DebugInit(const char *, DebugOutType, char *);
|
||||
void DebugDeInit(Debug *);
|
||||
|
||||
void DebugChangeOutput(Debug *, DebugOutType, char *);
|
||||
|
||||
void DebugPrintf(Debug *, const char *, u32, const char *, ...);
|
||||
|
||||
extern Debug * MainLog;
|
||||
|
||||
void LogStart(void);
|
||||
void LogStop(void);
|
||||
|
||||
#ifdef DEBUG
|
||||
#define LOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define LOG(...)
|
||||
#endif
|
||||
|
||||
#ifdef GPUDEBUG
|
||||
#define GPULOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define GPULOG(...)
|
||||
#endif
|
||||
|
||||
#ifdef DIVDEBUG
|
||||
#define DIVLOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define DIVLOG(...)
|
||||
#endif
|
||||
|
||||
#ifdef SQRTDEBUG
|
||||
#define SQRTLOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define SQRTLOG(...)
|
||||
#endif
|
||||
|
||||
#ifdef CARDDEBUG
|
||||
#define CARDLOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define CARDLOG(...)
|
||||
#endif
|
||||
|
||||
#ifdef DMADEBUG
|
||||
#define DMALOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define DMALOG(...)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef __DSCARD_H__
|
||||
#define __DSCARD_H__
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
u32 adress;
|
||||
u32 transfer_count;
|
||||
|
||||
} nds_dscard;
|
||||
|
||||
#endif /*__DSCARD_H__*/
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
FAT.H
|
||||
Mic, 2006
|
||||
Structures taken from Michael Chisholm's FAT library
|
||||
*/
|
||||
|
||||
#ifndef __FAT_H__
|
||||
#define __FAT_H__
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define ATTRIB_DIR 0x10
|
||||
#define ATTRIB_LFN 0x0F
|
||||
|
||||
#define FILE_FREE 0xE5
|
||||
|
||||
// Boot Sector - must be packed
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
u8 jmpBoot[3];
|
||||
u8 OEMName[8];
|
||||
// BIOS Parameter Block
|
||||
u16 bytesPerSector;
|
||||
u8 sectorsPerCluster;
|
||||
u16 reservedSectors;
|
||||
u8 numFATs;
|
||||
u16 rootEntries;
|
||||
u16 numSectorsSmall;
|
||||
u8 mediaDesc;
|
||||
u16 sectorsPerFAT;
|
||||
u16 sectorsPerTrk;
|
||||
u16 numHeads;
|
||||
u32 numHiddenSectors;
|
||||
u32 numSectors;
|
||||
struct
|
||||
{
|
||||
// Ext BIOS Parameter Block for FAT16
|
||||
u8 driveNumber;
|
||||
u8 reserved1;
|
||||
u8 extBootSig;
|
||||
u32 volumeID;
|
||||
u8 volumeLabel[11];
|
||||
u8 fileSysType[8];
|
||||
// Bootcode
|
||||
u8 bootCode[448];
|
||||
u16 signature;
|
||||
} fat16;
|
||||
} BOOT_RECORD;
|
||||
#pragma pack(pop)
|
||||
|
||||
// Directory entry - must be packed
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
u8 name[8];
|
||||
u8 ext[3];
|
||||
u8 attrib;
|
||||
u8 reserved;
|
||||
u8 cTime_ms;
|
||||
u16 cTime;
|
||||
u16 cDate;
|
||||
u16 aDate;
|
||||
u16 startClusterHigh;
|
||||
u16 mTime;
|
||||
u16 mDate;
|
||||
u16 startCluster;
|
||||
u32 fileSize;
|
||||
} DIR_ENT;
|
||||
#pragma pack(pop)
|
||||
#else
|
||||
typedef struct
|
||||
{
|
||||
u8 jmpBoot[3] __PACKED;
|
||||
u8 OEMName[8] __PACKED;
|
||||
// BIOS Parameter Block
|
||||
u16 bytesPerSector __PACKED;
|
||||
u8 sectorsPerCluster __PACKED;
|
||||
u16 reservedSectors __PACKED;
|
||||
u8 numFATs __PACKED;
|
||||
u16 rootEntries __PACKED;
|
||||
u16 numSectorsSmall __PACKED;
|
||||
u8 mediaDesc __PACKED;
|
||||
u16 sectorsPerFAT __PACKED;
|
||||
u16 sectorsPerTrk __PACKED;
|
||||
u16 numHeads __PACKED;
|
||||
u32 numHiddenSectors __PACKED;
|
||||
u32 numSectors __PACKED;
|
||||
struct
|
||||
{
|
||||
// Ext BIOS Parameter Block for FAT16
|
||||
u8 driveNumber __PACKED;
|
||||
u8 reserved1 __PACKED;
|
||||
u8 extBootSig __PACKED;
|
||||
u32 volumeID __PACKED;
|
||||
u8 volumeLabel[11] __PACKED;
|
||||
u8 fileSysType[8] __PACKED;
|
||||
// Bootcode
|
||||
u8 bootCode[448] __PACKED;
|
||||
u16 signature __PACKED;
|
||||
} fat16;
|
||||
} BOOT_RECORD;
|
||||
|
||||
// Directory entry - must be packed
|
||||
typedef struct
|
||||
{
|
||||
u8 name[8] __PACKED;
|
||||
u8 ext[3] __PACKED;
|
||||
u8 attrib __PACKED;
|
||||
u8 reserved __PACKED;
|
||||
u8 cTime_ms __PACKED;
|
||||
u16 cTime __PACKED;
|
||||
u16 cDate __PACKED;
|
||||
u16 aDate __PACKED;
|
||||
u16 startClusterHigh __PACKED;
|
||||
u16 mTime __PACKED;
|
||||
u16 mDate __PACKED;
|
||||
u16 startCluster __PACKED;
|
||||
u32 fileSize __PACKED;
|
||||
} DIR_ENT;
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,104 @@
|
|||
/* Copyright (C) 2006 Guillaume Duhamel
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "fs.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
DIR * dir;
|
||||
char * path;
|
||||
} FsLinuxDir;
|
||||
|
||||
const char FS_SEPARATOR = '/';
|
||||
|
||||
void * FsReadFirst(const char * path, FsEntry * entry) {
|
||||
FsLinuxDir * dir;
|
||||
struct dirent * e;
|
||||
struct stat s;
|
||||
char buffer[1024];
|
||||
DIR * tmp;
|
||||
|
||||
tmp = opendir(path);
|
||||
if (!tmp)
|
||||
return NULL;
|
||||
|
||||
e = readdir(tmp);
|
||||
if (!e)
|
||||
return NULL;
|
||||
|
||||
dir = malloc(sizeof(FsLinuxDir));
|
||||
dir->dir = tmp;
|
||||
|
||||
strcpy(entry->cFileName, e->d_name);
|
||||
// there's no 8.3 file names support on linux :)
|
||||
strcpy(entry->cAlternateFileName, "");
|
||||
entry->flags = 0;
|
||||
|
||||
dir->path = strdup(path);
|
||||
|
||||
sprintf(buffer, "%s/%s", dir->path, e->d_name);
|
||||
|
||||
stat(buffer, &s);
|
||||
if (S_ISDIR(s.st_mode)) {
|
||||
entry->flags = FS_IS_DIR;
|
||||
}
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
int FsReadNext(void * search, FsEntry * entry) {
|
||||
FsLinuxDir * dir = search;
|
||||
struct dirent * e;
|
||||
struct stat s;
|
||||
char buffer[1024];
|
||||
|
||||
e = readdir(dir->dir);
|
||||
if (!e)
|
||||
return 0;
|
||||
|
||||
strcpy(entry->cFileName, e->d_name);
|
||||
// there's no 8.3 file names support on linux :)
|
||||
strcpy(entry->cAlternateFileName, "");
|
||||
entry->flags = 0;
|
||||
|
||||
sprintf(buffer, "%s/%s", dir->path, e->d_name);
|
||||
|
||||
stat(buffer, &s);
|
||||
if (S_ISDIR(s.st_mode)) {
|
||||
entry->flags = FS_IS_DIR;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void FsClose(void * search) {
|
||||
DIR * dir = ((FsLinuxDir *) search)->dir;
|
||||
|
||||
closedir(dir);
|
||||
free(search);
|
||||
}
|
||||
|
||||
int FsError(void) {
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/* Copyright (C) 2006 Guillaume Duhamel
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "fs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
const char FS_SEPARATOR = '\\';
|
||||
|
||||
void * FsReadFirst(const char * p, FsEntry * entry) {
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
HANDLE hFind;
|
||||
HANDLE * ret;
|
||||
char path[1024];
|
||||
|
||||
sprintf(path, "%s\\*", p);
|
||||
|
||||
hFind = FindFirstFile(path, &FindFileData);
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
|
||||
strcpy(entry->cFileName, FindFileData.cFileName);
|
||||
strcpy(entry->cAlternateFileName, FindFileData.cAlternateFileName);
|
||||
entry->flags = 0;
|
||||
if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
entry->flags = FS_IS_DIR;
|
||||
}
|
||||
|
||||
ret = (void**)malloc(sizeof(HANDLE));
|
||||
*ret = hFind;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int FsReadNext(void * search, FsEntry * entry) {
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
HANDLE * h = (HANDLE *) search;
|
||||
int ret;
|
||||
|
||||
ret = FindNextFile(*h, &FindFileData);
|
||||
|
||||
strcpy(entry->cFileName, FindFileData.cFileName);
|
||||
strcpy(entry->cAlternateFileName, FindFileData.cAlternateFileName);
|
||||
entry->flags = 0;
|
||||
if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
entry->flags = FS_IS_DIR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void FsClose(void * search) {
|
||||
FindClose(*((HANDLE *) search));
|
||||
}
|
||||
|
||||
int FsError(void) {
|
||||
if (GetLastError() == ERROR_NO_MORE_FILES)
|
||||
return FS_ERR_NO_MORE_FILES;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/* Copyright (C) 2006 Guillaume Duhamel
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef FS_H
|
||||
#define FS_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FS_IS_DIR 1
|
||||
|
||||
#define FS_ERR_NO_MORE_FILES 1
|
||||
|
||||
extern const char FS_SEPARATOR;
|
||||
|
||||
typedef struct {
|
||||
char cFileName[256];
|
||||
char cAlternateFileName[14];
|
||||
u32 flags;
|
||||
} FsEntry;
|
||||
|
||||
void * FsReadFirst(const char * path, FsEntry * entry);
|
||||
int FsReadNext(void * search, FsEntry * entry);
|
||||
void FsClose(void * search);
|
||||
int FsError(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,50 @@
|
|||
/* XPM */
|
||||
static const char * DeSmuME_xpm[] = {
|
||||
"32 32 15 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #F6F6FB",
|
||||
"@ c #ECECF6",
|
||||
"# c #E2E2F1",
|
||||
"$ c #D8D8EC",
|
||||
"% c #CFCFE7",
|
||||
"& c #C5C5E2",
|
||||
"* c #BBBBDE",
|
||||
"= c #B1B1D9",
|
||||
"- c #A8A8D4",
|
||||
"; c #9E9ECF",
|
||||
"> c #9494CA",
|
||||
", c #8A8AC5",
|
||||
"' c #8080C0",
|
||||
" .................... ",
|
||||
" .................... ",
|
||||
".....++..+++++..+++++.. ",
|
||||
".....++..++.....++..... ",
|
||||
"..@@@@@..@@@@@..@@@@@.. ",
|
||||
"..@@.@@..@@........@@.. ",
|
||||
"..##.##..##.##..##.##.. ",
|
||||
"..##.##..##.##..##.##.. ",
|
||||
"..$$.$$..$$.$$..$$.$$.. ",
|
||||
"..$$.$$..$$.$$..$$.$$.. ",
|
||||
"..%%.%%..%%.%%..%%.%%.. ",
|
||||
"..%%.%%..%%.%%..%%.%%.. ",
|
||||
"..&&&&&..&&&&&..&&&&&.. ",
|
||||
"....................... ",
|
||||
".......********.**.**.. ",
|
||||
" ..==.==.==.==.==.. ",
|
||||
" ..==.==.==.==.==.. ",
|
||||
" ..--.--.--.--.--.. ",
|
||||
" ..--.--.--.--.--.. ",
|
||||
" ..;;.;;.;;.;;;;;.. ",
|
||||
" ..................... ",
|
||||
" ..................... ",
|
||||
" ..>>>>>>>>.>>>>>.. ",
|
||||
" ..>>.>>.>>.>>..... ",
|
||||
" ..,,.,,.,,.,,,,,.. ",
|
||||
" ..,,.,,.,,.,,..... ",
|
||||
" ..''.''.''.''.''.. ",
|
||||
" ..''.''.''.''.''.. ",
|
||||
" ..''.''.''.''.''.. ",
|
||||
" ..''.''.''.'''''.. ",
|
||||
" .................. ",
|
||||
" .................. "};
|
|
@ -0,0 +1,4 @@
|
|||
bin_PROGRAMS = desmume
|
||||
desmume_SOURCES = main.c desmume.c dToolsList.c tools/ioregsView.c ../sndsdl.c
|
||||
desmume_LDADD = ../libdesmume.a $(SDL_LIBS) $(GTK_LIBS)
|
||||
desmume_CFLAGS = $(SDL_CFLAGS) $(GTK_CFLAGS)
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef __DTOOL_H__
|
||||
#define __DTOOL_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#define DTOOL_LOG(...) fprintf(stderr, __VA_ARGS__);
|
||||
|
||||
#include "../types.h"
|
||||
#include "../registers.h"
|
||||
|
||||
typedef void (*dTool_openFn)(int id);
|
||||
typedef void (*dTool_updateFn)();
|
||||
typedef void (*dTool_closeFn)();
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char name[64];
|
||||
dTool_openFn open;
|
||||
dTool_updateFn update;
|
||||
dTool_closeFn close;
|
||||
|
||||
} dTool_t;
|
||||
|
||||
extern void dTool_CloseCallback(int id);
|
||||
|
||||
#endif /*__DTOOL_H__*/
|
|
@ -0,0 +1,10 @@
|
|||
#include "dTool.h"
|
||||
#include "tools/ioregsView.h"
|
||||
|
||||
dTool_t *dTools_list[] =
|
||||
{
|
||||
&dTool_ioregsView
|
||||
};
|
||||
|
||||
int dTools_list_size = 1;
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include "../MMU.h"
|
||||
#include "../armcpu.h"
|
||||
#include "../NDSSystem.h"
|
||||
#include "../cflash.h"
|
||||
#include "../sndsdl.h"
|
||||
|
||||
#include "desmume.h"
|
||||
|
||||
volatile BOOL execute = FALSE;
|
||||
BOOL click = FALSE;
|
||||
BOOL fini = FALSE;
|
||||
unsigned long glock = 0;
|
||||
|
||||
void desmume_mem_init();
|
||||
|
||||
u8 *desmume_rom_data = NULL;
|
||||
u32 desmume_last_cycle;
|
||||
|
||||
void desmume_init()
|
||||
{
|
||||
NDS_Init();
|
||||
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
|
||||
execute = FALSE;
|
||||
}
|
||||
|
||||
void desmume_free()
|
||||
{
|
||||
execute = FALSE;
|
||||
NDS_DeInit();
|
||||
}
|
||||
|
||||
void desmume_pause()
|
||||
{
|
||||
execute = FALSE;
|
||||
}
|
||||
void desmume_resume()
|
||||
{
|
||||
execute = TRUE;
|
||||
}
|
||||
void desmume_toggle()
|
||||
{
|
||||
execute = (execute) ? FALSE : TRUE;
|
||||
}
|
||||
BOOL desmume_running()
|
||||
{
|
||||
return execute;
|
||||
}
|
||||
|
||||
void desmume_cycle()
|
||||
{
|
||||
desmume_last_cycle = NDS_exec((560190 << 1) - desmume_last_cycle, FALSE);
|
||||
SPU_Emulate();
|
||||
}
|
||||
|
||||
void desmume_keypad(u16 k)
|
||||
{
|
||||
unsigned short k_ext = (k >> 10) & 0x3;
|
||||
unsigned short k_pad = k & 0x3FF;
|
||||
((unsigned short *)ARM9Mem.ARM9_REG)[0x130>>1] = ~k_pad;
|
||||
((unsigned short *)MMU.ARM7_REG)[0x130>>1] = ~k_ext;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef __DESMUME_H__
|
||||
#define __DESMUME_H__
|
||||
|
||||
#include "../types.h"
|
||||
|
||||
#define DESMUME_NB_KEYS 13
|
||||
|
||||
#define DESMUME_KEYMASK_(k) (1 << k)
|
||||
|
||||
#define DESMUME_KEY_A 1
|
||||
#define DESMUME_KEY_B 2
|
||||
#define DESMUME_KEY_Select 3
|
||||
#define DESMUME_KEY_Start 4
|
||||
#define DESMUME_KEY_Right 5
|
||||
#define DESMUME_KEY_Left 6
|
||||
#define DESMUME_KEY_Up 7
|
||||
#define DESMUME_KEY_Down 8
|
||||
#define DESMUME_KEY_R 9
|
||||
#define DESMUME_KEY_L 10
|
||||
|
||||
#define DESMUME_KEY_Y 11
|
||||
#define DESMUME_KEY_X 12
|
||||
#define DESMUME_KEY_DEBUG 13
|
||||
|
||||
extern void desmume_init();
|
||||
extern void desmume_free();
|
||||
|
||||
extern void desmume_pause();
|
||||
extern void desmume_resume();
|
||||
extern void desmume_toggle();
|
||||
extern BOOL desmume_running();
|
||||
|
||||
extern void desmume_cycle();
|
||||
|
||||
extern void desmume_keypad(u16 k);
|
||||
|
||||
#endif /*__DESMUME_H__*/
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
# Project: desmume
|
||||
# Makefile created by Dev-C++ 4.9.9.2
|
||||
|
||||
CPP = g++.exe
|
||||
CC = gcc.exe
|
||||
WINDRES = windres.exe
|
||||
RES =
|
||||
OBJ = ../main.o ../../arm_instructions.o ../../bios.o ../../cp15.o ../../Disassembler.o ../../GPU.o ../../MMU.o ../../NDSSystem.o ../../thumb_instructions.o ../../armcpu.o ../../debug.o ../../FIFO.o $(RES)
|
||||
LINKOBJ = ../main.o ../../arm_instructions.o ../../bios.o ../../cp15.o ../../Disassembler.o ../../GPU.o ../../MMU.o ../../NDSSystem.o ../../thumb_instructions.o ../../armcpu.o ../../debug.o ../../FIFO.o $(RES)
|
||||
LIBS = -L"lib" -mwindows -limm32 -lshell32 -lole32 -luuid -lintl -lpangowin32-1.0.dll -latk-1.0.dll -lgdk_pixbuf-2.0.dll -lgdk-win32-2.0.dll -lglib-2.0.dll -lgmodule-2.0.dll -lgobject-2.0.dll -lgthread-2.0.dll -lgtk-win32-2.0.dll -lpango-1.0.dll libpthreadGC2.a libSDL.a
|
||||
INCS = -I"include"
|
||||
CXXINCS = -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
|
||||
BIN = desmume.exe
|
||||
CXXFLAGS = $(CXXINCS) -I"C:\Dev-Cpp\\include\gtk-2.0" -I"C:\Dev-Cpp\\lib\gtk-2.0\include" -I"C:\Dev-Cpp\\include\atk-1.0" -I"C:\Dev-Cpp\\include\pango-1.0" -I"C:\Dev-Cpp\\include\glib-2.0" -I"C:\Dev-Cpp\\include\glib-2.0\glib" -I"C:\Dev-Cpp\\lib\glib-2.0" -I"C:\Dev-Cpp\\lib\glib-2.0\include" -mno-cygwin -mms-bitfields -mconsole
|
||||
CFLAGS = $(INCS) -I"C:\Dev-Cpp\\include\gtk-2.0" -I"C:\Dev-Cpp\\lib\gtk-2.0\include" -I"C:\Dev-Cpp\\include\atk-1.0" -I"C:\Dev-Cpp\\include\pango-1.0" -I"C:\Dev-Cpp\\include\glib-2.0" -I"C:\Dev-Cpp\\include\glib-2.0\glib" -I"C:\Dev-Cpp\\lib\glib-2.0" -I"C:\Dev-Cpp\\lib\glib-2.0\include" -mno-cygwin -mms-bitfields
|
||||
RM = rm -f
|
||||
|
||||
.PHONY: all all-before all-after clean clean-custom
|
||||
|
||||
all: all-before desmume.exe all-after
|
||||
|
||||
|
||||
clean: clean-custom
|
||||
${RM} $(OBJ) $(BIN)
|
||||
|
||||
$(BIN): $(OBJ)
|
||||
$(CPP) $(LINKOBJ) -o "desmume.exe" $(LIBS)
|
||||
|
||||
../main.o: ../main.cpp
|
||||
$(CPP) -c ../main.cpp -o ../main.o $(CXXFLAGS)
|
||||
|
||||
../../arm_instructions.o: ../../arm_instructions.cpp
|
||||
$(CPP) -c ../../arm_instructions.cpp -o ../../arm_instructions.o $(CXXFLAGS)
|
||||
|
||||
../../bios.o: ../../bios.cpp
|
||||
$(CPP) -c ../../bios.cpp -o ../../bios.o $(CXXFLAGS)
|
||||
|
||||
../../cp15.o: ../../cp15.cpp
|
||||
$(CPP) -c ../../cp15.cpp -o ../../cp15.o $(CXXFLAGS)
|
||||
|
||||
../../Disassembler.o: ../../Disassembler.cpp
|
||||
$(CPP) -c ../../Disassembler.cpp -o ../../Disassembler.o $(CXXFLAGS)
|
||||
|
||||
../../GPU.o: ../../GPU.cpp
|
||||
$(CPP) -c ../../GPU.cpp -o ../../GPU.o $(CXXFLAGS)
|
||||
|
||||
../../MMU.o: ../../MMU.cpp
|
||||
$(CPP) -c ../../MMU.cpp -o ../../MMU.o $(CXXFLAGS)
|
||||
|
||||
../../NDSSystem.o: ../../NDSSystem.cpp
|
||||
$(CPP) -c ../../NDSSystem.cpp -o ../../NDSSystem.o $(CXXFLAGS)
|
||||
|
||||
../../thumb_instructions.o: ../../thumb_instructions.cpp
|
||||
$(CPP) -c ../../thumb_instructions.cpp -o ../../thumb_instructions.o $(CXXFLAGS)
|
||||
|
||||
../../armcpu.o: ../../armcpu.cpp
|
||||
$(CPP) -c ../../armcpu.cpp -o ../../armcpu.o $(CXXFLAGS)
|
||||
|
||||
../../debug.o: ../../debug.c
|
||||
$(CPP) -c ../../debug.c -o ../../debug.o $(CXXFLAGS)
|
||||
|
||||
../../FIFO.o: ../../FIFO.cpp
|
||||
$(CPP) -c ../../FIFO.cpp -o ../../FIFO.o $(CXXFLAGS)
|
|
@ -0,0 +1,309 @@
|
|||
[Project]
|
||||
FileName=desmume.dev
|
||||
Name=desmume
|
||||
UnitCount=26
|
||||
Type=0
|
||||
Ver=1
|
||||
ObjFiles=
|
||||
Includes=
|
||||
Libs=
|
||||
PrivateResource=
|
||||
ResourceIncludes=
|
||||
MakeIncludes=
|
||||
Compiler=-I"<INCLUDE>\gtk-2.0" -I"<LIB>\gtk-2.0\include" -I"<INCLUDE>\atk-1.0" -I"<INCLUDE>\pango-1.0" -I"<INCLUDE>\glib-2.0" -I"<INCLUDE>\glib-2.0\glib" -I"<LIB>\glib-2.0" -I"<LIB>\glib-2.0\include" -mno-cygwin -mms-bitfields_@@_
|
||||
CppCompiler=-I"<INCLUDE>\gtk-2.0" -I"<LIB>\gtk-2.0\include" -I"<INCLUDE>\atk-1.0" -I"<INCLUDE>\pango-1.0" -I"<INCLUDE>\glib-2.0" -I"<INCLUDE>\glib-2.0\glib" -I"<LIB>\glib-2.0" -I"<LIB>\glib-2.0\include" -mno-cygwin -mms-bitfields -mconsole_@@_
|
||||
Linker=-limm32 -lshell32 -lole32 -luuid -lintl -lpangowin32-1.0.dll -latk-1.0.dll -lgdk_pixbuf-2.0.dll -lgdk-win32-2.0.dll -lglib-2.0.dll -lgmodule-2.0.dll -lgobject-2.0.dll -lgthread-2.0.dll -lgtk-win32-2.0.dll -lpango-1.0.dll_@@_libpthreadGC2.a_@@_libSDL.a_@@_
|
||||
IsCpp=1
|
||||
Icon=
|
||||
ExeOutput=
|
||||
ObjectOutput=
|
||||
OverrideOutput=0
|
||||
OverrideOutputName=desmume.exe
|
||||
HostApplication=
|
||||
Folders=
|
||||
CommandLine=
|
||||
UseCustomMakefile=0
|
||||
CustomMakefile=
|
||||
IncludeVersionInfo=0
|
||||
SupportXPThemes=0
|
||||
CompilerSet=0
|
||||
CompilerSettings=0000000000000000000000
|
||||
|
||||
[Unit1]
|
||||
FileName=..\main.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit2]
|
||||
FileName=..\..\types.h
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit3]
|
||||
FileName=..\..\arm_instructions.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit4]
|
||||
FileName=..\..\arm_instructions.h
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit7]
|
||||
FileName=..\..\bios.hpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit8]
|
||||
FileName=..\..\config.h
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit9]
|
||||
FileName=..\..\cp15.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit10]
|
||||
FileName=..\..\cp15.h
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit11]
|
||||
FileName=..\..\Disassembler.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit12]
|
||||
FileName=..\..\Disassembler.hpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit13]
|
||||
FileName=..\..\FIFO.hpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit14]
|
||||
FileName=..\..\GPU.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit15]
|
||||
FileName=..\..\GPU.hpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit16]
|
||||
FileName=..\..\MMU.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit17]
|
||||
FileName=..\..\MMU.hpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit18]
|
||||
FileName=..\..\NDSSystem.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit19]
|
||||
FileName=..\..\NDSSystem.hpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit20]
|
||||
FileName=..\..\thumb_instructions.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit21]
|
||||
FileName=..\..\thumb_instructions.h
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit22]
|
||||
FileName=pthread.h
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit23]
|
||||
FileName=..\..\armcpu.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit24]
|
||||
FileName=..\..\debug.c
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit25]
|
||||
FileName=..\..\debug.h
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit26]
|
||||
FileName=..\..\FIFO.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[VersionInfo]
|
||||
Major=0
|
||||
Minor=1
|
||||
Release=1
|
||||
Build=1
|
||||
LanguageID=1033
|
||||
CharsetID=1252
|
||||
CompanyName=
|
||||
FileVersion=
|
||||
FileDescription=Developed using the Dev-C++ IDE
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=
|
||||
AutoIncBuildNr=0
|
||||
|
||||
[Unit6]
|
||||
FileName=..\..\bios.cpp
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit5]
|
||||
FileName=..\..\armcpu.h
|
||||
CompileCpp=1
|
||||
Folder=desmume
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
[Editor_4]
|
||||
CursorCol=1
|
||||
CursorRow=78
|
||||
TopLine=169
|
||||
LeftChar=1
|
||||
Open=0
|
||||
Top=0
|
||||
[Editors]
|
||||
Focused=-1
|
||||
Order=-1
|
||||
[Editor_0]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=878
|
||||
TopLine=867
|
||||
LeftChar=1
|
||||
[Editor_1]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_2]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=15
|
||||
CursorRow=3626
|
||||
TopLine=3605
|
||||
LeftChar=1
|
||||
[Editor_3]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_5]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_6]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_7]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_8]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_9]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_10]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=8
|
||||
CursorRow=3315
|
||||
TopLine=3305
|
||||
LeftChar=1
|
||||
[Editor_11]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_12]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_13]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=29
|
||||
CursorRow=1063
|
||||
TopLine=1043
|
||||
LeftChar=1
|
||||
[Editor_14]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=1
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_15]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_16]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_17]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_18]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_19]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_20]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_21]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=47
|
||||
CursorRow=242
|
||||
TopLine=191
|
||||
LeftChar=1
|
||||
[Editor_22]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=10
|
||||
CursorRow=487
|
||||
TopLine=474
|
||||
LeftChar=1
|
||||
[Editor_23]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_24]
|
||||
Open=0
|
||||
Top=0
|
||||
[Editor_25]
|
||||
Open=0
|
||||
Top=0
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
* Module: sched.h
|
||||
*
|
||||
* Purpose:
|
||||
* Provides an implementation of POSIX realtime extensions
|
||||
* as defined in
|
||||
*
|
||||
* POSIX 1003.1b-1993 (POSIX.1b)
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifndef _SCHED_H
|
||||
#define _SCHED_H
|
||||
|
||||
#undef PTW32_LEVEL
|
||||
|
||||
#if defined(_POSIX_SOURCE)
|
||||
#define PTW32_LEVEL 0
|
||||
/* Early POSIX */
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
|
||||
#undef PTW32_LEVEL
|
||||
#define PTW32_LEVEL 1
|
||||
/* Include 1b, 1c and 1d */
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_NP)
|
||||
#undef PTW32_LEVEL
|
||||
#define PTW32_LEVEL 2
|
||||
/* Include Non-Portable extensions */
|
||||
#endif
|
||||
|
||||
#define PTW32_LEVEL_MAX 3
|
||||
|
||||
#if !defined(PTW32_LEVEL)
|
||||
#define PTW32_LEVEL PTW32_LEVEL_MAX
|
||||
/* Include everything */
|
||||
#endif
|
||||
|
||||
|
||||
#if __GNUC__ && ! defined (__declspec)
|
||||
# error Please upgrade your GNU compiler to one that supports __declspec.
|
||||
#endif
|
||||
|
||||
/*
|
||||
* When building the DLL code, you should define PTW32_BUILD so that
|
||||
* the variables/functions are exported correctly. When using the DLL,
|
||||
* do NOT define PTW32_BUILD, and then the variables/functions will
|
||||
* be imported correctly.
|
||||
*/
|
||||
#ifndef PTW32_STATIC_LIB
|
||||
# ifdef PTW32_BUILD
|
||||
# define PTW32_DLLPORT __declspec (dllexport)
|
||||
# else
|
||||
# define PTW32_DLLPORT __declspec (dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define PTW32_DLLPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This is a duplicate of what is in the autoconf config.h,
|
||||
* which is only used when building the pthread-win32 libraries.
|
||||
*/
|
||||
|
||||
#ifndef PTW32_CONFIG_H
|
||||
# if defined(WINCE)
|
||||
# define NEED_ERRNO
|
||||
# define NEED_SEM
|
||||
# endif
|
||||
# if defined(_UWIN) || defined(__MINGW32__)
|
||||
# define HAVE_MODE_T
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
|
||||
#ifdef NEED_ERRNO
|
||||
#include "need_errno.h"
|
||||
#else
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
|
||||
|
||||
#if defined(__MINGW32__) || defined(_UWIN)
|
||||
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
|
||||
/* For pid_t */
|
||||
# include <sys/types.h>
|
||||
/* Required by Unix 98 */
|
||||
# include <time.h>
|
||||
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
|
||||
#else
|
||||
typedef int pid_t;
|
||||
#endif
|
||||
|
||||
/* Thread scheduling policies */
|
||||
|
||||
enum {
|
||||
SCHED_OTHER = 0,
|
||||
SCHED_FIFO,
|
||||
SCHED_RR,
|
||||
SCHED_MIN = SCHED_OTHER,
|
||||
SCHED_MAX = SCHED_RR
|
||||
};
|
||||
|
||||
struct sched_param {
|
||||
int sched_priority;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
PTW32_DLLPORT int __cdecl sched_yield (void);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
|
||||
|
||||
/*
|
||||
* Note that this macro returns ENOTSUP rather than
|
||||
* ENOSYS as might be expected. However, returning ENOSYS
|
||||
* should mean that sched_get_priority_{min,max} are
|
||||
* not implemented as well as sched_rr_get_interval.
|
||||
* This is not the case, since we just don't support
|
||||
* round-robin scheduling. Therefore I have chosen to
|
||||
* return the same value as sched_setscheduler when
|
||||
* SCHED_RR is passed to it.
|
||||
*/
|
||||
#define sched_rr_get_interval(_pid, _interval) \
|
||||
( errno = ENOTSUP, (int) -1 )
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* End of extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#undef PTW32_LEVEL
|
||||
#undef PTW32_LEVEL_MAX
|
||||
|
||||
#endif /* !_SCHED_H */
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
* Module: semaphore.h
|
||||
*
|
||||
* Purpose:
|
||||
* Semaphores aren't actually part of the PThreads standard.
|
||||
* They are defined by the POSIX Standard:
|
||||
*
|
||||
* POSIX 1003.1b-1993 (POSIX.1b)
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pthreads-win32 - POSIX Threads Library for Win32
|
||||
* Copyright(C) 1998 John E. Bossom
|
||||
* Copyright(C) 1999,2005 Pthreads-win32 contributors
|
||||
*
|
||||
* Contact Email: rpj@callisto.canberra.edu.au
|
||||
*
|
||||
* The current list of contributors is contained
|
||||
* in the file CONTRIBUTORS included with the source
|
||||
* code distribution. The list can also be seen at the
|
||||
* following World Wide Web location:
|
||||
* http://sources.redhat.com/pthreads-win32/contributors.html
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library in the file COPYING.LIB;
|
||||
* if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined( SEMAPHORE_H )
|
||||
#define SEMAPHORE_H
|
||||
|
||||
#undef PTW32_LEVEL
|
||||
|
||||
#if defined(_POSIX_SOURCE)
|
||||
#define PTW32_LEVEL 0
|
||||
/* Early POSIX */
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
|
||||
#undef PTW32_LEVEL
|
||||
#define PTW32_LEVEL 1
|
||||
/* Include 1b, 1c and 1d */
|
||||
#endif
|
||||
|
||||
#if defined(INCLUDE_NP)
|
||||
#undef PTW32_LEVEL
|
||||
#define PTW32_LEVEL 2
|
||||
/* Include Non-Portable extensions */
|
||||
#endif
|
||||
|
||||
#define PTW32_LEVEL_MAX 3
|
||||
|
||||
#if !defined(PTW32_LEVEL)
|
||||
#define PTW32_LEVEL PTW32_LEVEL_MAX
|
||||
/* Include everything */
|
||||
#endif
|
||||
|
||||
#if __GNUC__ && ! defined (__declspec)
|
||||
# error Please upgrade your GNU compiler to one that supports __declspec.
|
||||
#endif
|
||||
|
||||
/*
|
||||
* When building the DLL code, you should define PTW32_BUILD so that
|
||||
* the variables/functions are exported correctly. When using the DLL,
|
||||
* do NOT define PTW32_BUILD, and then the variables/functions will
|
||||
* be imported correctly.
|
||||
*/
|
||||
#ifndef PTW32_STATIC_LIB
|
||||
# ifdef PTW32_BUILD
|
||||
# define PTW32_DLLPORT __declspec (dllexport)
|
||||
# else
|
||||
# define PTW32_DLLPORT __declspec (dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define PTW32_DLLPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This is a duplicate of what is in the autoconf config.h,
|
||||
* which is only used when building the pthread-win32 libraries.
|
||||
*/
|
||||
|
||||
#ifndef PTW32_CONFIG_H
|
||||
# if defined(WINCE)
|
||||
# define NEED_ERRNO
|
||||
# define NEED_SEM
|
||||
# endif
|
||||
# if defined(_UWIN) || defined(__MINGW32__)
|
||||
# define HAVE_MODE_T
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
|
||||
#ifdef NEED_ERRNO
|
||||
#include "need_errno.h"
|
||||
#else
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
|
||||
|
||||
#define _POSIX_SEMAPHORES
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef HAVE_MODE_T
|
||||
typedef unsigned int mode_t;
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct sem_t_ * sem_t;
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
|
||||
int pshared,
|
||||
unsigned int value);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem,
|
||||
const struct timespec * abstime);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_post (sem_t * sem);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem,
|
||||
int count);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_open (const char * name,
|
||||
int oflag,
|
||||
mode_t mode,
|
||||
unsigned int value);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_close (sem_t * sem);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
|
||||
|
||||
PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
|
||||
int * sval);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* End of extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#undef PTW32_LEVEL
|
||||
#undef PTW32_LEVEL_MAX
|
||||
|
||||
#endif /* !SEMAPHORE_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,464 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include "../dTool.h"
|
||||
|
||||
#include "../MMU.h"
|
||||
|
||||
#define TOOL_NAME "IO regs view"
|
||||
|
||||
BOOL CPUS [2] = {TRUE, TRUE};
|
||||
|
||||
static GtkWidget *mWin[2];
|
||||
static GtkWidget *mVbox0[2];
|
||||
static GtkWidget *mIoRegCombo[2];
|
||||
static GtkWidget *mRegInfos[2];
|
||||
|
||||
typedef void (*reg_dispFn)(int c);
|
||||
typedef u32 (*reg_valFn)(int c);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[64];
|
||||
u32 adress;
|
||||
int size;
|
||||
reg_dispFn create;
|
||||
reg_dispFn update;
|
||||
reg_dispFn destroy;
|
||||
reg_valFn value;
|
||||
} reg_t;
|
||||
|
||||
static reg_t *current_reg[2] = {NULL, NULL};
|
||||
|
||||
#define REGFN_BEGIN(reg) \
|
||||
GtkWidget **_wl_ = Widgets_##reg [c];
|
||||
|
||||
#define BIT_CHECK(w, n, s) { \
|
||||
char _bit_check_buf[64]; \
|
||||
sprintf(_bit_check_buf, "Bit %d: %s", n,s); \
|
||||
_wl_[w] = gtk_check_button_new_with_label(_bit_check_buf ); \
|
||||
gtk_box_pack_start(GTK_BOX(mVbox0[c]), _wl_[w], FALSE, FALSE, 0); }
|
||||
|
||||
#define BIT_COMBO(w,n,s) { \
|
||||
_wl_[w] = gtk_hbox_new(FALSE, 0); \
|
||||
gtk_box_pack_start(GTK_BOX(mVbox0[c]), _wl_[w], FALSE, FALSE, 0); } \
|
||||
char _bit_combo_buf[64]; \
|
||||
sprintf(_bit_combo_buf, "Bits %s: %s", n,s); \
|
||||
GtkWidget *__combo_lbl_tmp = gtk_label_new(_bit_combo_buf); \
|
||||
GtkWidget *__combo_tmp = gtk_combo_box_new_text(); \
|
||||
|
||||
#define BIT_COMBO_ADD(w, s) { \
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(__combo_tmp), s); }
|
||||
|
||||
#define BIT_COMBO_GET(w) (GTK_WIDGET(g_list_first(gtk_container_get_children(GTK_CONTAINER(_wl_[w])))->data))
|
||||
|
||||
#define BIT_COMBO_END(w) \
|
||||
gtk_box_pack_start(GTK_BOX(_wl_[w]), __combo_tmp, FALSE, FALSE, 0); \
|
||||
gtk_box_pack_start(GTK_BOX(_wl_[w]), __combo_lbl_tmp, FALSE, FALSE, 0);
|
||||
|
||||
#define CREA_END() \
|
||||
gtk_widget_show_all(mWin[c]);
|
||||
|
||||
/////////////////////////////// REG_IME ///////////////////////////////
|
||||
static GtkWidget *Widgets_REG_IME[2][1];
|
||||
static void crea_REG_IME(int c)
|
||||
{
|
||||
REGFN_BEGIN(REG_IME);
|
||||
BIT_CHECK(0, 0, "Master interrupt enable");
|
||||
CREA_END();
|
||||
}
|
||||
static void updt_REG_IME(int c) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IME[c][0]), MMU.reg_IME[c] ? 1 : 0); }
|
||||
static void dest_REG_IME(int c) { gtk_widget_destroy(Widgets_REG_IME[c][0]); }
|
||||
static u32 val_REG_IME(int c) { return MMU.reg_IME[c]; }
|
||||
|
||||
/////////////////////////////// REG_IE ///////////////////////////////
|
||||
|
||||
static const char *interrupt_strings[25] =
|
||||
{
|
||||
"LCD VBlank", // 0
|
||||
"LCD HBlank", // 1
|
||||
"LCD VCount", // 2
|
||||
"Timer0 overflow", // 3
|
||||
"Timer1 overflow",
|
||||
"Timer2 overflow",
|
||||
"Timer3 overflow",
|
||||
"Serial communication (RTC)", // 7
|
||||
"DMA0", // 8
|
||||
"DMA1",
|
||||
"DMA2",
|
||||
"DMA3",
|
||||
"Keypad", // 12
|
||||
"Game Pak (GBA slot)", // 13
|
||||
"", // 14
|
||||
"", // 15
|
||||
"IPC Sync", // 16
|
||||
"IPC Send FIFO empty", // 17
|
||||
"IPC Recv FIFO not empty", // 18
|
||||
"Card Data Transfer Completion (DS-card slot)", // 29
|
||||
"Card IREQ_MC (DS-card slot)", // 20
|
||||
"Geometry (3D) command FIFO", // 21
|
||||
"Screens unfolding", // 22
|
||||
"SPI bus", // 23
|
||||
"Wifi" // 24
|
||||
};
|
||||
#define INTERRUPT_SKIP(c) if(i == 14 || i == 15 || (c == 0 && (i == 7 || i == 22 || i == 23 || i == 24)) || (c == 1 && i == 21))continue;
|
||||
|
||||
static GtkWidget *Widgets_REG_IE[2][32];
|
||||
static void crea_REG_IE(int c)
|
||||
{
|
||||
REGFN_BEGIN(REG_IE);
|
||||
int i;
|
||||
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); BIT_CHECK(i, i, interrupt_strings[i]); }
|
||||
CREA_END();
|
||||
}
|
||||
static void updt_REG_IE(int c)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IE[c][i]), (MMU.reg_IE[c] & (1<<i)) ? 1 : 0); }
|
||||
}
|
||||
static void dest_REG_IE(int c)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); gtk_widget_destroy(Widgets_REG_IE[c][i]); }
|
||||
}
|
||||
static u32 val_REG_IE(int c) { return MMU.reg_IE[c]; }
|
||||
|
||||
/////////////////////////////// REG_IF ///////////////////////////////
|
||||
static GtkWidget *Widgets_REG_IF[2][32];
|
||||
static void crea_REG_IF(int c)
|
||||
{
|
||||
REGFN_BEGIN(REG_IF);
|
||||
int i;
|
||||
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); BIT_CHECK(i, i, interrupt_strings[i]); }
|
||||
CREA_END();
|
||||
}
|
||||
static void updt_REG_IF(int c)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IF[c][i]), (MMU.reg_IF[c] & (1<<i)) ? 1 : 0); }
|
||||
}
|
||||
static void dest_REG_IF(int c)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); gtk_widget_destroy(Widgets_REG_IF[c][i]); }
|
||||
}
|
||||
static u32 val_REG_IF(int c) { return MMU.reg_IF[c]; }
|
||||
|
||||
/////////////////////////////// REG_IPCFIFOCNT ///////////////////////////////
|
||||
static const char *fifocnt_strings[] =
|
||||
{
|
||||
"Send FIFO empty",
|
||||
"Send FIFO full",
|
||||
"Send FIFO empty IRQ",
|
||||
"Send FIFO clear (flush)",
|
||||
"","","","",
|
||||
"Receive FIFO empty",
|
||||
"Receive FIFO full",
|
||||
"Receive FIFO not empty IRQ",
|
||||
"","","",
|
||||
"Error (read when empty/write when full)",
|
||||
"Enable FIFOs"
|
||||
|
||||
};
|
||||
#define FIFOCNT_SKIP(c) if(i==4||i==5||i==6||i==11||i==12||i==13)continue;
|
||||
|
||||
static GtkWidget *Widgets_REG_IPCFIFOCNT[2][16];
|
||||
static void crea_REG_IPCFIFOCNT(int c)
|
||||
{
|
||||
REGFN_BEGIN(REG_IPCFIFOCNT);
|
||||
int i;
|
||||
for(i = 0; i < 16; i++) { FIFOCNT_SKIP(c); BIT_CHECK(i, i, fifocnt_strings[i]); }
|
||||
CREA_END();
|
||||
}
|
||||
static void updt_REG_IPCFIFOCNT(int c)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 16; i++) { FIFOCNT_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IPCFIFOCNT[c][i]), (((u16 *)(MMU.MMU_MEM[c][0x40]))[0x184>>1]&(1<<i)) ? 1 : 0); }
|
||||
}
|
||||
static void dest_REG_IPCFIFOCNT(int c)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 16; i++) { FIFOCNT_SKIP(c); gtk_widget_destroy(Widgets_REG_IPCFIFOCNT[c][i]); }
|
||||
}
|
||||
static u32 val_REG_IPCFIFOCNT(int c) { return ((u16 *)(MMU.MMU_MEM[c][0x40]))[0x184>>1]; }
|
||||
|
||||
/////////////////////////////// POWER_CR ///////////////////////////////
|
||||
static const char *powercr9_strings[] =
|
||||
{
|
||||
"Enable LCD",
|
||||
"2D A engine",
|
||||
"3D render engine",
|
||||
"3D geometry engine (matrix)",
|
||||
"", "", "", "", "",
|
||||
"2D B engine",
|
||||
"", "", "", "", "",
|
||||
"Swap LCD"
|
||||
};
|
||||
static const char *powercr7_strings[] =
|
||||
{
|
||||
"Sound speakers",
|
||||
"Wifi system"
|
||||
};
|
||||
#define POWER_CR_SKIP(c) if(i==4||i==5||i==6||i==7||i==8||i==10||i==11|i==12|i==13||i==14)continue;
|
||||
#define POWER_CR_SIZE(c) ((c==0)?16:2)
|
||||
|
||||
static GtkWidget *Widgets_POWER_CR[2][16];
|
||||
static void crea_POWER_CR(int c)
|
||||
{
|
||||
REGFN_BEGIN(POWER_CR);
|
||||
int i;
|
||||
for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); BIT_CHECK(i, i, (c==0?powercr9_strings:powercr7_strings)[i]); }
|
||||
CREA_END();
|
||||
}
|
||||
static void updt_POWER_CR(int c)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_POWER_CR[c][i]), (((u16 *)(MMU.MMU_MEM[c][0x40]))[0x304>>1]&(1<<i)) ? 1 : 0); }
|
||||
}
|
||||
static void dest_POWER_CR(int c)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); gtk_widget_destroy(Widgets_POWER_CR[c][i]); }
|
||||
}
|
||||
static u32 val_POWER_CR(int c) { return ((u16 *)(MMU.MMU_MEM[c][0x40]))[0x304>>1]; }
|
||||
|
||||
/////////////////////////////// REG_SPICNT ///////////////////////////////
|
||||
static const char *spicnt_strings[16] =
|
||||
{
|
||||
"Baudrate",
|
||||
"","","","","","",
|
||||
"Busy flag",
|
||||
"Device",
|
||||
"",
|
||||
"Transfer size",
|
||||
"Chipselect Hold",
|
||||
"Unknown",
|
||||
"Unknown",
|
||||
"Interrupt request",
|
||||
"Enable SPI bus",
|
||||
};
|
||||
|
||||
// 0-1 Baudrate (0=4MHz/Firmware, 1=2MHz/Touchscr, 2=1MHz/Powerman., 3=512KHz)
|
||||
// 2-6 Not used (Zero)
|
||||
// 7 Busy Flag (0=Ready, 1=Busy) (presumably Read-only)
|
||||
// 8-9 Device Select (0=Powerman., 1=Firmware, 2=Touchscr, 3=Reserved)
|
||||
// 10 Transfer Size (0=8bit, 1=16bit)
|
||||
// 11 Chipselect Hold (0=Deselect after transfer, 1=Keep selected)
|
||||
// 12 Unknown (usually 0) (set equal to Bit11 when BIOS accesses firmware)
|
||||
// 13 Unknown (usually 0) (set to 1 when BIOS accesses firmware)
|
||||
// 14 Interrupt Request (0=Disable, 1=Enable)
|
||||
// 15 SPI Bus Enable (0=Disable, 1=Enable)
|
||||
|
||||
|
||||
#define REG_SPICNT_SKIP(c) if(i==1||i==2||i==3||i==4||i==5||i==6||i==9)continue;
|
||||
#define REG_SPICNT_ISCHECK(c) (i==7||i==11||i==14||i==15||i==12||i==13)
|
||||
|
||||
static GtkWidget *Widgets_REG_SPICNT[2][16];
|
||||
static void crea_REG_SPICNT(int c)
|
||||
{
|
||||
REGFN_BEGIN(REG_SPICNT);
|
||||
int i;
|
||||
for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c);
|
||||
if(REG_SPICNT_ISCHECK(c)) { BIT_CHECK(i, i, spicnt_strings[i]); }
|
||||
else if(i == 0) { BIT_COMBO(i, "0-1", spicnt_strings[0]);
|
||||
BIT_COMBO_ADD(i, "0= 4Mhz");
|
||||
BIT_COMBO_ADD(i, "1= 2Mhz");
|
||||
BIT_COMBO_ADD(i, "2= 1Mhz");
|
||||
BIT_COMBO_ADD(i, "3= 512Khz");
|
||||
BIT_COMBO_END(i); }
|
||||
else if(i == 8) { BIT_COMBO(i, "8-9", spicnt_strings[8]);
|
||||
BIT_COMBO_ADD(i, "0= Power management device");
|
||||
BIT_COMBO_ADD(i, "1= Firmware");
|
||||
BIT_COMBO_ADD(i, "2= Touchscreen/Microphone");
|
||||
BIT_COMBO_ADD(i, "3= Reserved/Prohibited");
|
||||
BIT_COMBO_END(i); }
|
||||
else if(i == 10) { BIT_COMBO(i, "10", spicnt_strings[10]);
|
||||
BIT_COMBO_ADD(i, "0= 8 bits");
|
||||
BIT_COMBO_ADD(i, "1= 16 bits");
|
||||
BIT_COMBO_END(i); }
|
||||
}
|
||||
CREA_END();
|
||||
}
|
||||
static u32 val_REG_SPICNT(int c) { return ((u16 *)(MMU.MMU_MEM[c][0x40]))[0x1C0>>1]; }
|
||||
static void updt_REG_SPICNT(int c)
|
||||
{
|
||||
REGFN_BEGIN(REG_SPICNT);
|
||||
u16 val = val_REG_SPICNT(c);
|
||||
int i;
|
||||
for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c);
|
||||
if(REG_SPICNT_ISCHECK(c)) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_SPICNT[c][i]), (((u16 *)(MMU.MMU_MEM[c][0x40]))[0x1C0>>1]&(1<<i)) ? 1 : 0); }
|
||||
else if(i == 0) { gtk_combo_box_set_active(GTK_COMBO_BOX(BIT_COMBO_GET(i)) , val&3); }
|
||||
else if(i == 8) { gtk_combo_box_set_active(GTK_COMBO_BOX(BIT_COMBO_GET(i)) , (val>>8)&3); }
|
||||
else if(i == 10) { gtk_combo_box_set_active(GTK_COMBO_BOX(BIT_COMBO_GET(i)) , (val>>10)&1); }
|
||||
}
|
||||
}
|
||||
static void dest_REG_SPICNT(int c)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c); gtk_widget_destroy(Widgets_REG_SPICNT[c][i]); }
|
||||
}
|
||||
|
||||
/////////////////////////////// LIST ///////////////////////////////
|
||||
#define BITS_8 1
|
||||
#define BITS_16 2
|
||||
#define BITS_32 4
|
||||
static const char *bits_strings[5] = {"0", "8", "16", "24", "32"};
|
||||
|
||||
#define REG_STR(r, s) {#r, r, s, &crea_##r, &updt_##r, &dest_##r, &val_##r}
|
||||
#define REG_FNS(r) &crea_##r, &updt_##r, &dest_##r, &val_##r
|
||||
//////// ARM9 ////////
|
||||
#define REG_LIST_SIZE_ARM9 5
|
||||
static const reg_t regs_list_9[] =
|
||||
{
|
||||
{"REG_IME", REG_IME, BITS_16, REG_FNS(REG_IME)},
|
||||
{"REG_IE", REG_IE, BITS_32, REG_FNS(REG_IE)},
|
||||
{"REG_IF", REG_IF, BITS_32, REG_FNS(REG_IF)},
|
||||
{"REG_IPCFIFOCNT", 0x04000184, BITS_16, REG_FNS(REG_IPCFIFOCNT)},
|
||||
{"POWER_CR", REG_POWCNT1, BITS_16, REG_FNS(POWER_CR)}
|
||||
};
|
||||
|
||||
//////// ARM7 ////////
|
||||
#define REG_LIST_SIZE_ARM7 6
|
||||
static const reg_t regs_list_7[] =
|
||||
{
|
||||
{"REG_IME", REG_IME, BITS_16, REG_FNS(REG_IME)},
|
||||
{"REG_IE", REG_IE, BITS_32, REG_FNS(REG_IE)},
|
||||
{"REG_IF", REG_IF, BITS_32, REG_FNS(REG_IF)},
|
||||
{"REG_IPCFIFOCNT", 0x04000184, BITS_16, REG_FNS(REG_IPCFIFOCNT)},
|
||||
{"POWER_CR", REG_POWCNT1, BITS_16, REG_FNS(POWER_CR)},
|
||||
{"REG_SPICNT", REG_SPICNT, BITS_16, REG_FNS(REG_SPICNT)}
|
||||
};
|
||||
|
||||
#define GET_REG_LIST_SIZE(i) ((i==0)?REG_LIST_SIZE_ARM9:REG_LIST_SIZE_ARM7)
|
||||
#define GET_REG_LIST(i) ((i==0)?regs_list_9:regs_list_7)
|
||||
|
||||
static void _clearContainer(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
if(widget == mRegInfos[0] || widget == mRegInfos[1]) return;
|
||||
if(widget == mIoRegCombo[0] || widget == mIoRegCombo[1]) return;
|
||||
|
||||
gtk_container_remove(GTK_CONTAINER((GtkWidget*)data), widget);
|
||||
// gtk_widget_destroy(widget);
|
||||
// gtk_object_destroy(GTK_OBJECT(widget));
|
||||
}
|
||||
|
||||
static void selected_reg(GtkWidget* widget, gpointer data)
|
||||
{
|
||||
int c = GPOINTER_TO_INT(data);
|
||||
|
||||
guint active = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
|
||||
|
||||
if(current_reg[c]) current_reg[c]->destroy(c);
|
||||
gtk_container_foreach(GTK_CONTAINER(mVbox0[c]), _clearContainer, (gpointer)mVbox0[c]);
|
||||
|
||||
current_reg[c] = (reg_t*)&(GET_REG_LIST(c)[active]);
|
||||
|
||||
// gtk_box_pack_start(GTK_BOX(mVbox0[c]), mIoRegCombo[c], FALSE, FALSE, 0);
|
||||
|
||||
char regInfosBuffer[64];
|
||||
|
||||
if(current_reg[c]->size == BITS_8)
|
||||
{
|
||||
sprintf(regInfosBuffer, "0x%02X", current_reg[c]->value(c));
|
||||
}
|
||||
else if(current_reg[c]->size == BITS_16)
|
||||
{
|
||||
sprintf(regInfosBuffer, "0x%04X", current_reg[c]->value(c));
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(regInfosBuffer, "0x%08X", current_reg[c]->value(c));
|
||||
}
|
||||
// gtk_box_pack_start(GTK_BOX(mVbox0[c]), mRegInfos[c], FALSE, FALSE, 0);
|
||||
gtk_label_set_label(GTK_LABEL(mRegInfos[c]), regInfosBuffer);
|
||||
|
||||
current_reg[c]->create(c);
|
||||
current_reg[c]->update(c);
|
||||
}
|
||||
|
||||
/////////////////////////////// TOOL ///////////////////////////////
|
||||
|
||||
static int DTOOL_ID;
|
||||
|
||||
static void close()
|
||||
{
|
||||
DTOOL_LOG("Close\n");
|
||||
|
||||
dTool_CloseCallback(DTOOL_ID);
|
||||
}
|
||||
|
||||
static void _closeOne(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
int c = GPOINTER_TO_INT(data);
|
||||
|
||||
CPUS[c] = FALSE;
|
||||
if(c == 0 && !CPUS[1]) close();
|
||||
if(c == 1 && !CPUS[0]) close();
|
||||
|
||||
gtk_widget_destroy(mRegInfos[c]);
|
||||
gtk_widget_destroy(mIoRegCombo[c]);
|
||||
gtk_widget_destroy(mVbox0[c]);
|
||||
// gtk_widget_destroy(mWin[c]);
|
||||
}
|
||||
|
||||
static void update()
|
||||
{
|
||||
int c;
|
||||
|
||||
for(c = 0; c < 2; c++)
|
||||
{
|
||||
if(!CPUS[c]) continue;
|
||||
current_reg[c]->update(c);
|
||||
}
|
||||
}
|
||||
|
||||
static void open(int ID)
|
||||
{
|
||||
int c, i;
|
||||
|
||||
DTOOL_ID = ID;
|
||||
|
||||
for(c = 0; c < 2; c++)
|
||||
{
|
||||
CPUS[c] = TRUE;
|
||||
|
||||
mWin[c]= gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
if(c == 0) gtk_window_set_title(GTK_WINDOW(mWin[c]), TOOL_NAME " : ARM9");
|
||||
else gtk_window_set_title(GTK_WINDOW(mWin[c]), TOOL_NAME " : ARM7");
|
||||
g_signal_connect(G_OBJECT(mWin[c]), "destroy", G_CALLBACK(&_closeOne), GINT_TO_POINTER(c));
|
||||
|
||||
mVbox0[c] = gtk_vbox_new(FALSE, 0);
|
||||
gtk_container_add(GTK_CONTAINER(mWin[c]), mVbox0[c]);
|
||||
|
||||
mIoRegCombo[c] = gtk_combo_box_new_text();
|
||||
mRegInfos[c] = gtk_label_new("");
|
||||
|
||||
for(i = 0; i < GET_REG_LIST_SIZE(c); i++)
|
||||
{
|
||||
char reg_name_buffer[64];
|
||||
sprintf(reg_name_buffer, "0x%08X : %s (%s)", GET_REG_LIST(c)[i].adress, GET_REG_LIST(c)[i].name, bits_strings[GET_REG_LIST(c)[i].size]);
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(mIoRegCombo[c]), reg_name_buffer);
|
||||
}
|
||||
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(mIoRegCombo[c]), 0);
|
||||
g_signal_connect(G_OBJECT(mIoRegCombo[c]), "changed", G_CALLBACK(selected_reg), GINT_TO_POINTER(c));
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(mVbox0[c]), mIoRegCombo[c], FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(mVbox0[c]), mRegInfos[c], FALSE, FALSE, 0);
|
||||
selected_reg(mIoRegCombo[c], GINT_TO_POINTER(c));
|
||||
|
||||
gtk_widget_show_all(mWin[c]);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////// TOOL DEFINITION ///////////////////////////////
|
||||
|
||||
dTool_t dTool_ioregsView =
|
||||
{
|
||||
TOOL_NAME,
|
||||
&open,
|
||||
&update,
|
||||
&close
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef __IOREGSVIEW_H__
|
||||
#define __IOREGSVIEW_H__
|
||||
|
||||
#include "../dTool.h"
|
||||
|
||||
extern dTool_t dTool_ioregsView;
|
||||
|
||||
#endif /*__IOREGSVIEW_H__*/
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,399 @@
|
|||
#include <stdlib.h>
|
||||
#include "debug.h"
|
||||
#include "types.h"
|
||||
#include "mc.h"
|
||||
|
||||
#define FW_CMD_READ 0x3
|
||||
#define FW_CMD_WRITEDISABLE 0x4
|
||||
#define FW_CMD_READSTATUS 0x5
|
||||
#define FW_CMD_WRITEENABLE 0x6
|
||||
#define FW_CMD_PAGEWRITE 0xA
|
||||
|
||||
#define BM_CMD_AUTODETECT 0xFF
|
||||
#define BM_CMD_WRITESTATUS 0x1
|
||||
#define BM_CMD_WRITELOW 0x2
|
||||
#define BM_CMD_READLOW 0x3
|
||||
#define BM_CMD_WRITEDISABLE 0x4
|
||||
#define BM_CMD_READSTATUS 0x5
|
||||
#define BM_CMD_WRITEENABLE 0x6
|
||||
#define BM_CMD_WRITEHIGH 0xA
|
||||
#define BM_CMD_READHIGH 0xB
|
||||
|
||||
/* FLASH*/
|
||||
#define COMM_PAGE_WRITE 0x0A
|
||||
#define COMM_PAGE_ERASE 0xDB
|
||||
#define COMM_SECTOR_ERASE 0xD8
|
||||
#define COMM_CHIP_ERASE 0xC7
|
||||
#define CARDFLASH_READ_BYTES_FAST 0x0B /* Not used*/
|
||||
#define CARDFLASH_DEEP_POWDOWN 0xB9 /* Not used*/
|
||||
#define CARDFLASH_WAKEUP 0xAB /* Not used*/
|
||||
|
||||
void mc_init(memory_chip_t *mc, int type)
|
||||
{
|
||||
mc->com = 0;
|
||||
mc->addr = 0;
|
||||
mc->addr_shift = 0;
|
||||
mc->data = NULL;
|
||||
mc->size = 0;
|
||||
mc->write_enable = FALSE;
|
||||
mc->writeable_buffer = FALSE;
|
||||
mc->type = type;
|
||||
mc->autodetectsize = 0;
|
||||
|
||||
switch(mc->type)
|
||||
{
|
||||
case MC_TYPE_EEPROM1:
|
||||
mc->addr_size = 1;
|
||||
break;
|
||||
case MC_TYPE_EEPROM2:
|
||||
case MC_TYPE_FRAM:
|
||||
mc->addr_size = 2;
|
||||
break;
|
||||
case MC_TYPE_FLASH:
|
||||
mc->addr_size = 3;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
u8 *mc_alloc(memory_chip_t *mc, u32 size)
|
||||
{
|
||||
u8 *buffer;
|
||||
buffer = malloc(size);
|
||||
|
||||
if(!buffer) { return NULL; }
|
||||
mc->data = buffer;
|
||||
mc->size = size;
|
||||
mc->writeable_buffer = TRUE;
|
||||
}
|
||||
|
||||
void mc_free(memory_chip_t *mc)
|
||||
{
|
||||
if(mc->data) free(mc->data);
|
||||
mc_init(mc, 0);
|
||||
}
|
||||
|
||||
void mc_reset_com(memory_chip_t *mc)
|
||||
{
|
||||
if (mc->type == MC_TYPE_AUTODETECT && mc->com == BM_CMD_AUTODETECT)
|
||||
{
|
||||
u32 i;
|
||||
u32 addr, size;
|
||||
|
||||
if (mc->autodetectsize == (32768+2))
|
||||
{
|
||||
// FRAM
|
||||
addr = (mc->autodetectbuf[0] << 8) | mc->autodetectbuf[1];
|
||||
mc->type = MC_TYPE_FRAM;
|
||||
mc->size = MC_SIZE_256KBITS;
|
||||
}
|
||||
else if (mc->autodetectsize == (256+3))
|
||||
{
|
||||
// Flash
|
||||
addr = (mc->autodetectbuf[0] << 16) |
|
||||
(mc->autodetectbuf[1] << 8) |
|
||||
mc->autodetectbuf[2];
|
||||
mc->type = MC_TYPE_FLASH;
|
||||
mc->size = MC_SIZE_2MBITS;
|
||||
}
|
||||
else if (mc->autodetectsize == (128+2))
|
||||
{
|
||||
// 512 Kbit EEPROM
|
||||
addr = (mc->autodetectbuf[0] << 8) | mc->autodetectbuf[1];
|
||||
mc->type = MC_TYPE_EEPROM2;
|
||||
mc->size = MC_SIZE_512KBITS;
|
||||
}
|
||||
else if (mc->autodetectsize == (32+2))
|
||||
{
|
||||
// 64 Kbit EEPROM
|
||||
addr = (mc->autodetectbuf[0] << 8) | mc->autodetectbuf[1];
|
||||
mc->type = MC_TYPE_EEPROM2;
|
||||
mc->size = MC_SIZE_64KBITS;
|
||||
}
|
||||
else if (mc->autodetectsize == (16+1))
|
||||
{
|
||||
// 4 Kbit EEPROM
|
||||
addr = mc->autodetectbuf[0];
|
||||
mc->type = MC_TYPE_EEPROM1;
|
||||
mc->size = MC_SIZE_4KBITS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume it's a Flash non-page write
|
||||
LOG("Flash detected(guessed). autodetectsize = %d\n", mc->autodetectsize);
|
||||
addr = (mc->autodetectbuf[0] << 16) |
|
||||
(mc->autodetectbuf[1] << 8) |
|
||||
mc->autodetectbuf[2];
|
||||
mc->type = MC_TYPE_FLASH;
|
||||
mc->size = MC_SIZE_2MBITS;
|
||||
}
|
||||
|
||||
size = mc->autodetectsize;
|
||||
mc_realloc(mc, mc->type, mc->size);
|
||||
memcpy(mc->data+addr, mc->autodetectbuf+mc->addr_size, size-mc->addr_size);
|
||||
mc->autodetectsize = 0;
|
||||
mc->write_enable = FALSE;
|
||||
|
||||
// Generate file
|
||||
if ((mc->fp = fopen(mc->filename, "wb+")) != NULL)
|
||||
fwrite((void *)mc->data, 1, mc->size, mc->fp);
|
||||
}
|
||||
else if (mc->com == BM_CMD_WRITELOW)
|
||||
{
|
||||
if (mc->fp)
|
||||
{
|
||||
fseek(mc->fp, 0, SEEK_SET);
|
||||
fwrite((void *)mc->data, 1, mc->size, mc->fp); // fix me
|
||||
}
|
||||
mc->write_enable = FALSE;
|
||||
}
|
||||
|
||||
mc->com = 0;
|
||||
}
|
||||
|
||||
void mc_realloc(memory_chip_t *mc, int type, u32 size)
|
||||
{
|
||||
if(mc->data) free(mc->data);
|
||||
mc_init(mc, type);
|
||||
mc_alloc(mc, size);
|
||||
}
|
||||
|
||||
void mc_load_file(memory_chip_t *mc, const char* filename)
|
||||
{
|
||||
long size;
|
||||
int type;
|
||||
FILE* file = fopen(filename, "rb+");
|
||||
if(file == NULL)
|
||||
{
|
||||
mc->filename = strdup(filename);
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
if (mc->type == MC_TYPE_AUTODETECT)
|
||||
{
|
||||
if (size == MC_SIZE_4KBITS)
|
||||
type = MC_TYPE_EEPROM1;
|
||||
else if (size == MC_SIZE_64KBITS)
|
||||
type = MC_TYPE_EEPROM2;
|
||||
else if (size == MC_SIZE_256KBITS)
|
||||
type = MC_TYPE_FRAM;
|
||||
else if (size == MC_SIZE_512KBITS)
|
||||
type = MC_TYPE_EEPROM2;
|
||||
else if (size >= MC_SIZE_2MBITS)
|
||||
type = MC_TYPE_FLASH;
|
||||
mc_realloc(mc, type, size);
|
||||
}
|
||||
|
||||
if (size > mc->size)
|
||||
size = mc->size;
|
||||
fread (mc->data, 1, size, file);
|
||||
mc->fp = file;
|
||||
}
|
||||
|
||||
u8 fw_transfer(memory_chip_t *mc, u8 data)
|
||||
{
|
||||
if(mc->com == FW_CMD_READ || mc->com == FW_CMD_PAGEWRITE) /* check if we are in a command that needs 3 bytes address */
|
||||
{
|
||||
if(mc->addr_shift > 0) /* if we got a complete address */
|
||||
{
|
||||
mc->addr_shift--;
|
||||
mc->addr |= data << (mc->addr_shift * 8); /* argument is a byte of address */
|
||||
}
|
||||
else /* if we have received 3 bytes of address, proceed command */
|
||||
{
|
||||
switch(mc->com)
|
||||
{
|
||||
case FW_CMD_READ:
|
||||
if(mc->addr < mc->size) /* check if we can read */
|
||||
{
|
||||
data = mc->data[mc->addr]; /* return byte */
|
||||
mc->addr++; /* then increment address */
|
||||
}
|
||||
break;
|
||||
|
||||
case FW_CMD_PAGEWRITE:
|
||||
if(mc->addr < mc->size)
|
||||
{
|
||||
mc->data[mc->addr] = data; /* write byte */
|
||||
mc->addr++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if(mc->com == FW_CMD_READSTATUS)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else /* finally, check if it's a new command */
|
||||
{
|
||||
switch(data)
|
||||
{
|
||||
case 0: break; /* nothing */
|
||||
|
||||
case FW_CMD_READ: /* read command */
|
||||
mc->addr = 0;
|
||||
mc->addr_shift = 3;
|
||||
mc->com = FW_CMD_READ;
|
||||
break;
|
||||
|
||||
case FW_CMD_WRITEENABLE: /* enable writing */
|
||||
if(mc->writeable_buffer) { mc->write_enable = TRUE; }
|
||||
break;
|
||||
|
||||
case FW_CMD_WRITEDISABLE: /* disable writing */
|
||||
mc->write_enable = FALSE;
|
||||
break;
|
||||
|
||||
case FW_CMD_PAGEWRITE: /* write command */
|
||||
if(mc->write_enable)
|
||||
{
|
||||
mc->addr = 0;
|
||||
mc->addr_shift = 3;
|
||||
mc->com = FW_CMD_PAGEWRITE;
|
||||
}
|
||||
else { data = 0; }
|
||||
break;
|
||||
|
||||
case FW_CMD_READSTATUS: /* status register command */
|
||||
mc->com = FW_CMD_READSTATUS;
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG("Unhandled FW command: %02X\n", data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
u8 bm_transfer(memory_chip_t *mc, u8 data)
|
||||
{
|
||||
if(mc->com == BM_CMD_READLOW || mc->com == BM_CMD_WRITELOW) /* check if we are in a command that needs multiple byte address */
|
||||
{
|
||||
if(mc->addr_shift > 0) /* if we got a complete address */
|
||||
{
|
||||
mc->addr_shift--;
|
||||
mc->addr |= data << (mc->addr_shift * 8); /* argument is a byte of address */
|
||||
}
|
||||
else /* if we have received all bytes of address, proceed command */
|
||||
{
|
||||
switch(mc->com)
|
||||
{
|
||||
case BM_CMD_READLOW:
|
||||
if(mc->addr < mc->size) /* check if we can read */
|
||||
{
|
||||
//LOG("Read Backup Memory addr %08X(%02X)\n", mc->addr, mc->data[mc->addr]);
|
||||
data = mc->data[mc->addr]; /* return byte */
|
||||
mc->addr++; /* then increment address */
|
||||
}
|
||||
break;
|
||||
|
||||
case BM_CMD_WRITELOW:
|
||||
if(mc->addr < mc->size)
|
||||
{
|
||||
//LOG("Write Backup Memory addr %08X with %02X\n", mc->addr, data);
|
||||
mc->data[mc->addr] = data; /* write byte */
|
||||
mc->addr++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if(mc->com == BM_CMD_AUTODETECT)
|
||||
{
|
||||
// Store everything in a temporary
|
||||
mc->autodetectbuf[mc->autodetectsize] = data;
|
||||
mc->autodetectsize++;
|
||||
return 0;
|
||||
}
|
||||
else if(mc->com == BM_CMD_READSTATUS)
|
||||
{
|
||||
//LOG("Backup Memory Read Status: %02X\n", mc->write_enable << 1);
|
||||
return (mc->write_enable << 1);
|
||||
}
|
||||
else /* finally, check if it's a new command */
|
||||
{
|
||||
switch(data)
|
||||
{
|
||||
case 0: break; /* nothing */
|
||||
|
||||
case BM_CMD_WRITELOW: /* write command */
|
||||
if(mc->write_enable)
|
||||
{
|
||||
if(mc->type == MC_TYPE_AUTODETECT)
|
||||
{
|
||||
mc->com = BM_CMD_AUTODETECT;
|
||||
break;
|
||||
}
|
||||
|
||||
mc->addr = 0;
|
||||
mc->addr_shift = mc->addr_size;
|
||||
mc->com = BM_CMD_WRITELOW;
|
||||
}
|
||||
else { data = 0; }
|
||||
break;
|
||||
|
||||
case BM_CMD_READLOW: /* read command */
|
||||
mc->addr = 0;
|
||||
mc->addr_shift = mc->addr_size;
|
||||
mc->com = BM_CMD_READLOW;
|
||||
break;
|
||||
|
||||
case BM_CMD_WRITEDISABLE: /* disable writing */
|
||||
mc->write_enable = FALSE;
|
||||
break;
|
||||
|
||||
case BM_CMD_READSTATUS: /* status register command */
|
||||
mc->com = BM_CMD_READSTATUS;
|
||||
break;
|
||||
|
||||
case BM_CMD_WRITEENABLE: /* enable writing */
|
||||
if(mc->writeable_buffer) { mc->write_enable = TRUE; }
|
||||
break;
|
||||
|
||||
case BM_CMD_WRITEHIGH: /* write command that's only available on ST M95040-W that I know of */
|
||||
if(mc->write_enable)
|
||||
{
|
||||
if(mc->type == MC_TYPE_AUTODETECT)
|
||||
{
|
||||
mc->com = BM_CMD_AUTODETECT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (mc->type == MC_TYPE_EEPROM1)
|
||||
mc->addr = 0x100;
|
||||
else
|
||||
mc->addr = 0;
|
||||
mc->addr_shift = mc->addr_size;
|
||||
mc->com = BM_CMD_WRITELOW;
|
||||
}
|
||||
else { data = 0; }
|
||||
break;
|
||||
|
||||
case BM_CMD_READHIGH: /* read command that's only available on ST M95040-W that I know of */
|
||||
if (mc->type == MC_TYPE_EEPROM1)
|
||||
mc->addr = 0x100;
|
||||
else
|
||||
mc->addr = 0;
|
||||
mc->addr_shift = mc->addr_size;
|
||||
mc->com = BM_CMD_READLOW;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG("Unhandled Backup Memory command: %02X\n", data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
#ifndef __FW_H__
|
||||
#define __FW_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "types.h"
|
||||
|
||||
#define MC_TYPE_AUTODETECT 0x0
|
||||
#define MC_TYPE_EEPROM1 0x1
|
||||
#define MC_TYPE_EEPROM2 0x2
|
||||
#define MC_TYPE_FLASH 0x3
|
||||
#define MC_TYPE_FRAM 0x4
|
||||
|
||||
#define MC_SIZE_4KBITS 0x000200
|
||||
#define MC_SIZE_64KBITS 0x002000
|
||||
#define MC_SIZE_256KBITS 0x008000
|
||||
#define MC_SIZE_512KBITS 0x010000
|
||||
#define MC_SIZE_1MBITS 0x020000
|
||||
#define MC_SIZE_2MBITS 0x040000
|
||||
#define MC_SIZE_4MBITS 0x080000
|
||||
#define MC_SIZE_8MBITS 0x100000
|
||||
#define MC_SIZE_16MBITS 0x200000
|
||||
#define MC_SIZE_64MBITS 0x800000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 com; /* persistent command actually handled */
|
||||
u32 addr; /* current address for reading/writing */
|
||||
u8 addr_shift; /* shift for address (since addresses are transfered by 3 bytes units) */
|
||||
u8 addr_size; /* size of addr when writing/reading */
|
||||
|
||||
BOOL write_enable; /* is write enabled ? */
|
||||
|
||||
u8 *data; /* memory data */
|
||||
u32 size; /* memory size */
|
||||
BOOL writeable_buffer; /* is "data" writeable ? */
|
||||
int type; /* type of Memory */
|
||||
char *filename;
|
||||
FILE *fp;
|
||||
u8 autodetectbuf[32768];
|
||||
int autodetectsize;
|
||||
} memory_chip_t;
|
||||
|
||||
#define NDS_FW_SIZE_V1 (256 * 1024) /* size of fw memory on nds v1 */
|
||||
#define NDS_FW_SIZE_V2 (512 * 1024) /* size of fw memory on nds v2 */
|
||||
|
||||
void mc_init(memory_chip_t *mc, int type); /* reset and init values for memory struct */
|
||||
u8 *mc_alloc(memory_chip_t *mc, u32 size); /* alloc mc memory */
|
||||
void mc_realloc(memory_chip_t *mc, int type, u32 size); /* realloc mc memory */
|
||||
void mc_load_file(memory_chip_t *mc, const char* filename); /* load save file and setup fp */
|
||||
void mc_free(memory_chip_t *mc); /* delete mc memory */
|
||||
void mc_reset_com(memory_chip_t *mc); /* reset communication with mc */
|
||||
u8 fw_transfer(memory_chip_t *mc, u8 data); /* transfer to, then receive data from firmware */
|
||||
u8 bm_transfer(memory_chip_t *mc, u8 data); /* transfer to, then receive data from backup memory */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__FW_H__*/
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
/* Copyright 2005-2006 Guillaume Duhamel
|
||||
Copyright 2005 Theo Berkau
|
||||
|
||||
This file is part of Yabause.
|
||||
|
||||
Yabause 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.
|
||||
|
||||
Yabause 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 Yabause; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef MEM_H
|
||||
#define MEM_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "types.h"
|
||||
|
||||
/* Type 1 Memory, faster for byte (8 bits) accesses */
|
||||
|
||||
static INLINE u8 T1ReadByte(u8 * mem, u32 addr)
|
||||
{
|
||||
return mem[addr];
|
||||
}
|
||||
|
||||
static INLINE u16 T1ReadWord(u8 * mem, u32 addr)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
return (mem[addr + 1] << 8) | mem[addr];
|
||||
#else
|
||||
return *((u16 *) (mem + addr));
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE u32 T1ReadLong(u8 * mem, u32 addr)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
return (mem[addr + 3] << 24 | mem[addr + 2] << 16 |
|
||||
mem[addr + 1] << 8 | mem[addr]);
|
||||
#else
|
||||
return *((u32 *) (mem + addr));
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE u64 T1ReadQuad(u8 * mem, u32 addr)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
return (mem[addr + 7] << 56 | mem[addr + 6] << 48 |
|
||||
mem[addr + 5] << 40 | mem[addr + 4] << 32 |
|
||||
mem[addr + 3] << 24 | mem[addr + 2] << 16 |
|
||||
mem[addr + 1] << 8 | mem[addr]);
|
||||
#else
|
||||
return *((u64 *) (mem + addr));
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE void T1WriteByte(u8 * mem, u32 addr, u8 val)
|
||||
{
|
||||
mem[addr] = val;
|
||||
}
|
||||
|
||||
static INLINE void T1WriteWord(u8 * mem, u32 addr, u16 val)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
mem[addr + 1] = val >> 8;
|
||||
mem[addr] = val & 0xFF;
|
||||
#else
|
||||
*((u16 *) (mem + addr)) = val;
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE void T1WriteLong(u8 * mem, u32 addr, u32 val)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
mem[addr + 3] = val >> 24;
|
||||
mem[addr + 2] = (val >> 16) & 0xFF;
|
||||
mem[addr + 1] = (val >> 8) & 0xFF;
|
||||
mem[addr] = val & 0xFF;
|
||||
#else
|
||||
*((u32 *) (mem + addr)) = val;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Type 2 Memory, faster for word (16 bits) accesses */
|
||||
|
||||
static INLINE u8 T2ReadByte(u8 * mem, u32 addr)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
return mem[addr ^ 1];
|
||||
#else
|
||||
return mem[addr];
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE u16 T2ReadWord(u8 * mem, u32 addr)
|
||||
{
|
||||
return *((u16 *) (mem + addr));
|
||||
}
|
||||
|
||||
static INLINE u32 T2ReadLong(u8 * mem, u32 addr)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
return *((u16 *) (mem + addr + 2)) << 16 | *((u16 *) (mem + addr));
|
||||
#else
|
||||
return *((u32 *) (mem + addr));
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE void T2WriteByte(u8 * mem, u32 addr, u8 val)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
mem[addr ^ 1] = val;
|
||||
#else
|
||||
mem[addr] = val;
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE void T2WriteWord(u8 * mem, u32 addr, u16 val)
|
||||
{
|
||||
*((u16 *) (mem + addr)) = val;
|
||||
}
|
||||
|
||||
static INLINE void T2WriteLong(u8 * mem, u32 addr, u32 val)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
*((u16 *) (mem + addr + 2)) = val >> 16;
|
||||
*((u16 *) (mem + addr)) = val & 0xFFFF;
|
||||
#else
|
||||
*((u32 *) (mem + addr)) = val;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,190 @@
|
|||
#ifndef REGISTERS_H
|
||||
#define REGISTERS_H
|
||||
|
||||
// Display Engine A
|
||||
#define REG_DISPA_DISPCNT 0x04000000
|
||||
#define REG_DISPA_DISPSTAT 0x04000004
|
||||
#define REG_DISPA_VCOUNT 0x04000006
|
||||
#define REG_DISPA_BG0CNT 0x04000008
|
||||
#define REG_DISPA_BG1CNT 0x0400000A
|
||||
#define REG_DISPA_BG2CNT 0x0400000C
|
||||
#define REG_DISPA_BG3CNT 0x0400000E
|
||||
#define REG_DISPA_BG0HOFS 0x04000010
|
||||
#define REG_DISPA_BG0VOFS 0x04000012
|
||||
#define REG_DISPA_BG1HOFS 0x04000014
|
||||
#define REG_DISPA_BG1VOFS 0x04000016
|
||||
#define REG_DISPA_BG2HOFS 0x04000018
|
||||
#define REG_DISPA_BG2VOFS 0x0400001A
|
||||
#define REG_DISPA_BG3HOFS 0x0400001C
|
||||
#define REG_DISPA_BG3VOFS 0x0400001E
|
||||
#define REG_DISPA_BG2PA 0x04000020
|
||||
#define REG_DISPA_BG2PB 0x04000022
|
||||
#define REG_DISPA_BG2PC 0x04000024
|
||||
#define REG_DISPA_BG2PD 0x04000026
|
||||
#define REG_DISPA_BG2XL 0x04000028
|
||||
#define REG_DISPA_BG2XH 0x0400002A
|
||||
#define REG_DISPA_BG2YL 0x0400002C
|
||||
#define REG_DISPA_BG2YH 0x0400002E
|
||||
#define REG_DISPA_BG3PA 0x04000030
|
||||
#define REG_DISPA_BG3PB 0x04000032
|
||||
#define REG_DISPA_BG3PC 0x04000034
|
||||
#define REG_DISPA_BG3PD 0x04000036
|
||||
#define REG_DISPA_BG3XL 0x04000038
|
||||
#define REG_DISPA_BG3XH 0x0400003A
|
||||
#define REG_DISPA_BG3YL 0x0400003C
|
||||
#define REG_DISPA_BG3YH 0x0400003E
|
||||
#define REG_DISPA_WIN0H 0x04000040
|
||||
#define REG_DISPA_WIN1H 0x04000042
|
||||
#define REG_DISPA_WIN0V 0x04000044
|
||||
#define REG_DISPA_WIN1V 0x04000046
|
||||
#define REG_DISPA_WININ 0x04000048
|
||||
#define REG_DISPA_WINOUT 0x0400004A
|
||||
#define REG_DISPA_MOSAIC 0x0400004C
|
||||
#define REG_DISPA_BLDCNT 0x04000050
|
||||
#define REG_DISPA_BLDALPHA 0x04000052
|
||||
#define REG_DISPA_BLDY 0x04000054
|
||||
#define REG_DISPA_DISP3DCNT 0x04000060
|
||||
#define REG_DISPA_DISPCAPCNT 0x04000064
|
||||
#define REG_DISPA_DISPMMEMFIFO 0x04000068
|
||||
#define REG_DISPA_MASTERBRIGHT 0x0400006C
|
||||
|
||||
// DMA
|
||||
#define REG_DMA0SAD 0x040000B0
|
||||
#define REG_DMA0DAD 0x040000B4
|
||||
#define REG_DMA0CNTL 0x040000B8
|
||||
#define REG_DMA0CNTH 0x040000BA
|
||||
#define REG_DMA1SAD 0x040000BC
|
||||
#define REG_DMA1DAD 0x040000C0
|
||||
#define REG_DMA1CNTL 0x040000C4
|
||||
#define REG_DMA1CNTH 0x040000C6
|
||||
#define REG_DMA2SAD 0x040000C8
|
||||
#define REG_DMA2DAD 0x040000CC
|
||||
#define REG_DMA2CNTL 0x040000D0
|
||||
#define REG_DMA2CNTH 0x040000D2
|
||||
#define REG_DMA3SAD 0x040000D4
|
||||
#define REG_DMA3DAD 0x040000D8
|
||||
#define REG_DMA3CNTL 0x040000DC
|
||||
#define REG_DMA3CNTH 0x040000DE
|
||||
#define REG_DMA0FILL 0x040000E0
|
||||
#define REG_DMA1FILL 0x040000E4
|
||||
#define REG_DMA2FILL 0x040000E8
|
||||
#define REG_DMA3FILL 0x040000EC
|
||||
|
||||
// Timers
|
||||
#define REG_TM0CNTL 0x04000100
|
||||
#define REG_TM0CNTH 0x04000102
|
||||
#define REG_TM1CNTL 0x04000104
|
||||
#define REG_TM1CNTH 0x04000106
|
||||
#define REG_TM2CNTL 0x04000108
|
||||
#define REG_TM2CNTH 0x0400010A
|
||||
#define REG_TM3CNTL 0x0400010C
|
||||
#define REG_TM3CNTH 0x0400010E
|
||||
|
||||
// SIO/Keypad Input/RTC
|
||||
#define REG_SIODATA32 0x04000120
|
||||
#define REG_SIOCNT 0x04000128
|
||||
#define REG_KEYINPUT 0x04000130
|
||||
#define REG_KEYCNT 0x04000132
|
||||
#define REG_RCNT 0x04000134
|
||||
#define REG_EXTKEYIN 0x04000136
|
||||
#define REG_RTC 0x04000138
|
||||
|
||||
// IPC
|
||||
#define REG_IPCSYNC 0x04000180
|
||||
#define REG_IPCFIFOCNT 0x04000184
|
||||
#define REG_IPCFIFOSEND 0x04000188
|
||||
|
||||
// ROM
|
||||
#define REG_AUXSPICNT 0x040001A0
|
||||
#define REG_AUXSPIDATA 0x040001A2
|
||||
#define REG_GCROMCTRL 0x040001A4
|
||||
#define REG_GCCMDOUT 0x040001A8
|
||||
#define REG_ENCSEED0L 0x040001B0
|
||||
#define REG_ENCSEED1L 0x040001B4
|
||||
#define REG_ENCSEED0H 0x040001B8
|
||||
#define REG_ENCSEED1H 0x040001BC
|
||||
#define REG_SPICNT 0x040001C0
|
||||
#define REG_SPIDATA 0x040001C2
|
||||
|
||||
// Memory/IRQ
|
||||
#define REG_EXMEMCNT 0x04000204
|
||||
#define REG_WIFIWAITCNT 0x04000206
|
||||
#define REG_IME 0x04000208
|
||||
#define REG_IE 0x04000210
|
||||
#define REG_IF 0x04000214
|
||||
#define REG_VRAMCNTA 0x04000240
|
||||
#define REG_VRAMSTAT 0x04000240
|
||||
#define REG_VRAMCNTB 0x04000241
|
||||
#define REG_WRAMSTAT 0x04000241
|
||||
#define REG_VRAMCNTC 0x04000242
|
||||
#define REG_VRAMCNTD 0x04000243
|
||||
#define REG_VRAMCNTE 0x04000244
|
||||
#define REG_VRAMCNTF 0x04000245
|
||||
#define REG_VRAMCNTG 0x04000246
|
||||
#define REG_WRAMCNT 0x04000247
|
||||
#define REG_VRAMCNTH 0x04000248
|
||||
#define REG_VRAMCNTI 0x04000249
|
||||
|
||||
// Math
|
||||
#define REG_DIVCNT 0x04000280
|
||||
#define REG_DIVNUMER 0x04000290
|
||||
#define REG_DIVDENOM 0x04000298
|
||||
#define REG_DIVRESULT 0x040002A0
|
||||
#define REG_DIVREMRESULT 0x040002A8
|
||||
#define REG_SQRTCNT 0x040002B0
|
||||
#define REG_SQRTRESULT 0x040002B4
|
||||
#define REG_SQRTPARAM 0x040002B8
|
||||
|
||||
// Other
|
||||
#define REG_POSTFLG 0x04000300
|
||||
#define REG_HALTCNT 0x04000301
|
||||
#define REG_POWCNT1 0x04000304
|
||||
#define REG_POWCNT2 0x04000304
|
||||
#define REG_BIOSPROT 0x04000308
|
||||
|
||||
#define REG_DISPB_DISPCNT 0x04001000
|
||||
#define REG_DISPB_BG0CNT 0x04001008
|
||||
#define REG_DISPB_BG1CNT 0x0400100A
|
||||
#define REG_DISPB_BG2CNT 0x0400100C
|
||||
#define REG_DISPB_BG3CNT 0x0400100E
|
||||
#define REG_DISPB_BG0HOFS 0x04001010
|
||||
#define REG_DISPB_BG0VOFS 0x04001012
|
||||
#define REG_DISPB_BG1HOFS 0x04001014
|
||||
#define REG_DISPB_BG1VOFS 0x04001016
|
||||
#define REG_DISPB_BG2HOFS 0x04001018
|
||||
#define REG_DISPB_BG2VOFS 0x0400101A
|
||||
#define REG_DISPB_BG3HOFS 0x0400101C
|
||||
#define REG_DISPB_BG3VOFS 0x0400101E
|
||||
#define REG_DISPB_BG2PA 0x04001020
|
||||
#define REG_DISPB_BG2PB 0x04001022
|
||||
#define REG_DISPB_BG2PC 0x04001024
|
||||
#define REG_DISPB_BG2PD 0x04001026
|
||||
#define REG_DISPB_BG2XL 0x04001028
|
||||
#define REG_DISPB_BG2XH 0x0400102A
|
||||
#define REG_DISPB_BG2YL 0x0400102C
|
||||
#define REG_DISPB_BG2YH 0x0400102E
|
||||
#define REG_DISPB_BG3PA 0x04001030
|
||||
#define REG_DISPB_BG3PB 0x04001032
|
||||
#define REG_DISPB_BG3PC 0x04001034
|
||||
#define REG_DISPB_BG3PD 0x04001036
|
||||
#define REG_DISPB_BG3XL 0x04001038
|
||||
#define REG_DISPB_BG3XH 0x0400103A
|
||||
#define REG_DISPB_BG3YL 0x0400103C
|
||||
#define REG_DISPB_BG3YH 0x0400103E
|
||||
#define REG_DISPB_WIN0H 0x04001040
|
||||
#define REG_DISPB_WIN1H 0x04001042
|
||||
#define REG_DISPB_WIN0V 0x04001044
|
||||
#define REG_DISPB_WIN1V 0x04001046
|
||||
#define REG_DISPB_WININ 0x04001048
|
||||
#define REG_DISPB_WINOUT 0x0400104A
|
||||
#define REG_DISPB_MOSAIC 0x0400104C
|
||||
#define REG_DISPB_BLDCNT 0x04001050
|
||||
#define REG_DISPB_BLDALPHA 0x04001052
|
||||
#define REG_DISPB_BLDY 0x04001054
|
||||
#define REG_DISPB_MASTERBRIGHT 0x0400106C
|
||||
|
||||
// Receive ports
|
||||
#define REG_IPCFIFORECV 0x04100000
|
||||
#define REG_GCDATAIN 0x04100010
|
||||
|
||||
#endif
|
|
@ -0,0 +1,336 @@
|
|||
/* Copyright (C) 2006 Normmatt
|
||||
Copyright (C) 2006 Theo Berkau
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "saves.h"
|
||||
#include "MMU.h"
|
||||
#include "NDSSystem.h"
|
||||
|
||||
#define SAVESTATE_VERSION 010
|
||||
|
||||
u8 sram_read (u32 address) {
|
||||
address = address - SRAM_ADDRESS;
|
||||
|
||||
if ( address > SRAM_SIZE )
|
||||
return 0;
|
||||
|
||||
return MMU.CART_RAM[address];
|
||||
|
||||
}
|
||||
|
||||
void sram_write (u32 address, u8 value) {
|
||||
|
||||
address = address - SRAM_ADDRESS;
|
||||
|
||||
if ( address < SRAM_SIZE )
|
||||
MMU.CART_RAM[address] = value;
|
||||
|
||||
}
|
||||
|
||||
int sram_load (const char *file_name) {
|
||||
|
||||
FILE *file;
|
||||
|
||||
file = fopen ( file_name, "rb" );
|
||||
if( file == NULL )
|
||||
return 0;
|
||||
|
||||
fread ( MMU.CART_RAM, SRAM_SIZE, 1, file );
|
||||
|
||||
fclose ( file );
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
int sram_save (const char *file_name) {
|
||||
|
||||
FILE *file;
|
||||
|
||||
file = fopen ( file_name, "wb" );
|
||||
if( file == NULL )
|
||||
return 0;
|
||||
|
||||
fwrite ( MMU.CART_RAM, SRAM_SIZE, 1, file );
|
||||
|
||||
fclose ( file );
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
int savestate_load (const char *file_name) {
|
||||
#ifdef HAVE_LIBZ
|
||||
|
||||
gzFile file;
|
||||
char idstring[30];
|
||||
u8 version;
|
||||
int i;
|
||||
|
||||
file = gzopen( file_name, "rb" );
|
||||
if( file == NULL )
|
||||
return 0;
|
||||
|
||||
memset(idstring, 0, 30);
|
||||
gzgets(file, idstring, 23);
|
||||
|
||||
if (strncmp("DeSmuME Savestate File", idstring, 22) != 0)
|
||||
{
|
||||
gzclose (file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
version = gzgetc(file);
|
||||
|
||||
// Read ARM7 cpu registers
|
||||
gzread(file, &NDS_ARM7.proc_ID, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.instruction, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.instruct_adr, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.next_instruction, sizeof(u32));
|
||||
gzread(file, NDS_ARM7.R, sizeof(u32) * 16);
|
||||
gzread(file, &NDS_ARM7.CPSR, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM7.SPSR, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM7.R13_usr, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R14_usr, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R13_svc, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R14_svc, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R13_abt, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R14_abt, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R13_und, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R14_und, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R13_irq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R14_irq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R8_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R9_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R10_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R11_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R12_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R13_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.R14_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.SPSR_svc, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM7.SPSR_abt, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM7.SPSR_und, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM7.SPSR_irq, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM7.SPSR_fiq, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM7.intVector, sizeof(u32));
|
||||
gzread(file, &NDS_ARM7.LDTBit, sizeof(u8));
|
||||
gzread(file, &NDS_ARM7.waitIRQ, sizeof(BOOL));
|
||||
gzread(file, &NDS_ARM7.wIRQ, sizeof(BOOL));
|
||||
gzread(file, &NDS_ARM7.wirq, sizeof(BOOL));
|
||||
|
||||
// Read ARM9 cpu registers
|
||||
gzread(file, &NDS_ARM9.proc_ID, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.instruction, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.instruct_adr, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.next_instruction, sizeof(u32));
|
||||
gzread(file, NDS_ARM9.R, sizeof(u32) * 16);
|
||||
gzread(file, &NDS_ARM9.CPSR, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM9.SPSR, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM9.R13_usr, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R14_usr, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R13_svc, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R14_svc, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R13_abt, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R14_abt, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R13_und, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R14_und, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R13_irq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R14_irq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R8_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R9_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R10_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R11_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R12_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R13_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.R14_fiq, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.SPSR_svc, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM9.SPSR_abt, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM9.SPSR_und, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM9.SPSR_irq, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM9.SPSR_fiq, sizeof(Status_Reg));
|
||||
gzread(file, &NDS_ARM9.intVector, sizeof(u32));
|
||||
gzread(file, &NDS_ARM9.LDTBit, sizeof(u8));
|
||||
gzread(file, &NDS_ARM9.waitIRQ, sizeof(BOOL));
|
||||
gzread(file, &NDS_ARM9.wIRQ, sizeof(BOOL));
|
||||
gzread(file, &NDS_ARM9.wirq, sizeof(BOOL));
|
||||
|
||||
// Read in other internal variables that are important
|
||||
gzread (file, &nds, sizeof(NDSSystem));
|
||||
|
||||
// Read in memory/registers specific to the ARM9
|
||||
gzread (file, ARM9Mem.ARM9_ITCM, 0x8000);
|
||||
gzread (file ,ARM9Mem.ARM9_DTCM, 0x4000);
|
||||
gzread (file ,ARM9Mem.ARM9_WRAM, 0x1000000);
|
||||
gzread (file, ARM9Mem.MAIN_MEM, 0x400000);
|
||||
gzread (file, ARM9Mem.ARM9_REG, 0x10000);
|
||||
gzread (file, ARM9Mem.ARM9_VMEM, 0x800);
|
||||
gzread (file, ARM9Mem.ARM9_OAM, 0x800);
|
||||
gzread (file, ARM9Mem.ARM9_ABG, 0x80000);
|
||||
gzread (file, ARM9Mem.ARM9_BBG, 0x20000);
|
||||
gzread (file, ARM9Mem.ARM9_AOBJ, 0x40000);
|
||||
gzread (file, ARM9Mem.ARM9_BOBJ, 0x20000);
|
||||
gzread (file, ARM9Mem.ARM9_LCD, 0xA4000);
|
||||
|
||||
// Read in memory/registers specific to the ARM7
|
||||
gzread (file, MMU.ARM7_ERAM, 0x10000);
|
||||
gzread (file, MMU.ARM7_REG, 0x10000);
|
||||
gzread (file, MMU.ARM7_WIRAM, 0x10000);
|
||||
|
||||
// Read in shared memory
|
||||
gzread (file, MMU.SWIRAM, 0x8000);
|
||||
|
||||
// Internal variable states should be regenerated
|
||||
|
||||
// This should regenerate the vram banks
|
||||
for (i = 0; i < 0xA; i++)
|
||||
MMU_write8(ARMCPU_ARM9, 0x04000240+i, MMU_read8(ARMCPU_ARM9, 0x04000240+i));
|
||||
|
||||
// This should regenerate the graphics power control register
|
||||
MMU_write16(ARMCPU_ARM9, 0x04000304, MMU_read16(ARMCPU_ARM9, 0x04000304));
|
||||
|
||||
GPU_setVideoProp(MainScreen.gpu, MMU_read32(ARMCPU_ARM9, 0x04000000));
|
||||
GPU_setVideoProp(SubScreen.gpu, MMU_read32(ARMCPU_ARM9, 0x04000000));
|
||||
gzclose (file);
|
||||
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int savestate_save (const char *file_name) {
|
||||
#ifdef HAVE_LIBZ
|
||||
gzFile file;
|
||||
|
||||
file = gzopen( file_name, "wb" );
|
||||
if( file == NULL )
|
||||
return 0;
|
||||
|
||||
gzputs(file, "DeSmuME Savestate File");
|
||||
gzputc(file, SAVESTATE_VERSION);
|
||||
|
||||
// Save ARM7 cpu registers
|
||||
gzwrite(file, &NDS_ARM7.proc_ID, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.instruction, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.instruct_adr, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.next_instruction, sizeof(u32));
|
||||
gzwrite(file, NDS_ARM7.R, sizeof(u32) * 16);
|
||||
gzwrite(file, &NDS_ARM7.CPSR, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM7.SPSR, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM7.R13_usr, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R14_usr, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R13_svc, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R14_svc, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R13_abt, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R14_abt, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R13_und, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R14_und, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R13_irq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R14_irq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R8_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R9_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R10_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R11_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R12_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R13_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.R14_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.SPSR_svc, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM7.SPSR_abt, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM7.SPSR_und, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM7.SPSR_irq, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM7.SPSR_fiq, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM7.intVector, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM7.LDTBit, sizeof(u8));
|
||||
gzwrite(file, &NDS_ARM7.waitIRQ, sizeof(BOOL));
|
||||
gzwrite(file, &NDS_ARM7.wIRQ, sizeof(BOOL));
|
||||
gzwrite(file, &NDS_ARM7.wirq, sizeof(BOOL));
|
||||
|
||||
// Save ARM9 cpu registers
|
||||
gzwrite(file, &NDS_ARM9.proc_ID, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.instruction, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.instruct_adr, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.next_instruction, sizeof(u32));
|
||||
gzwrite(file, NDS_ARM9.R, sizeof(u32) * 16);
|
||||
gzwrite(file, &NDS_ARM9.CPSR, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM9.SPSR, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM9.R13_usr, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R14_usr, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R13_svc, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R14_svc, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R13_abt, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R14_abt, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R13_und, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R14_und, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R13_irq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R14_irq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R8_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R9_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R10_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R11_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R12_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R13_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.R14_fiq, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.SPSR_svc, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM9.SPSR_abt, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM9.SPSR_und, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM9.SPSR_irq, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM9.SPSR_fiq, sizeof(Status_Reg));
|
||||
gzwrite(file, &NDS_ARM9.intVector, sizeof(u32));
|
||||
gzwrite(file, &NDS_ARM9.LDTBit, sizeof(u8));
|
||||
gzwrite(file, &NDS_ARM9.waitIRQ, sizeof(BOOL));
|
||||
gzwrite(file, &NDS_ARM9.wIRQ, sizeof(BOOL));
|
||||
gzwrite(file, &NDS_ARM9.wirq, sizeof(BOOL));
|
||||
|
||||
// Save other internal variables that are important
|
||||
gzwrite (file, &nds, sizeof(NDSSystem));
|
||||
|
||||
// Save memory/registers specific to the ARM9
|
||||
gzwrite (file, ARM9Mem.ARM9_ITCM, 0x8000);
|
||||
gzwrite (file ,ARM9Mem.ARM9_DTCM, 0x4000);
|
||||
gzwrite (file ,ARM9Mem.ARM9_WRAM, 0x1000000);
|
||||
gzwrite (file, ARM9Mem.MAIN_MEM, 0x400000);
|
||||
gzwrite (file, ARM9Mem.ARM9_REG, 0x10000);
|
||||
gzwrite (file, ARM9Mem.ARM9_VMEM, 0x800);
|
||||
gzwrite (file, ARM9Mem.ARM9_OAM, 0x800);
|
||||
gzwrite (file, ARM9Mem.ARM9_ABG, 0x80000);
|
||||
gzwrite (file, ARM9Mem.ARM9_BBG, 0x20000);
|
||||
gzwrite (file, ARM9Mem.ARM9_AOBJ, 0x40000);
|
||||
gzwrite (file, ARM9Mem.ARM9_BOBJ, 0x20000);
|
||||
gzwrite (file, ARM9Mem.ARM9_LCD, 0xA4000);
|
||||
|
||||
// Save memory/registers specific to the ARM7
|
||||
gzwrite (file, MMU.ARM7_ERAM, 0x10000);
|
||||
gzwrite (file, MMU.ARM7_REG, 0x10000);
|
||||
gzwrite (file, MMU.ARM7_WIRAM, 0x10000);
|
||||
|
||||
// Save shared memory
|
||||
gzwrite (file, MMU.SWIRAM, 0x8000);
|
||||
gzclose (file);
|
||||
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/* Copyright (C) 2006 Normmatt
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _SRAM_H
|
||||
#define _SRAM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define SRAM_ADDRESS 0x0A000000
|
||||
#define SRAM_SIZE 0x10000
|
||||
|
||||
u8 sram_read (u32 address);
|
||||
void sram_write (u32 address, u8 value);
|
||||
int sram_load (const char *file_name);
|
||||
int sram_save (const char *file_name);
|
||||
|
||||
int savestate_load (const char *file_name);
|
||||
int savestate_save (const char *file_name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,197 @@
|
|||
/* Copyright 2005-2006 Theo Berkau
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
Yabause 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 Yabause; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "types.h"
|
||||
#include "SPU.h"
|
||||
#include "sndsdl.h"
|
||||
#include "debug.h"
|
||||
|
||||
int SNDSDLInit(int buffersize);
|
||||
void SNDSDLDeInit();
|
||||
void SNDSDLUpdateAudio(s16 *buffer, u32 num_samples);
|
||||
u32 SNDSDLGetAudioSpace();
|
||||
void SNDSDLMuteAudio();
|
||||
void SNDSDLUnMuteAudio();
|
||||
void SNDSDLSetVolume(int volume);
|
||||
|
||||
SoundInterface_struct SNDSDL = {
|
||||
SNDCORE_SDL,
|
||||
"SDL Sound Interface",
|
||||
SNDSDLInit,
|
||||
SNDSDLDeInit,
|
||||
SNDSDLUpdateAudio,
|
||||
SNDSDLGetAudioSpace,
|
||||
SNDSDLMuteAudio,
|
||||
SNDSDLUnMuteAudio,
|
||||
SNDSDLSetVolume
|
||||
};
|
||||
|
||||
static u16 *stereodata16;
|
||||
static u32 soundoffset;
|
||||
static volatile u32 soundpos;
|
||||
static u32 soundlen;
|
||||
static u32 soundbufsize;
|
||||
static SDL_AudioSpec audiofmt;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void MixAudio(void *userdata, Uint8 *stream, int len) {
|
||||
int i;
|
||||
Uint8 *soundbuf=(Uint8 *)stereodata16;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (soundpos >= soundbufsize)
|
||||
soundpos = 0;
|
||||
|
||||
stream[i] = soundbuf[soundpos];
|
||||
soundpos++;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int SNDSDLInit(int buffersize)
|
||||
{
|
||||
SDL_InitSubSystem(SDL_INIT_AUDIO);
|
||||
// if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0);
|
||||
// return -1;
|
||||
|
||||
audiofmt.freq = 44100;
|
||||
audiofmt.format = AUDIO_S16SYS;
|
||||
audiofmt.channels = 2;
|
||||
audiofmt.samples = (audiofmt.freq / 60) * 2;
|
||||
audiofmt.callback = MixAudio;
|
||||
audiofmt.userdata = NULL;
|
||||
|
||||
//samples should be a power of 2 according to SDL-doc
|
||||
//so normalize it to the nearest power of 2 here
|
||||
u32 normSamples = 512;
|
||||
while (normSamples < audiofmt.samples)
|
||||
normSamples <<= 1;
|
||||
|
||||
audiofmt.samples = normSamples;
|
||||
|
||||
soundlen = audiofmt.freq / 60; // 60 for NTSC
|
||||
soundbufsize = buffersize * sizeof(s16) * 2;
|
||||
|
||||
if (SDL_OpenAudio(&audiofmt, NULL) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((stereodata16 = (u16 *)malloc(soundbufsize)) == NULL)
|
||||
return -1;
|
||||
|
||||
memset(stereodata16, 0, soundbufsize);
|
||||
|
||||
soundpos = 0;
|
||||
|
||||
SDL_PauseAudio(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SNDSDLDeInit()
|
||||
{
|
||||
SDL_CloseAudio();
|
||||
|
||||
if (stereodata16)
|
||||
free(stereodata16);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int SNDSDLReset()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SNDSDLUpdateAudio(s16 *buffer, u32 num_samples)
|
||||
{
|
||||
u32 copy1size=0, copy2size=0;
|
||||
SDL_LockAudio();
|
||||
|
||||
if ((soundbufsize - soundoffset) < (num_samples * sizeof(s16) * 2))
|
||||
{
|
||||
copy1size = (soundbufsize - soundoffset);
|
||||
copy2size = (num_samples * sizeof(s16) * 2) - copy1size;
|
||||
}
|
||||
else
|
||||
{
|
||||
copy1size = (num_samples * sizeof(s16) * 2);
|
||||
copy2size = 0;
|
||||
}
|
||||
|
||||
memcpy((((u8 *)stereodata16)+soundoffset), buffer, copy1size);
|
||||
// ScspConvert32uto16s((s32 *)leftchanbuffer, (s32 *)rightchanbuffer, (s16 *)(((u8 *)stereodata16)+soundoffset), copy1size / sizeof(s16) / 2);
|
||||
|
||||
if (copy2size)
|
||||
memcpy(stereodata16, ((u8 *)buffer)+copy1size, copy2size);
|
||||
// ScspConvert32uto16s((s32 *)leftchanbuffer, (s32 *)rightchanbuffer, (s16 *)stereodata16, copy2size / sizeof(s16) / 2);
|
||||
|
||||
soundoffset += copy1size + copy2size;
|
||||
soundoffset %= soundbufsize;
|
||||
|
||||
SDL_UnlockAudio();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
u32 SNDSDLGetAudioSpace()
|
||||
{
|
||||
u32 freespace=0;
|
||||
|
||||
if (soundoffset > soundpos)
|
||||
freespace = soundbufsize - soundoffset + soundpos;
|
||||
else
|
||||
freespace = soundpos - soundoffset;
|
||||
|
||||
return (freespace / sizeof(s16) / 2);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SNDSDLMuteAudio()
|
||||
{
|
||||
SDL_PauseAudio(1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SNDSDLUnMuteAudio()
|
||||
{
|
||||
SDL_PauseAudio(0);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SNDSDLSetVolume(int volume)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,26 @@
|
|||
/* Copyright 2005-2006 Theo Berkau
|
||||
|
||||
This file is part of DeSmuME.
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
Yabause 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 Yabause; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef SNDSDL_H
|
||||
#define SNDSDL_H
|
||||
|
||||
#define SNDCORE_SDL 2
|
||||
|
||||
extern SoundInterface_struct SNDSDL;
|
||||
#endif
|
|
@ -0,0 +1,927 @@
|
|||
/*
|
||||
Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
Code added on 18/08/2006 by shash
|
||||
- Missing missaligned addresses correction
|
||||
(reference in http://nocash.emubase.de/gbatek.htm#cpumemoryalignments)
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "bios.h"
|
||||
#include "debug.h"
|
||||
#include "MMU.h"
|
||||
|
||||
#define REG_NUM(i, n) (((i)>>n)&0x7)
|
||||
|
||||
extern BOOL execute;
|
||||
|
||||
static u32 FASTCALL OP_UND_THUMB(armcpu_t *cpu)
|
||||
{
|
||||
execute = FALSE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LSL_0(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[REG_NUM(i, 0)] = cpu->R[REG_NUM(i, 3)];
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LSL(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 v = (i>>6) & 0x1F;
|
||||
cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 3)], 32-v);
|
||||
cpu->R[REG_NUM(i, 0)] = (cpu->R[REG_NUM(i, 3)] << v);
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LSR_0(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
// cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 3)]);
|
||||
cpu->R[REG_NUM(i, 0)] = 0;
|
||||
cpu->CPSR.bits.N = 0;
|
||||
cpu->CPSR.bits.Z = 1;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LSR(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 v = (i>>6) & 0x1F;
|
||||
cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1);
|
||||
cpu->R[REG_NUM(i, 0)] = (cpu->R[REG_NUM(i, 3)] >> v);
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ASR_0(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 3)]);
|
||||
cpu->R[REG_NUM(i, 0)] = BIT31(cpu->R[REG_NUM(i, 3)])*0xFFFFFFFF;
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ASR(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 v = (i>>6) & 0x1F;
|
||||
cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 3)], v-1);
|
||||
cpu->R[REG_NUM(i, 0)] = (((s32)cpu->R[REG_NUM(i, 3)]) >> v);
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ADD_REG(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 a = cpu->R[REG_NUM(i, 3)];
|
||||
u32 b = cpu->R[REG_NUM(i, 6)];
|
||||
cpu->R[REG_NUM(i, 0)] = a + b;
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(a, b, cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.V = SIGNED_OVERFLOW(a, b, cpu->R[REG_NUM(i, 0)]);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_SUB_REG(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 a = cpu->R[REG_NUM(i, 3)];
|
||||
u32 b = cpu->R[REG_NUM(i, 6)];
|
||||
cpu->R[REG_NUM(i, 0)] = a - b;
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(a, b, cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, b, cpu->R[REG_NUM(i, 0)]);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ADD_IMM3(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 a = cpu->R[REG_NUM(i, 3)];
|
||||
cpu->R[REG_NUM(i, 0)] = a + REG_NUM(i, 6);
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.V = SIGNED_OVERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_SUB_IMM3(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 a = cpu->R[REG_NUM(i, 3)];
|
||||
cpu->R[REG_NUM(i, 0)] = a - REG_NUM(i, 6);
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_MOV_IMM8(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[REG_NUM(i, 8)] = i & 0xFF;
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 8)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 8)] == 0;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_CMP_IMM8(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 tmp = cpu->R[REG_NUM(i, 8)] - (i & 0xFF);
|
||||
cpu->CPSR.bits.N = BIT31(tmp);
|
||||
cpu->CPSR.bits.Z = tmp == 0;
|
||||
cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp);
|
||||
cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ADD_IMM8(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 tmp = cpu->R[REG_NUM(i, 8)] + (i & 0xFF);
|
||||
cpu->CPSR.bits.N = BIT31(tmp);
|
||||
cpu->CPSR.bits.Z = tmp == 0;
|
||||
cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp);
|
||||
cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp);
|
||||
cpu->R[REG_NUM(i, 8)] = tmp;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_SUB_IMM8(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 tmp = cpu->R[REG_NUM(i, 8)] - (i & 0xFF);
|
||||
cpu->CPSR.bits.N = BIT31(tmp);
|
||||
cpu->CPSR.bits.Z = tmp == 0;
|
||||
cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp);
|
||||
cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp);
|
||||
cpu->R[REG_NUM(i, 8)] = tmp;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_AND(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[REG_NUM(i, 0)] &= cpu->R[REG_NUM(i, 3)];
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_EOR(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[REG_NUM(i, 0)] ^= cpu->R[REG_NUM(i, 3)];
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LSL_REG(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 v = cpu->R[REG_NUM(i, 3)]&0xFF;
|
||||
|
||||
if(!v)
|
||||
{
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
return 3;
|
||||
}
|
||||
if(v<32)
|
||||
{
|
||||
cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], 32-v);
|
||||
cpu->R[REG_NUM(i, 0)] <<= v;
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
return 3;
|
||||
}
|
||||
if(v==32)
|
||||
cpu->CPSR.bits.C = BIT0(cpu->R[REG_NUM(i, 0)]);
|
||||
else
|
||||
cpu->CPSR.bits.C = 0;
|
||||
cpu->R[REG_NUM(i, 0)] = 0;
|
||||
cpu->CPSR.bits.N = 0;
|
||||
cpu->CPSR.bits.Z = 1;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LSR_REG(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 v = cpu->R[REG_NUM(i, 3)]&0xFF;
|
||||
|
||||
if(!v)
|
||||
{
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
return 3;
|
||||
}
|
||||
if(v<32)
|
||||
{
|
||||
cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1);
|
||||
cpu->R[REG_NUM(i, 0)] >>= v;
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
return 3;
|
||||
}
|
||||
if(v==32)
|
||||
cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
else
|
||||
cpu->CPSR.bits.C = 0;
|
||||
cpu->R[REG_NUM(i, 0)] = 0;
|
||||
cpu->CPSR.bits.N = 0;
|
||||
cpu->CPSR.bits.Z = 1;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ASR_REG(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 v = cpu->R[REG_NUM(i, 3)]&0xFF;
|
||||
|
||||
if(!v)
|
||||
{
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
return 3;
|
||||
}
|
||||
if(v<32)
|
||||
{
|
||||
cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1);
|
||||
cpu->R[REG_NUM(i, 0)] = (u32)(((s32)cpu->R[REG_NUM(i, 0)]) >> v);
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
return 3;
|
||||
}
|
||||
|
||||
cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->R[REG_NUM(i, 0)] = BIT31(cpu->R[REG_NUM(i, 0)])*0xFFFFFFFF;
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ADC_REG(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 a = cpu->R[REG_NUM(i, 0)];
|
||||
u32 b = cpu->R[REG_NUM(i, 3)];
|
||||
u32 tmp = b + cpu->CPSR.bits.C;
|
||||
u32 res = a + tmp;
|
||||
|
||||
cpu->R[REG_NUM(i, 0)] = res;
|
||||
|
||||
cpu->CPSR.bits.N = BIT31(res);
|
||||
cpu->CPSR.bits.Z = res == 0;
|
||||
|
||||
cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(b, cpu->CPSR.bits.C, tmp) | UNSIGNED_OVERFLOW(tmp, a, res);
|
||||
cpu->CPSR.bits.V = SIGNED_OVERFLOW(b, cpu->CPSR.bits.C, tmp) | SIGNED_OVERFLOW(tmp, a, res);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_SBC_REG(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 a = cpu->R[REG_NUM(i, 0)];
|
||||
u32 b = cpu->R[REG_NUM(i, 3)];
|
||||
u32 tmp = a - (!cpu->CPSR.bits.C);
|
||||
u32 res = tmp - b;
|
||||
cpu->R[REG_NUM(i, 0)] = res;
|
||||
|
||||
cpu->CPSR.bits.N = BIT31(res);
|
||||
cpu->CPSR.bits.Z = res == 0;
|
||||
|
||||
cpu->CPSR.bits.C = (!UNSIGNED_UNDERFLOW(a, !cpu->CPSR.bits.C, tmp)) & (!UNSIGNED_OVERFLOW(tmp, b, res));
|
||||
cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, !cpu->CPSR.bits.C, tmp) | SIGNED_OVERFLOW(tmp, b, res);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ROR_REG(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 v = cpu->R[REG_NUM(i, 3)]&0xFF;
|
||||
|
||||
if(v == 0)
|
||||
{
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
return 3;
|
||||
}
|
||||
v &= 0xF;
|
||||
if(v == 0)
|
||||
{
|
||||
cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
return 3;
|
||||
}
|
||||
cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1);
|
||||
cpu->R[REG_NUM(i, 0)] = ROR(cpu->R[REG_NUM(i, 0)], v);
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_TST(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 tmp = cpu->R[REG_NUM(i, 0)] & cpu->R[REG_NUM(i, 3)];
|
||||
cpu->CPSR.bits.N = BIT31(tmp);
|
||||
cpu->CPSR.bits.Z = tmp == 0;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_NEG(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 a = cpu->R[REG_NUM(i, 3)];
|
||||
cpu->R[REG_NUM(i, 0)] = -((signed int)a);
|
||||
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(0, a, cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.V = SIGNED_UNDERFLOW(0, a, cpu->R[REG_NUM(i, 0)]);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_CMP(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 tmp = cpu->R[REG_NUM(i, 0)] -cpu->R[REG_NUM(i, 3)];
|
||||
|
||||
cpu->CPSR.bits.N = BIT31(tmp);
|
||||
cpu->CPSR.bits.Z = tmp == 0;
|
||||
cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp);
|
||||
cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_CMN(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 tmp = cpu->R[REG_NUM(i, 0)] + cpu->R[REG_NUM(i, 3)];
|
||||
|
||||
//execute = FALSE;
|
||||
//log::ajouter("OP_CMN THUMB");
|
||||
cpu->CPSR.bits.N = BIT31(tmp);
|
||||
cpu->CPSR.bits.Z = tmp == 0;
|
||||
cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp);
|
||||
cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ORR(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[REG_NUM(i, 0)] |= cpu->R[REG_NUM(i, 3)];
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_MUL_REG(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[REG_NUM(i, 0)] *= cpu->R[REG_NUM(i, 3)];
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_BIC(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[REG_NUM(i, 0)] &= (~cpu->R[REG_NUM(i, 3)]);
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_MVN(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[REG_NUM(i, 0)] = (~cpu->R[REG_NUM(i, 3)]);
|
||||
cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]);
|
||||
cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0;
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ADD_SPE(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 Rd = (i&7) | ((i>>4)&8);
|
||||
cpu->R[Rd] += cpu->R[REG_POS(i, 3)];
|
||||
|
||||
if(Rd==15)
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_CMP_SPE(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 Rn = (i&7) | ((i>>4)&8);
|
||||
u32 tmp = cpu->R[Rn] -cpu->R[REG_POS(i, 3)];
|
||||
|
||||
cpu->CPSR.bits.N = BIT31(tmp);
|
||||
cpu->CPSR.bits.Z = tmp == 0;
|
||||
cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[Rn], cpu->R[REG_POS(i, 3)], tmp);
|
||||
cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[Rn], cpu->R[REG_POS(i, 3)], tmp);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_MOV_SPE(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 Rd = (i&7) | ((i>>4)&8);
|
||||
cpu->R[Rd] = cpu->R[REG_POS(i, 3)];
|
||||
|
||||
if(Rd==15)
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_BX_THUMB(armcpu_t *cpu)
|
||||
{
|
||||
u32 Rm = cpu->R[REG_POS(cpu->instruction, 3)];
|
||||
|
||||
cpu->CPSR.bits.T = BIT0(Rm);
|
||||
cpu->R[15] = (Rm & 0xFFFFFFFE);
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_BLX_THUMB(armcpu_t *cpu)
|
||||
{
|
||||
u32 Rm = cpu->R[REG_POS(cpu->instruction, 3)];
|
||||
|
||||
cpu->CPSR.bits.T = BIT0(Rm);
|
||||
cpu->R[14] = cpu->next_instruction | 1;
|
||||
cpu->R[15] = (Rm & 0xFFFFFFFE);
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDR_PCREL(armcpu_t *cpu)
|
||||
{
|
||||
u32 adr = (cpu->R[15]&0xFFFFFFFC) + ((cpu->instruction&0xFF)<<2);
|
||||
|
||||
cpu->R[REG_NUM(cpu->instruction, 8)] = MMU_readWord(cpu->proc_ID, adr);
|
||||
|
||||
return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_STR_REG_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 6)] + cpu->R[REG_NUM(i, 3)];
|
||||
MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_NUM(i, 0)]);
|
||||
|
||||
return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_STRH_REG_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)];
|
||||
MMU_writeHWord(cpu->proc_ID, adr, ((u16)cpu->R[REG_NUM(i, 0)]));
|
||||
|
||||
return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_STRB_REG_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)];
|
||||
MMU_writeByte(cpu->proc_ID, adr, ((u8)cpu->R[REG_NUM(i, 0)]));
|
||||
|
||||
return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDRSB_REG_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)];
|
||||
cpu->R[REG_NUM(i, 0)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr));
|
||||
|
||||
return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDR_REG_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = (cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]);
|
||||
u32 tempValue = MMU_readWord(cpu->proc_ID, adr&0xFFFFFFFC);
|
||||
|
||||
adr = (adr&3)*8;
|
||||
tempValue = (tempValue>>adr) | (tempValue<<(32-adr));
|
||||
cpu->R[REG_NUM(i, 0)] = tempValue;
|
||||
|
||||
return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDRH_REG_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)];
|
||||
cpu->R[REG_NUM(i, 0)] = (u32)MMU_readHWord(cpu->proc_ID, adr);
|
||||
|
||||
return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDRB_REG_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)];
|
||||
cpu->R[REG_NUM(i, 0)] = (u32)MMU_readByte(cpu->proc_ID, adr);
|
||||
|
||||
return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDRSH_REG_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)];
|
||||
cpu->R[REG_NUM(i, 0)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr));
|
||||
|
||||
return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_STR_IMM_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>4)&0x7C);
|
||||
MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_NUM(i, 0)]);
|
||||
|
||||
return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDR_IMM_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>4)&0x7C);
|
||||
u32 tempValue = MMU_readWord(cpu->proc_ID, adr&0xFFFFFFFC);
|
||||
adr = (adr&3)*8;
|
||||
tempValue = (tempValue>>adr) | (tempValue<<(32-adr));
|
||||
cpu->R[REG_NUM(i, 0)] = tempValue;
|
||||
|
||||
return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_STRB_IMM_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>6)&0x1F);
|
||||
MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_NUM(i, 0)]);
|
||||
|
||||
return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDRB_IMM_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>6)&0x1F);
|
||||
cpu->R[REG_NUM(i, 0)] = MMU_readByte(cpu->proc_ID, adr);
|
||||
|
||||
return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_STRH_IMM_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>5)&0x3E);
|
||||
MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_NUM(i, 0)]);
|
||||
|
||||
return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDRH_IMM_OFF(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>5)&0x3E);
|
||||
cpu->R[REG_NUM(i, 0)] = MMU_readHWord(cpu->proc_ID, adr);
|
||||
|
||||
return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_STR_SPREL(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[13] + ((i&0xFF)<<2);
|
||||
MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_NUM(i, 8)]);
|
||||
|
||||
return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDR_SPREL(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[13] + ((i&0xFF)<<2);
|
||||
cpu->R[REG_NUM(i, 8)] = MMU_readWord(cpu->proc_ID, adr);
|
||||
|
||||
return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ADD_2PC(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[REG_NUM(i, 8)] = (cpu->R[15]&0xFFFFFFFC) + ((i&0xFF)<<2);
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ADD_2SP(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[REG_NUM(i, 8)] = cpu->R[13] + ((i&0xFF)<<2);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ADJUST_P_SP(armcpu_t *cpu)
|
||||
{
|
||||
cpu->R[13] += ((cpu->instruction&0x7F)<<2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_ADJUST_M_SP(armcpu_t *cpu)
|
||||
{
|
||||
cpu->R[13] -= ((cpu->instruction&0x7F)<<2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_PUSH(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[13] - 4;
|
||||
u32 c = 0, j;
|
||||
|
||||
for(j = 0; j<8; ++j)
|
||||
if(BIT_N(i, 7-j))
|
||||
{
|
||||
MMU_writeWord(cpu->proc_ID, adr, cpu->R[7-j]);
|
||||
c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
adr -= 4;
|
||||
}
|
||||
cpu->R[13] = adr + 4;
|
||||
|
||||
return c + 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_PUSH_LR(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[13] - 4;
|
||||
u32 c = 0, j;
|
||||
|
||||
MMU_writeWord(cpu->proc_ID, adr, cpu->R[14]);
|
||||
c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
adr -= 4;
|
||||
|
||||
for(j = 0; j<8; ++j)
|
||||
if(BIT_N(i, 7-j))
|
||||
{
|
||||
MMU_writeWord(cpu->proc_ID, adr, cpu->R[7-j]);
|
||||
c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
adr -= 4;
|
||||
}
|
||||
cpu->R[13] = adr + 4;
|
||||
|
||||
return c + 4;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_POP(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[13];
|
||||
u32 c = 0, j;
|
||||
|
||||
for(j = 0; j<8; ++j)
|
||||
if(BIT_N(i, j))
|
||||
{
|
||||
cpu->R[j] = MMU_readWord(cpu->proc_ID, adr);
|
||||
c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
adr += 4;
|
||||
}
|
||||
cpu->R[13] = adr;
|
||||
|
||||
return c + 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_POP_PC(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[13];
|
||||
u32 c = 0, j;
|
||||
u32 v;
|
||||
|
||||
for(j = 0; j<8; ++j)
|
||||
if(BIT_N(i, j))
|
||||
{
|
||||
cpu->R[j] = MMU_readWord(cpu->proc_ID, adr);
|
||||
c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
adr += 4;
|
||||
}
|
||||
|
||||
v = MMU_readWord(cpu->proc_ID, adr);
|
||||
c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
cpu->R[15] = v & 0xFFFFFFFE;
|
||||
cpu->next_instruction = v & 0xFFFFFFFE;
|
||||
if(cpu->proc_ID==0)
|
||||
cpu->CPSR.bits.T = BIT0(v);
|
||||
adr += 4;
|
||||
|
||||
cpu->R[13] = adr;
|
||||
return c + 5;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_BKPT_THUMB(armcpu_t *cpu)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_STMIA_THUMB(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 8)];
|
||||
u32 c = 0, j;
|
||||
|
||||
for(j = 0; j<8; ++j)
|
||||
if(BIT_N(i, j))
|
||||
{
|
||||
MMU_writeWord(cpu->proc_ID, adr, cpu->R[j]);
|
||||
c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
adr += 4;
|
||||
}
|
||||
cpu->R[REG_NUM(i, 8)] = adr;
|
||||
return c + 2;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_LDMIA_THUMB(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
u32 adr = cpu->R[REG_NUM(i, 8)];
|
||||
u32 c = 0, j;
|
||||
|
||||
for(j = 0; j<8; ++j)
|
||||
if(BIT_N(i, j))
|
||||
{
|
||||
cpu->R[j] = MMU_readWord(cpu->proc_ID, adr);
|
||||
c += MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF];
|
||||
adr += 4;
|
||||
}
|
||||
cpu->R[REG_NUM(i, 8)] = adr;
|
||||
return c + 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_B_COND(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
if(!TEST_COND((i>>8)&0xF, cpu->CPSR))
|
||||
return 1;
|
||||
|
||||
cpu->R[15] += ((s32)((s8)(i&0xFF)))<<1;
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_SWI_THUMB(armcpu_t *cpu)
|
||||
{
|
||||
if (((cpu->intVector != 0) ^ (cpu->proc_ID == ARMCPU_ARM9)))
|
||||
{
|
||||
/* we use an irq thats not in the irq tab, as
|
||||
it was replaced duie to a changed intVector */
|
||||
Status_Reg tmp = cpu->CPSR;
|
||||
armcpu_switchMode(cpu, SVC); /* enter svc mode */
|
||||
cpu->R[14] = cpu->R[15] - 4; /* jump to swi Vector */
|
||||
cpu->SPSR = tmp; /* save old CPSR as new SPSR */
|
||||
cpu->CPSR.bits.T = 0; /* handle as ARM32 code */
|
||||
cpu->CPSR.bits.I = cpu->SPSR.bits.I; /* keep int disable flag */
|
||||
cpu->R[15] = cpu->intVector + 0x08;
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 swinum = cpu->instruction & 0xFF;
|
||||
return cpu->swi_tab[swinum](cpu) + 3;
|
||||
}
|
||||
//return 3;
|
||||
}
|
||||
|
||||
#define SIGNEEXT_IMM11(i) (((i)&0x7FF) | (BIT10(i) * 0xFFFFF800))
|
||||
|
||||
static u32 FASTCALL OP_B_UNCOND(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[15] += (SIGNEEXT_IMM11(i)<<1);
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_BLX(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[15] = (cpu->R[14] + ((i&0x7FF)<<1))&0xFFFFFFFC;
|
||||
cpu->R[14] = cpu->next_instruction | 1;
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
cpu->CPSR.bits.T = 0;
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_BL_10(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[14] = cpu->R[15] + (SIGNEEXT_IMM11(i)<<12);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static u32 FASTCALL OP_BL_THUMB(armcpu_t *cpu)
|
||||
{
|
||||
u32 i = cpu->instruction;
|
||||
cpu->R[15] = (cpu->R[14] + ((i&0x7FF)<<1));
|
||||
cpu->R[14] = cpu->next_instruction | 1;
|
||||
cpu->next_instruction = cpu->R[15];
|
||||
return 3;
|
||||
}
|
||||
|
||||
#define TYPE_RETOUR u32
|
||||
#define CALLTYPE FASTCALL
|
||||
#define PARAMETRES armcpu_t *cpu
|
||||
#define NOM_THUMB_TAB thumb_instructions_set
|
||||
|
||||
#include "thumb_tabdef.inc"
|
|
@ -0,0 +1,30 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef THUMB_INSTRUCTIONS_H
|
||||
#define THUMB_INSTRUCTIONS_H
|
||||
|
||||
#include "armcpu.h"
|
||||
|
||||
extern u32 (* FASTCALL thumb_instructions_set[1024])(armcpu_t * cpu);
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,123 @@
|
|||
/* Copyright (C) 2005 Guillaume Duhamel
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef TYPES_HPP
|
||||
#define TYPES_HPP
|
||||
|
||||
#ifndef FASTCALL
|
||||
#ifdef __MINGW32__
|
||||
#define FASTCALL __attribute__((fastcall))
|
||||
#elif defined (__i386__)
|
||||
#define FASTCALL __attribute__((regparm(3)))
|
||||
#else
|
||||
#define FASTCALL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef INLINE
|
||||
#ifdef _MSC_VER
|
||||
#define INLINE _inline
|
||||
#else
|
||||
#define INLINE inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__LP64__)
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long u64;
|
||||
typedef unsigned long pointer;
|
||||
|
||||
typedef signed char s8;
|
||||
typedef signed short s16;
|
||||
typedef signed int s32;
|
||||
typedef signed long s64;
|
||||
#else
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned long u32;
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned __int64 u64;
|
||||
#else
|
||||
typedef unsigned long long u64;
|
||||
#endif
|
||||
typedef unsigned long pointer;
|
||||
|
||||
typedef signed char s8;
|
||||
typedef signed short s16;
|
||||
typedef signed long s32;
|
||||
#ifdef _MSC_VER
|
||||
typedef __int64 s64;
|
||||
#else
|
||||
typedef signed long long s64;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef u8 uint8;
|
||||
typedef u16 uint16;
|
||||
typedef u32 uint32;
|
||||
|
||||
typedef int BOOL;
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define PACKED __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
# define LOCAL_BE
|
||||
#else
|
||||
# define LOCAL_LE
|
||||
#endif
|
||||
|
||||
/* little endian (ds' endianess) to local endianess convert macros */
|
||||
#ifdef LOCAL_BE /* local arch is big endian */
|
||||
# define LE_TO_LOCAL_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff))
|
||||
# define LE_TO_LOCAL_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff))
|
||||
# define LOCAL_TO_LE_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff))
|
||||
# define LOCAL_TO_LE_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff))
|
||||
#else /* local arch is little endian */
|
||||
# define LE_TO_LOCAL_16(x) (x)
|
||||
# define LE_TO_LOCAL_32(x) (x)
|
||||
# define LOCAL_TO_LE_16(x) (x)
|
||||
# define LOCAL_TO_LE_32(x) (x)
|
||||
#endif
|
||||
|
||||
/* kilobytes and megabytes macro */
|
||||
#define MB(x) ((x)*1024*1024)
|
||||
#define KB(x) ((x)*1024)
|
||||
|
||||
#define CPU_STR(c) ((c==ARM9)?"ARM9":"ARM7")
|
||||
typedef enum
|
||||
{
|
||||
ARM9 = 0,
|
||||
ARM7 = 1
|
||||
} cpu_id_t;
|
||||
|
||||
#define __PACKED __attribute__((__packed__))
|
||||
|
||||
#endif
|
|
@ -0,0 +1,173 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "CWindow.h"
|
||||
#include "resource.h"
|
||||
|
||||
CRITICAL_SECTION section;
|
||||
cwindow_struct *updatewindowlist = NULL;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CWindow_Init(void *win, HINSTANCE hInst, const char * cname, const char * title, int style, int sx, int sy, WNDPROC wP)
|
||||
{
|
||||
static BOOL first = FALSE;
|
||||
RECT clientaera;
|
||||
cwindow_struct *win2=(cwindow_struct *)win;
|
||||
|
||||
win2->autoup = FALSE;
|
||||
|
||||
if(!first)
|
||||
{
|
||||
WNDCLASSEX wincl; // Data structure for the windowclass
|
||||
|
||||
// The Window structure
|
||||
wincl.hInstance = hInst;
|
||||
wincl.lpszClassName = cname;
|
||||
wincl.lpfnWndProc = wP; // This function is called by windows
|
||||
wincl.style = CS_DBLCLKS; // Catch double-clicks
|
||||
wincl.cbSize = sizeof (WNDCLASSEX);
|
||||
|
||||
// Use default icon and mouse-pointer
|
||||
wincl.hIcon = LoadIcon (hInst, MAKEINTRESOURCE(IconDeSmuME));//IDI_APPLICATION);
|
||||
wincl.hIconSm = LoadIcon (hInst, MAKEINTRESOURCE(IconDeSmuME));//IDI_APPLICATION);
|
||||
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||
wincl.lpszMenuName = NULL; // No menu
|
||||
wincl.cbClsExtra = 0; // No extra bytes after the window class
|
||||
wincl.cbWndExtra = 0; // structure or the window instance
|
||||
// Use Windows's default color as the background of the window
|
||||
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
|
||||
|
||||
// Register the window class, and if it fails quit the program
|
||||
if (!RegisterClassEx (&wincl))
|
||||
return -1;
|
||||
win2->first=NULL;
|
||||
first = TRUE;
|
||||
}
|
||||
|
||||
clientaera.left = 0;
|
||||
clientaera.top = 0;
|
||||
clientaera.right = sx;
|
||||
clientaera.bottom = sy;
|
||||
|
||||
AdjustWindowRectEx(&clientaera, style, TRUE, 0);
|
||||
|
||||
// The class is registered, let's create the program
|
||||
win2->hwnd = CreateWindowEx (
|
||||
0, // Extended possibilites for variation
|
||||
cname, // Classname
|
||||
title, // Title Text
|
||||
style, // default window
|
||||
CW_USEDEFAULT, // Windows decides the position
|
||||
CW_USEDEFAULT, // where the window ends up on the screen
|
||||
clientaera.right - clientaera.left, // The programs width
|
||||
clientaera.bottom - clientaera.top, // and height in pixels
|
||||
HWND_DESKTOP, // The window is a child-window to desktop
|
||||
NULL, // No menu
|
||||
hInst, // Program Instance handler
|
||||
NULL // No Window Creation data
|
||||
);
|
||||
|
||||
win2->prev = NULL;
|
||||
win2->next = NULL;
|
||||
win2->Refresh = &CWindow_Refresh;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CWindow_Init2(void *win, HINSTANCE hInst, HWND parent, char * title, int ID, DLGPROC wP)
|
||||
{
|
||||
cwindow_struct *win2=(cwindow_struct *)win;
|
||||
|
||||
win2->autoup = FALSE;
|
||||
win2->hwnd = CreateDialog(hInst, MAKEINTRESOURCE(ID), parent, wP);
|
||||
SetWindowLong(win2->hwnd, DWL_USER, (LONG)win2);
|
||||
SetWindowText(win2->hwnd, title);
|
||||
win2->prev = NULL;
|
||||
win2->next = NULL;
|
||||
win2->Refresh = &CWindow_Refresh;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CWindow_Show(void *win)
|
||||
{
|
||||
ShowWindow (((cwindow_struct *)win)->hwnd, SW_SHOW);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CWindow_Hide(void *win)
|
||||
{
|
||||
ShowWindow (((cwindow_struct *)win)->hwnd, SW_HIDE);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CWindow_Refresh(void *win)
|
||||
{
|
||||
InvalidateRect(((cwindow_struct *)win)->hwnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CWindow_AddToRefreshList(void *win)
|
||||
{
|
||||
cwindow_struct *win2=(cwindow_struct *)win;
|
||||
|
||||
EnterCriticalSection(§ion);
|
||||
win2->prev = NULL;
|
||||
win2->next = updatewindowlist;
|
||||
if(updatewindowlist)
|
||||
updatewindowlist->prev = win;
|
||||
updatewindowlist = (cwindow_struct *)win;
|
||||
LeaveCriticalSection(§ion);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CWindow_RemoveFromRefreshList(void *win)
|
||||
{
|
||||
cwindow_struct *win2=(cwindow_struct *)win;
|
||||
|
||||
EnterCriticalSection(§ion);
|
||||
if(updatewindowlist == win)
|
||||
{
|
||||
updatewindowlist = (cwindow_struct *)win2->next;
|
||||
if(updatewindowlist) updatewindowlist->prev = NULL;
|
||||
}
|
||||
else
|
||||
if(win2->prev)
|
||||
{
|
||||
((cwindow_struct *)win2->prev)->next = win2->next;
|
||||
if(win2->next) ((cwindow_struct *)win2->next)->prev = win2->prev;
|
||||
}
|
||||
win2->next = NULL;
|
||||
win2->prev = NULL;
|
||||
LeaveCriticalSection(§ion);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef CWINDOW_H
|
||||
#define CWINDOW_H
|
||||
|
||||
#include <windows.h>
|
||||
#include "../types.h"
|
||||
|
||||
extern CRITICAL_SECTION section;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HWND hwnd;
|
||||
BOOL autoup;
|
||||
void *prev;
|
||||
void *next;
|
||||
void *first;
|
||||
void (*Refresh)(void *win);
|
||||
} cwindow_struct;
|
||||
|
||||
int CWindow_Init(void *win, HINSTANCE hInst, const char * cname, const char * title, int style, int sx, int sy, WNDPROC wP);
|
||||
int CWindow_Init2(void *win, HINSTANCE hInst, HWND parent, char * title, int ID, DLGPROC wP);
|
||||
void CWindow_Show(void *win);
|
||||
void CWindow_Hide(void *win);
|
||||
void CWindow_Refresh(void *win);
|
||||
void CWindow_AddToRefreshList(void *win);
|
||||
void CWindow_RemoveFromRefreshList(void *win);
|
||||
|
||||
extern cwindow_struct *updatewindowlist;
|
||||
|
||||
static INLINE void CWindow_RefreshALL()
|
||||
{
|
||||
cwindow_struct *aux;
|
||||
EnterCriticalSection(§ion);
|
||||
aux = updatewindowlist;
|
||||
while(aux)
|
||||
{
|
||||
aux->Refresh(aux);
|
||||
aux = (cwindow_struct *)aux->next;
|
||||
}
|
||||
LeaveCriticalSection(§ion);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,266 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <COMMDLG.H>
|
||||
#include <string.h>
|
||||
|
||||
#include "CWindow.h"
|
||||
|
||||
#include "../debug.h"
|
||||
#include "resource.h"
|
||||
|
||||
char IniName[MAX_PATH];
|
||||
char vPath[MAX_PATH],*szPath,currDir[MAX_PATH];
|
||||
u32 keytab[12];
|
||||
|
||||
const char tabkeytext[48][8] = {"0","1","2","3","4","5","6","7","8","9","A","B","C",
|
||||
"D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X",
|
||||
"Y","Z","SPACE","UP","DOWN","LEFT","RIGHT","TAB","SHIFT","DEL","INSERT","HOME","END","ENTER"};
|
||||
|
||||
DWORD dds_up=37;
|
||||
DWORD dds_down=38;
|
||||
DWORD dds_left=39;
|
||||
DWORD dds_right=40;
|
||||
|
||||
DWORD dds_a=31;
|
||||
DWORD dds_b=11;
|
||||
DWORD dds_x=16;
|
||||
DWORD dds_y=17;
|
||||
|
||||
DWORD dds_l=12;
|
||||
DWORD dds_r=23;
|
||||
|
||||
DWORD dds_select=36;
|
||||
DWORD dds_start=47;
|
||||
|
||||
DWORD dds_debug=13;
|
||||
|
||||
extern DWORD ds_up;
|
||||
extern DWORD ds_down;
|
||||
extern DWORD ds_left;
|
||||
extern DWORD ds_right;
|
||||
extern DWORD ds_a;
|
||||
extern DWORD ds_b;
|
||||
extern DWORD ds_x;
|
||||
extern DWORD ds_y;
|
||||
extern DWORD ds_l;
|
||||
extern DWORD ds_r;
|
||||
extern DWORD ds_select;
|
||||
extern DWORD ds_start;
|
||||
|
||||
#define KEY_UP ds_up
|
||||
#define KEY_DOWN ds_down
|
||||
#define KEY_LEFT ds_left
|
||||
#define KEY_RIGHT ds_right
|
||||
#define KEY_X ds_x
|
||||
#define KEY_Y ds_y
|
||||
#define KEY_A ds_a
|
||||
#define KEY_B ds_b
|
||||
#define KEY_L ds_l
|
||||
#define KEY_R ds_r
|
||||
#define KEY_START ds_start
|
||||
#define KEY_SELECT ds_select
|
||||
#define KEY_DEBUG ds_debug
|
||||
|
||||
void GetINIPath(char *inipath)
|
||||
{
|
||||
if (*vPath)
|
||||
szPath = vPath;
|
||||
else
|
||||
{
|
||||
char *p;
|
||||
ZeroMemory(vPath, sizeof(vPath));
|
||||
GetModuleFileName(NULL, vPath, sizeof(vPath));
|
||||
p = vPath + lstrlen(vPath);
|
||||
while (p >= vPath && *p != '\\') p--;
|
||||
if (++p >= vPath) *p = 0;
|
||||
szPath = vPath;
|
||||
}
|
||||
|
||||
sprintf(inipath, "%s\\desmume.ini",szPath);
|
||||
}
|
||||
|
||||
void ReadConfig(void)
|
||||
{
|
||||
FILE *fp;
|
||||
int i;
|
||||
|
||||
GetINIPath(IniName);
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_A",31, IniName);
|
||||
KEY_A = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_B",11, IniName);
|
||||
KEY_B = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_SELECT",36, IniName);
|
||||
KEY_SELECT = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_START",13, IniName);
|
||||
if(i==13)
|
||||
KEY_START = 47;
|
||||
else
|
||||
KEY_START = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_RIGHT",40, IniName);
|
||||
KEY_RIGHT = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_LEFT",39, IniName);
|
||||
KEY_LEFT = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_UP",37, IniName);
|
||||
KEY_UP = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_DOWN",38, IniName);
|
||||
KEY_DOWN = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_R",23, IniName);
|
||||
KEY_R = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_L",12, IniName);
|
||||
KEY_L = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_X",16, IniName);
|
||||
KEY_X = i;
|
||||
|
||||
i=GetPrivateProfileInt("KEYS","KEY_Y",17, IniName);
|
||||
KEY_Y = i;
|
||||
|
||||
/*i=GetPrivateProfileInt("KEYS","KEY_DEBUG",13, IniName);
|
||||
KEY_DEBUG = i;*/
|
||||
}
|
||||
|
||||
void WritePrivateProfileInt(char* appname, char* keyname, int val, char* file)
|
||||
{
|
||||
char temp[256] = "";
|
||||
sprintf(temp, "%d", val);
|
||||
WritePrivateProfileString(appname, keyname, temp, file);
|
||||
}
|
||||
|
||||
void WriteConfig(void)
|
||||
{
|
||||
FILE *fp;
|
||||
int i;
|
||||
|
||||
GetINIPath(IniName);
|
||||
|
||||
WritePrivateProfileInt("KEYS","KEY_A",KEY_A,IniName);
|
||||
WritePrivateProfileInt("KEYS","KEY_B",KEY_B,IniName);
|
||||
WritePrivateProfileInt("KEYS","KEY_SELECT",KEY_SELECT,IniName);
|
||||
|
||||
if(KEY_START==47)
|
||||
WritePrivateProfileInt("KEYS","KEY_START",13,IniName);
|
||||
else
|
||||
WritePrivateProfileInt("KEYS","KEY_START",KEY_START,IniName);
|
||||
|
||||
WritePrivateProfileInt("KEYS","KEY_RIGHT",KEY_RIGHT,IniName);
|
||||
WritePrivateProfileInt("KEYS","KEY_LEFT",KEY_LEFT,IniName);
|
||||
WritePrivateProfileInt("KEYS","KEY_UP",KEY_UP,IniName);
|
||||
WritePrivateProfileInt("KEYS","KEY_DOWN",KEY_DOWN,IniName);
|
||||
WritePrivateProfileInt("KEYS","KEY_R",KEY_R,IniName);
|
||||
WritePrivateProfileInt("KEYS","KEY_L",KEY_L,IniName);
|
||||
WritePrivateProfileInt("KEYS","KEY_X",KEY_X,IniName);
|
||||
WritePrivateProfileInt("KEYS","KEY_Y",KEY_Y,IniName);
|
||||
/*WritePrivateProfileInt("KEYS","KEY_DEBUG",KEY_DEBUG,IniName);*/
|
||||
}
|
||||
|
||||
void dsDefaultKeys(void)
|
||||
{
|
||||
KEY_A=dds_a;
|
||||
KEY_B=dds_b;
|
||||
KEY_SELECT=dds_select;
|
||||
KEY_START=dds_start;
|
||||
KEY_RIGHT=dds_right;
|
||||
KEY_LEFT=dds_left;
|
||||
KEY_UP=dds_up;
|
||||
KEY_DOWN=dds_down;
|
||||
KEY_R=dds_r;
|
||||
KEY_L=dds_l;
|
||||
KEY_X=dds_x;
|
||||
KEY_Y=dds_y;
|
||||
//KEY_DEBUG=dds_debug;
|
||||
}
|
||||
|
||||
DWORD key_combos[12]={
|
||||
IDC_COMBO1,
|
||||
IDC_COMBO2,
|
||||
IDC_COMBO3,
|
||||
IDC_COMBO4,
|
||||
IDC_COMBO5,
|
||||
IDC_COMBO6,
|
||||
IDC_COMBO7,
|
||||
IDC_COMBO8,
|
||||
IDC_COMBO9,
|
||||
IDC_COMBO10,
|
||||
IDC_COMBO11,
|
||||
IDC_COMBO12};
|
||||
|
||||
BOOL CALLBACK ConfigView_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam)
|
||||
{
|
||||
int i,j;
|
||||
char tempstring[256];
|
||||
switch(komunikat)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
ReadConfig();
|
||||
for(i=0;i<48;i++)for(j=0;j<12;j++)SendDlgItemMessage(dialog,key_combos[j],CB_ADDSTRING,0,(LPARAM)&tabkeytext[i]);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO1,CB_SETCURSEL,KEY_UP,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO2,CB_SETCURSEL,KEY_LEFT,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO3,CB_SETCURSEL,KEY_RIGHT,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO4,CB_SETCURSEL,KEY_DOWN,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO5,CB_SETCURSEL,KEY_Y,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO6,CB_SETCURSEL,KEY_X,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO7,CB_SETCURSEL,KEY_A,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO8,CB_SETCURSEL,KEY_B,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO9,CB_SETCURSEL,KEY_START,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO10,CB_SETCURSEL,KEY_L,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO11,CB_SETCURSEL,KEY_R,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO12,CB_SETCURSEL,KEY_SELECT,0);
|
||||
//SendDlgItemMessage(dialog,IDC_COMBO13,CB_SETCURSEL,KEY_DEBUG,0);
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
if((HIWORD(wparam)==BN_CLICKED)&&(((int)LOWORD(wparam))==IDC_BUTTON1))
|
||||
{
|
||||
dsDefaultKeys();
|
||||
SendDlgItemMessage(dialog,IDC_COMBO1,CB_SETCURSEL,KEY_UP,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO2,CB_SETCURSEL,KEY_LEFT,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO3,CB_SETCURSEL,KEY_RIGHT,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO4,CB_SETCURSEL,KEY_DOWN,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO5,CB_SETCURSEL,KEY_Y,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO6,CB_SETCURSEL,KEY_X,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO7,CB_SETCURSEL,KEY_A,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO8,CB_SETCURSEL,KEY_B,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO9,CB_SETCURSEL,KEY_START,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO10,CB_SETCURSEL,KEY_L,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO11,CB_SETCURSEL,KEY_R,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO12,CB_SETCURSEL,KEY_SELECT,0);
|
||||
//SendDlgItemMessage(dialog,IDC_COMBO13,CB_SETCURSEL,KEY_DEBUG,0);
|
||||
}
|
||||
else
|
||||
if((HIWORD(wparam)==BN_CLICKED)&&(((int)LOWORD(wparam))==IDC_FERMER))
|
||||
{
|
||||
KEY_UP=SendDlgItemMessage(dialog,IDC_COMBO1,CB_GETCURSEL,0,0);
|
||||
KEY_LEFT=SendDlgItemMessage(dialog,IDC_COMBO2,CB_GETCURSEL,0,0);
|
||||
KEY_RIGHT=SendDlgItemMessage(dialog,IDC_COMBO3,CB_GETCURSEL,0,0);
|
||||
KEY_DOWN=SendDlgItemMessage(dialog,IDC_COMBO4,CB_GETCURSEL,0,0);
|
||||
KEY_Y=SendDlgItemMessage(dialog,IDC_COMBO5,CB_GETCURSEL,0,0);
|
||||
KEY_X=SendDlgItemMessage(dialog,IDC_COMBO6,CB_GETCURSEL,0,0);
|
||||
KEY_A=SendDlgItemMessage(dialog,IDC_COMBO7,CB_GETCURSEL,0,0);
|
||||
KEY_B=SendDlgItemMessage(dialog,IDC_COMBO8,CB_GETCURSEL,0,0);
|
||||
KEY_START=SendDlgItemMessage(dialog,IDC_COMBO9,CB_GETCURSEL,0,0);
|
||||
KEY_L=SendDlgItemMessage(dialog,IDC_COMBO10,CB_GETCURSEL,0,0);
|
||||
KEY_R=SendDlgItemMessage(dialog,IDC_COMBO11,CB_GETCURSEL,0,0);
|
||||
KEY_SELECT=SendDlgItemMessage(dialog,IDC_COMBO12,CB_GETCURSEL,0,0);
|
||||
//KEY_DEBUG=SendDlgItemMessage(dialog,IDC_COMBO13,CB_GETCURSEL,0,0);
|
||||
WriteConfig();
|
||||
EndDialog(dialog,0);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
#ifndef CONFIGKEYS_H
|
||||
#define CONFIGKEYS_H
|
||||
|
||||
extern unsigned long keytab[12];
|
||||
extern const DWORD tabkey[48];
|
||||
extern DWORD ds_up;
|
||||
extern DWORD ds_down;
|
||||
extern DWORD ds_left;
|
||||
extern DWORD ds_right;
|
||||
extern DWORD ds_a;
|
||||
extern DWORD ds_b;
|
||||
extern DWORD ds_x;
|
||||
extern DWORD ds_y;
|
||||
extern DWORD ds_l;
|
||||
extern DWORD ds_r;
|
||||
extern DWORD ds_select;
|
||||
extern DWORD ds_start;
|
||||
extern DWORD ds_debug;
|
||||
|
||||
void GetINIPath(char *initpath);
|
||||
void ReadConfig(void);
|
||||
|
||||
BOOL CALLBACK ConfigView_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,708 @@
|
|||
[Project]
|
||||
FileName=DeSmuME.dev
|
||||
Name=DeSmuME
|
||||
UnitCount=65
|
||||
Type=0
|
||||
Ver=1
|
||||
ObjFiles=
|
||||
Includes=
|
||||
Libs=
|
||||
PrivateResource=yopyop_private.rc
|
||||
ResourceIncludes=
|
||||
MakeIncludes=
|
||||
Compiler=-DVERSION=\"0.3.3\"_@@_
|
||||
CppCompiler=_@@_
|
||||
Linker=-lz -ldxguid -ldxerr8 -ldsound_@@_
|
||||
IsCpp=1
|
||||
Icon=DeSmuME.ico
|
||||
ExeOutput=
|
||||
ObjectOutput=obj
|
||||
OverrideOutput=0
|
||||
OverrideOutputName=DeSmuME.exe
|
||||
HostApplication=
|
||||
Folders=EmuSRC,EmuSRC/Desassembleur,EmuSRC/MMU,EmuSRC/NDSSys,Resources
|
||||
CommandLine=
|
||||
UseCustomMakefile=0
|
||||
CustomMakefile=
|
||||
IncludeVersionInfo=1
|
||||
SupportXPThemes=1
|
||||
CompilerSet=0
|
||||
CompilerSettings=0000000001001000000100
|
||||
|
||||
[Unit1]
|
||||
FileName=resources.rc
|
||||
CompileCpp=1
|
||||
Folder=Resources
|
||||
Compile=1
|
||||
Link=0
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[VersionInfo]
|
||||
Major=0
|
||||
Minor=0
|
||||
Release=3
|
||||
Build=4
|
||||
LanguageID=5129
|
||||
CharsetID=1252
|
||||
CompanyName=yopyop
|
||||
FileVersion=
|
||||
FileDescription=NDS(tm) emulator
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=DeSmuME
|
||||
ProductVersion=
|
||||
AutoIncBuildNr=0
|
||||
|
||||
[Unit3]
|
||||
FileName=..\types.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit4]
|
||||
FileName=..\arm_instructions.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit8]
|
||||
FileName=..\debug.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c debug.c -o obj/debug.o $(CFLAGS)
|
||||
|
||||
[Unit10]
|
||||
FileName=..\thumb_instructions.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit14]
|
||||
FileName=..\Disassembler.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit15]
|
||||
FileName=..\FIFO.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit16]
|
||||
FileName=..\fs-windows.c
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c fs-windows.c -o obj/fs-windows.o $(CFLAGS)
|
||||
CompileCpp=0
|
||||
|
||||
[Unit17]
|
||||
FileName=..\fs.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit18]
|
||||
FileName=..\GPU.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c GPU.c -o obj/GPU.o $(CFLAGS)
|
||||
|
||||
[Unit19]
|
||||
FileName=..\GPU.h
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
CompileCpp=1
|
||||
|
||||
[Unit20]
|
||||
FileName=..\ARM9.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c ARM9.c -o obj/ARM9.o $(CFLAGS)
|
||||
|
||||
[Unit21]
|
||||
FileName=..\ARM9.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit22]
|
||||
FileName=ConfigKeys.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c ConfigKeys.c -o obj/ConfigKeys.o $(CFLAGS)
|
||||
|
||||
[Unit23]
|
||||
FileName=CWindow.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c CWindow.c -o obj/CWindow.o $(CFLAGS)
|
||||
|
||||
[Unit24]
|
||||
FileName=disView.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c disView.c -o obj/disView.o $(CFLAGS)
|
||||
|
||||
[Unit25]
|
||||
FileName=ginfo.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c ginfo.c -o obj/ginfo.o $(CFLAGS)
|
||||
|
||||
[Unit26]
|
||||
FileName=IORegView.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c IORegView.c -o obj/IORegView.o $(CFLAGS)
|
||||
|
||||
[Unit27]
|
||||
FileName=main.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c main.c -o obj/main.o $(CFLAGS)
|
||||
|
||||
[Unit28]
|
||||
FileName=mapView.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c mapView.c -o obj/mapView.o $(CFLAGS)
|
||||
|
||||
[Unit29]
|
||||
FileName=memView.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c memView.c -o obj/memView.o $(CFLAGS)
|
||||
|
||||
[Unit32]
|
||||
FileName=tileView.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c tileView.c -o obj/tileView.o $(CFLAGS)
|
||||
|
||||
[Unit33]
|
||||
FileName=ConfigKeys.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit34]
|
||||
FileName=CWindow.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit37]
|
||||
FileName=IORegView.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit41]
|
||||
FileName=palView.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit42]
|
||||
FileName=..\bios.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit43]
|
||||
FileName=..\bits.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit46]
|
||||
FileName=..\fat.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit35]
|
||||
FileName=disView.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit40]
|
||||
FileName=oamView.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit44]
|
||||
FileName=..\cflash.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit45]
|
||||
FileName=..\dscard.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit47]
|
||||
FileName=..\mc.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit48]
|
||||
FileName=..\mem.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit49]
|
||||
FileName=..\MMU.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit50]
|
||||
FileName=..\NDSSystem.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit31]
|
||||
FileName=palView.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c palView.c -o obj/palView.o $(CFLAGS)
|
||||
|
||||
[Unit36]
|
||||
FileName=ginfo.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit38]
|
||||
FileName=mapView.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit39]
|
||||
FileName=memView.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit53]
|
||||
FileName=..\arm_instructions.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c arm_instructions.c -o obj/arm_instructions.o $(CFLAGS)
|
||||
|
||||
[Unit54]
|
||||
FileName=..\armcpu.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c armcpu.c -o obj/armcpu.o $(CFLAGS)
|
||||
|
||||
[Unit55]
|
||||
FileName=..\bios.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c bios.c -o obj/bios.o $(CFLAGS)
|
||||
|
||||
[Unit56]
|
||||
FileName=..\cflash.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c cflash.c -o obj/cflash.o $(CFLAGS)
|
||||
|
||||
[Unit57]
|
||||
FileName=..\cp15.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c cp15.c -o obj/cp15.o $(CFLAGS)
|
||||
|
||||
[Unit58]
|
||||
FileName=..\mc.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c mc.c -o obj/mc.o $(CFLAGS)
|
||||
|
||||
[Unit60]
|
||||
FileName=..\NDSSystem.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c NDSSystem.c -o obj/NDSSystem.o $(CFLAGS)
|
||||
|
||||
[Unit61]
|
||||
FileName=..\saves.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c saves.c -o obj/saves.o $(CFLAGS)
|
||||
|
||||
[Unit62]
|
||||
FileName=..\SPU.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c SPU.c -o obj/SPU.o $(CFLAGS)
|
||||
|
||||
[Unit5]
|
||||
FileName=..\armcpu.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit6]
|
||||
FileName=..\config.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit7]
|
||||
FileName=..\cp15.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit11]
|
||||
FileName=resource.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit12]
|
||||
FileName=..\Disassembler.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c Disassembler.c -o obj/Disassembler.o $(CFLAGS)
|
||||
|
||||
[Unit13]
|
||||
FileName=..\FIFO.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c FIFO.c -o obj/FIFO.o $(CFLAGS)
|
||||
|
||||
[Unit30]
|
||||
FileName=oamView.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c oamView.c -o obj/oamView.o $(CFLAGS)
|
||||
|
||||
[Unit9]
|
||||
FileName=..\debug.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit2]
|
||||
FileName=yopyop_private.rc
|
||||
Folder=Resources
|
||||
Compile=1
|
||||
Link=0
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit51]
|
||||
FileName=..\saves.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit64]
|
||||
FileName=snddx.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c snddx.c -o obj/snddx.o $(CFLAGS)
|
||||
|
||||
[Unit65]
|
||||
FileName=snddx.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit66]
|
||||
FileName=..\thumb_instructions.c
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit59]
|
||||
FileName=..\MMU.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c MMU.c -o obj/MMU.o $(CFLAGS)
|
||||
|
||||
[Unit52]
|
||||
FileName=..\SPU.h
|
||||
CompileCpp=1
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=
|
||||
|
||||
[Unit63]
|
||||
FileName=..\thumb_instructions.c
|
||||
CompileCpp=0
|
||||
Folder=DeSmuME
|
||||
Compile=1
|
||||
Link=1
|
||||
Priority=1000
|
||||
OverrideBuildCmd=0
|
||||
BuildCmd=$(CC) -c thumb_instructions.c -o obj/thumb_instructions.o $(CFLAGS)
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
|
@ -0,0 +1,339 @@
|
|||
[Editor_9]
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
Open=0
|
||||
Top=0
|
||||
[Editors]
|
||||
Focused=0
|
||||
Order=0,20,1,47
|
||||
[Editor_0]
|
||||
Open=1
|
||||
Top=1
|
||||
CursorCol=21
|
||||
CursorRow=30
|
||||
TopLine=25
|
||||
LeftChar=1
|
||||
[Editor_1]
|
||||
Open=1
|
||||
Top=0
|
||||
CursorCol=55
|
||||
CursorRow=40
|
||||
TopLine=28
|
||||
LeftChar=1
|
||||
[Editor_2]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_3]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_4]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_5]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_6]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_7]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_8]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_10]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_11]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_12]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_13]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_14]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_15]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_16]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_17]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_18]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_19]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_20]
|
||||
Open=1
|
||||
Top=0
|
||||
CursorCol=37
|
||||
CursorRow=151
|
||||
TopLine=16
|
||||
LeftChar=1
|
||||
[Editor_21]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=35
|
||||
CursorRow=17
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_22]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=2
|
||||
LeftChar=1
|
||||
[Editor_23]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_24]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_25]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_26]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_27]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_28]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_29]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_30]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_31]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=14
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_32]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_33]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_34]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_35]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_36]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_37]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_38]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_39]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_40]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_41]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_42]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_43]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_44]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_45]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_46]
|
||||
Open=0
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=4
|
||||
TopLine=1
|
||||
LeftChar=1
|
||||
[Editor_47]
|
||||
Open=1
|
||||
Top=0
|
||||
CursorCol=1
|
||||
CursorRow=151
|
||||
TopLine=128
|
||||
LeftChar=1
|
|
@ -0,0 +1,97 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "CWindow.h"
|
||||
#include "resource.h"
|
||||
#include "../MMU.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT Ioreg_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
TCHAR text[80];
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
sprintf(text, "%08X", (int)((u32 *)ARM9Mem.ARM9_DTCM)[0x3FFC>>2]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_INTHAND), text);
|
||||
|
||||
sprintf(text, "%08X", (int)MMU.reg_IF[0]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_IE), text);
|
||||
|
||||
sprintf(text, "%08X", (int)MMU.reg_IME[0]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_IME), text);
|
||||
|
||||
sprintf(text, "%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x0004>>1]);//((u32 *)ARM9.ARM9_REG)[0x10>>2]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_DISPCNT), text);
|
||||
|
||||
sprintf(text, "%08X", ((u16 *)MMU.ARM7_REG)[0x0004>>1]);//MMU.DMACycle[0][1]);//((u16 *)ARM9.ARM9_REG)[0x16>>1]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_DISPSTAT), text);
|
||||
|
||||
sprintf(text, "%08X", (int)((u32 *)ARM9Mem.ARM9_REG)[0x180>>2]);//MMU.DMACycle[0][2]);//((u32 *)ARM9.ARM9_REG)[0x001C>>2]);//MMU.fifos[0].data[MMU.fifos[0].begin]);//((u32 *)MMU.ARM7_REG)[0x210>>2]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_IPCSYNC), text);
|
||||
|
||||
sprintf(text, "%08X", (int)((u32 *)MMU.ARM7_REG)[0x180>>2]);//MMU.DMACycle[0][3]);//nds.ARM9.SPSR.bits.I);//((u32 *)MMU.ARM7_REG)[0x184>>2]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_IPCFIFO), text);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
cwindow_struct *win = (cwindow_struct *)GetWindowLong(hwnd, DWL_USER);
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
return 1;
|
||||
case WM_CLOSE :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
if (win)
|
||||
free(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case WM_PAINT:
|
||||
Ioreg_OnPaint(hwnd, wParam, lParam);
|
||||
return 1;
|
||||
case WM_COMMAND :
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDC_FERMER :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
if (win)
|
||||
free(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,27 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef IO_REG_H
|
||||
#define IO_REG_H
|
||||
|
||||
BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,14 @@
|
|||
bin_PROGRAMS = desmume
|
||||
desmume_SOURCES = \
|
||||
CWindow.c CWindow.h \
|
||||
disView.c disView.h ginfo.c ginfo.h \
|
||||
IORegView.c IORegView.h \
|
||||
main.cpp mapView.c mapView.h memView.c memView.h \
|
||||
oamView.c oamView.h palView.c palView.h \
|
||||
resource.h \
|
||||
snddx.c snddx.h \
|
||||
tileView.c tileView.h yopyop_private.h \
|
||||
ConfigKeys.c ConfigKeys.h
|
||||
desmume_LDADD = ../libdesmume.a yopyop_private.o
|
||||
yopyop_private.o: yopyop_private.rc resources.rc resource.h
|
||||
windres yopyop_private.rc -o yopyop_private.o
|
|
@ -0,0 +1,93 @@
|
|||
# Project: DeSmuME
|
||||
# Makefile created by Dev-C++ 4.9.9.2
|
||||
|
||||
CPP = g++.exe
|
||||
CC = gcc.exe
|
||||
WINDRES = windres.exe
|
||||
RES = obj/yopyop_private.res
|
||||
OBJ = obj/main.o obj/mem_view.o obj/des_view.o obj/ginfo.o obj/IORegView.o obj/palView.o obj/CWindow.o obj/tileView.o obj/mapView.o obj/oamView.o obj/arm_instructions.o obj/armcpu.o obj/bios.o obj/cp15.o obj/debug.o obj/Disassembler.o obj/FIFO.o obj/GPU.o obj/MMU.o obj/NDSSystem.o obj/thumb_instructions.o $(RES)
|
||||
LINKOBJ = obj/main.o obj/mem_view.o obj/des_view.o obj/ginfo.o obj/IORegView.o obj/palView.o obj/CWindow.o obj/tileView.o obj/mapView.o obj/oamView.o obj/arm_instructions.o obj/armcpu.o obj/bios.o obj/cp15.o obj/debug.o obj/Disassembler.o obj/FIFO.o obj/GPU.o obj/MMU.o obj/NDSSystem.o obj/thumb_instructions.o $(RES)
|
||||
LIBS = -L"lib" -mwindows -s -march=pentium4 -msse2
|
||||
INCS = -I"include"
|
||||
CXXINCS = -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
|
||||
BIN = DeSmuME.exe
|
||||
CXXFLAGS = $(CXXINCS) -fexpensive-optimizations -O3 -march=pentium4 -msse2
|
||||
CFLAGS = $(INCS) -fexpensive-optimizations -O3 -march=pentium4 -msse2
|
||||
RM = rm -f
|
||||
|
||||
.PHONY: all all-before all-after clean clean-custom
|
||||
|
||||
all: all-before DeSmuME.exe all-after
|
||||
|
||||
|
||||
clean: clean-custom
|
||||
${RM} $(OBJ) $(BIN)
|
||||
|
||||
$(BIN): $(OBJ)
|
||||
$(CPP) $(LINKOBJ) -o "DeSmuME.exe" $(LIBS)
|
||||
|
||||
obj/main.o: main.cpp
|
||||
$(CPP) -c main.cpp -o obj/main.o $(CXXFLAGS)
|
||||
|
||||
obj/mem_view.o: mem_view.cpp
|
||||
$(CPP) -c mem_view.cpp -o obj/mem_view.o $(CXXFLAGS)
|
||||
|
||||
obj/des_view.o: des_view.cpp
|
||||
$(CPP) -c des_view.cpp -o obj/des_view.o $(CXXFLAGS)
|
||||
|
||||
obj/ginfo.o: ginfo.cpp
|
||||
$(CPP) -c ginfo.cpp -o obj/ginfo.o $(CXXFLAGS)
|
||||
|
||||
obj/IORegView.o: IORegView.cpp
|
||||
$(CPP) -c IORegView.cpp -o obj/IORegView.o $(CXXFLAGS)
|
||||
|
||||
obj/palView.o: palView.cpp
|
||||
$(CPP) -c palView.cpp -o obj/palView.o $(CXXFLAGS)
|
||||
|
||||
obj/CWindow.o: CWindow.cpp
|
||||
$(CPP) -c CWindow.cpp -o obj/CWindow.o $(CXXFLAGS)
|
||||
|
||||
obj/tileView.o: tileView.cpp
|
||||
$(CPP) -c tileView.cpp -o obj/tileView.o $(CXXFLAGS)
|
||||
|
||||
obj/mapView.o: mapView.cpp
|
||||
$(CPP) -c mapView.cpp -o obj/mapView.o $(CXXFLAGS)
|
||||
|
||||
obj/oamView.o: oamView.cpp
|
||||
$(CPP) -c oamView.cpp -o obj/oamView.o $(CXXFLAGS)
|
||||
|
||||
obj/arm_instructions.o: ../arm_instructions.cpp
|
||||
$(CPP) -c ../arm_instructions.cpp -o obj/arm_instructions.o $(CXXFLAGS)
|
||||
|
||||
obj/armcpu.o: ../armcpu.cpp
|
||||
$(CPP) -c ../armcpu.cpp -o obj/armcpu.o $(CXXFLAGS)
|
||||
|
||||
obj/bios.o: ../bios.cpp
|
||||
$(CPP) -c ../bios.cpp -o obj/bios.o $(CXXFLAGS)
|
||||
|
||||
obj/cp15.o: ../cp15.cpp
|
||||
$(CPP) -c ../cp15.cpp -o obj/cp15.o $(CXXFLAGS)
|
||||
|
||||
obj/debug.o: ../debug.c
|
||||
$(CPP) -c ../debug.c -o obj/debug.o $(CXXFLAGS)
|
||||
|
||||
obj/Disassembler.o: ../Disassembler.cpp
|
||||
$(CPP) -c ../Disassembler.cpp -o obj/Disassembler.o $(CXXFLAGS)
|
||||
|
||||
obj/FIFO.o: ../FIFO.cpp
|
||||
$(CPP) -c ../FIFO.cpp -o obj/FIFO.o $(CXXFLAGS)
|
||||
|
||||
obj/GPU.o: ../GPU.cpp
|
||||
$(CPP) -c ../GPU.cpp -o obj/GPU.o $(CXXFLAGS)
|
||||
|
||||
obj/MMU.o: ../MMU.cpp
|
||||
$(CPP) -c ../MMU.cpp -o obj/MMU.o $(CXXFLAGS)
|
||||
|
||||
obj/NDSSystem.o: ../NDSSystem.cpp
|
||||
$(CPP) -c ../NDSSystem.cpp -o obj/NDSSystem.o $(CXXFLAGS)
|
||||
|
||||
obj/thumb_instructions.o: ../thumb_instructions.cpp
|
||||
$(CPP) -c ../thumb_instructions.cpp -o obj/thumb_instructions.o $(CXXFLAGS)
|
||||
|
||||
obj/yopyop_private.res: yopyop_private.rc resources.rc yopyop_private.rc
|
||||
$(WINDRES) -i yopyop_private.rc --input-format=rc -o obj/yopyop_private.res -O coff
|
|
@ -0,0 +1,798 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include "../MMU.h"
|
||||
#include "../Disassembler.h"
|
||||
#include "disView.h"
|
||||
#include "resource.h"
|
||||
|
||||
#define INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF))
|
||||
|
||||
extern HDC hdc;
|
||||
|
||||
LRESULT CALLBACK DisViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
u32 cycles = 1;
|
||||
|
||||
void InitDesViewBox()
|
||||
{
|
||||
WNDCLASSEX wc;
|
||||
|
||||
wc.cbSize = sizeof(wc);
|
||||
wc.lpszClassName = _T("DesViewBox");
|
||||
wc.hInstance = GetModuleHandle(0);
|
||||
wc.lpfnWndProc = DisViewBoxWndProc;
|
||||
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||
wc.hIcon = 0;
|
||||
wc.lpszMenuName = 0;
|
||||
wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE);
|
||||
wc.style = 0;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = sizeof(cwindow_struct *);
|
||||
wc.hIconSm = 0;
|
||||
|
||||
RegisterClassEx(&wc);
|
||||
}
|
||||
|
||||
/*
|
||||
LRESULT DesViewBox_OnPaint(CDesView * win, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hwnd = GetDlgItem(win->hwnd, IDC_DES_BOX);
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
SIZE fontsize;
|
||||
TCHAR text[100];
|
||||
TCHAR txt[100];
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(hwnd, &rect);
|
||||
int lg = rect.right - rect.left;
|
||||
int ht = rect.bottom - rect.top;
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
HDC mem_dc = CreateCompatibleDC(hdc);
|
||||
HBITMAP mem_bmp = CreateCompatibleBitmap(hdc, lg, ht);
|
||||
SelectObject(mem_dc, mem_bmp);
|
||||
|
||||
FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||
|
||||
SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT));
|
||||
|
||||
GetTextExtentPoint32(mem_dc, "0", 1, &fontsize);
|
||||
|
||||
u32 nbligne = ht/fontsize.cy;
|
||||
|
||||
SetTextColor(mem_dc, RGB(0,0,0));
|
||||
|
||||
if((win->mode==1) || ((win->mode==0) && (win->cpu->CPSR.bits.T == 0)))
|
||||
{
|
||||
u32 adr = win->curr_ligne*4;
|
||||
|
||||
for(u32 i = 0; i < nbligne; ++i)
|
||||
{
|
||||
u32 ins = MMU_readWord(win->cpu->proc_ID, adr);
|
||||
des_arm_instructions_set[INDEX(ins)](adr, ins, txt);
|
||||
sprintf(text, "%04X:%04X %08X %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt);
|
||||
DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
rect.top+=fontsize.cy;
|
||||
adr += 4;
|
||||
}
|
||||
|
||||
if(((win->cpu->instruct_adr&0x0FFFFFFF) >= win->curr_ligne<<2)&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+nbligne<<2)))
|
||||
{
|
||||
HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0));
|
||||
SetBkColor(mem_dc, RGB(255, 255, 0));
|
||||
rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>2) - win->curr_ligne)*fontsize.cy;
|
||||
rect.bottom = rect.top + fontsize.cy;
|
||||
FillRect(mem_dc, &rect, brjaune);
|
||||
des_arm_instructions_set[INDEX(win->cpu->instruction)](win->cpu->instruct_adr, win->cpu->instruction, txt);
|
||||
sprintf(text, "%04X:%04X %08X %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)win->cpu->instruction, txt);
|
||||
DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
DeleteObject(brjaune);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 adr = win->curr_ligne*2;
|
||||
|
||||
for(u32 i = 0; i < nbligne; ++i)
|
||||
{
|
||||
u32 ins = MMU_readHWord(win->cpu->proc_ID, adr);
|
||||
des_thumb_instructions_set[ins>>6](adr, ins, txt);
|
||||
sprintf(text, "%04X:%04X %04X %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt);
|
||||
DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
rect.top+=fontsize.cy;
|
||||
adr += 2;
|
||||
}
|
||||
|
||||
if(((win->cpu->instruct_adr&0x0FFFFFFF) >= win->curr_ligne<<1)&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+nbligne<<1)))
|
||||
{
|
||||
HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0));
|
||||
SetBkColor(mem_dc, RGB(255, 255, 0));
|
||||
|
||||
rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>1) - win->curr_ligne)*fontsize.cy;
|
||||
rect.bottom = rect.top + fontsize.cy;
|
||||
FillRect(mem_dc, &rect, brjaune);
|
||||
des_thumb_instructions_set[((win->cpu->instruction)&0xFFFF)>>6](win->cpu->instruct_adr, win->cpu->instruction&0xFFFF, txt);
|
||||
sprintf(text, "%04X:%04X %04X %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)(win->cpu->instruction&0xFFFF), txt);
|
||||
DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
DeleteObject(brjaune);
|
||||
}
|
||||
}
|
||||
|
||||
BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY);
|
||||
|
||||
DeleteDC(mem_dc);
|
||||
DeleteObject(mem_bmp);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
return 1;
|
||||
}
|
||||
|
||||
LRESULT DesViewDialog_OnPaint(HWND hwnd, CDesView * win, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
TCHAR text[80];
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
for(u32 i = 0; i < 16; ++i)
|
||||
{
|
||||
sprintf(text, "%08X", (int)win->cpu->R[i]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_R0+i), text);
|
||||
}
|
||||
|
||||
#define OFF 16
|
||||
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
if(win->cpu->CPSR.bits.N)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 452+OFF, 238, "N", 1);
|
||||
|
||||
if(win->cpu->CPSR.bits.Z)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 464+OFF, 238, "Z", 1);
|
||||
|
||||
if(win->cpu->CPSR.bits.C)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 475+OFF, 238, "C", 1);
|
||||
|
||||
if(win->cpu->CPSR.bits.V)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 486+OFF, 238, "V", 1);
|
||||
|
||||
if(win->cpu->CPSR.bits.Q)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 497+OFF, 238, "Q", 1);
|
||||
|
||||
if(!win->cpu->CPSR.bits.I)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 508+OFF, 238, "I", 1);
|
||||
|
||||
sprintf(text, "%02X", (int)win->cpu->CPSR.bits.mode);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_MODE), text);
|
||||
|
||||
sprintf(text, "%08X", MMU.timer[0][0]);//win->cpu->SPSR);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_TMP), text);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
return 1;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK DesViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CDesView * win = (CDesView *)GetWindowLong(hwnd, 0);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_NCCREATE:
|
||||
SetScrollRange(hwnd, SB_VERT, 0, 0x3FFFFF7, TRUE);
|
||||
SetScrollPos(hwnd, SB_VERT, 10, TRUE);
|
||||
return 1;
|
||||
|
||||
case WM_NCDESTROY:
|
||||
free(win);
|
||||
return 1;
|
||||
|
||||
case WM_PAINT:
|
||||
DesViewBox_OnPaint(win, wParam, lParam);
|
||||
return 1;
|
||||
|
||||
case WM_VSCROLL :
|
||||
{
|
||||
RECT rect;
|
||||
SIZE fontsize;
|
||||
GetClientRect(hwnd, &rect);
|
||||
HDC dc = GetDC(hwnd);
|
||||
HFONT old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT));
|
||||
GetTextExtentPoint32(dc, "0", 1, &fontsize);
|
||||
|
||||
int nbligne = (rect.bottom - rect.top)/fontsize.cy;
|
||||
|
||||
switch LOWORD(wParam)
|
||||
{
|
||||
case SB_LINEDOWN :
|
||||
win->curr_ligne = min(0x3FFFFF7*(1+win->cpu->CPSR.bits.T), win->curr_ligne+1);
|
||||
break;
|
||||
case SB_LINEUP :
|
||||
win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-1);
|
||||
break;
|
||||
case SB_PAGEDOWN :
|
||||
win->curr_ligne = min(0x3FFFFF7*(1+win->cpu->CPSR.bits.T), win->curr_ligne+nbligne);
|
||||
break;
|
||||
case SB_PAGEUP :
|
||||
win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-nbligne);
|
||||
break;
|
||||
}
|
||||
|
||||
SelectObject(dc, old);
|
||||
SetScrollPos(hwnd, SB_VERT, win->curr_ligne, TRUE);
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
UpdateWindow(hwnd);
|
||||
}
|
||||
return 1;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
// DES VIEWER
|
||||
BOOL CALLBACK des_view_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CDesView * win = (CDesView *)GetWindowLong(hwnd, DWL_USER);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
SetDlgItemInt(hwnd, IDC_SETPNUM, 1, FALSE);
|
||||
SendMessage(GetDlgItem(hwnd, IDC_AUTO_DES), BM_SETCHECK, TRUE, 0);
|
||||
return 1;
|
||||
case WM_CLOSE :
|
||||
win->remove2RefreshList();
|
||||
delete win;
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case WM_PAINT:
|
||||
DesViewDialog_OnPaint(hwnd, win, wParam, lParam);
|
||||
return 1;
|
||||
case WM_COMMAND :
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDC_FERMER :
|
||||
win->remove2RefreshList();
|
||||
delete win;
|
||||
EndDialog(hwnd, 0);
|
||||
return 0;
|
||||
case IDC_AUTO_DES :
|
||||
win->mode = 0;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX));
|
||||
return 1;
|
||||
case IDC_ARM :
|
||||
win->mode = 1;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX));
|
||||
return 1;
|
||||
case IDC_THUMB :
|
||||
win->mode = 2;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX));
|
||||
return 1;
|
||||
case IDC_AUTO_UPDATE :
|
||||
if(win->autoup)
|
||||
{
|
||||
win->remove2RefreshList();
|
||||
win->autoup = FALSE;
|
||||
return 1;
|
||||
}
|
||||
win->add2RefreshList();
|
||||
win->autoup = TRUE;
|
||||
return 1;
|
||||
case IDC_STEP :
|
||||
{
|
||||
BITMAPV4HEADER bmi;
|
||||
|
||||
//CreateBitmapIndirect(&bmi);
|
||||
memset(&bmi, 0, sizeof(bmi));
|
||||
bmi.bV4Size = sizeof(bmi);
|
||||
bmi.bV4Planes = 1;
|
||||
bmi.bV4BitCount = 16;
|
||||
bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS;
|
||||
bmi.bV4RedMask = 0x001F;
|
||||
bmi.bV4GreenMask = 0x03E0;
|
||||
bmi.bV4BlueMask = 0x7C00;
|
||||
bmi.bV4Width = 256;
|
||||
bmi.bV4Height = -192;
|
||||
int ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE);
|
||||
NDS_exec(ndstep, TRUE);
|
||||
if(!win->autoup) win->refresh();
|
||||
CWindow::refreshALL();
|
||||
SetDIBitsToDevice(hdc, 0, 0, 256, 192*2, 0, 0, 0, 192*2, GPU_screen, (BITMAPINFO*)&bmi, DIB_RGB_COLORS);
|
||||
}
|
||||
return 1;
|
||||
case IDC_GO :
|
||||
{
|
||||
char tmp[8];
|
||||
int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 8);
|
||||
u32 adr = 0;
|
||||
for(u16 i = 0; i<lg; ++i)
|
||||
{
|
||||
if((tmp[i]>='A')&&(tmp[i]<='F'))
|
||||
{
|
||||
adr = adr*16 + (tmp[i]-'A'+10);
|
||||
continue;
|
||||
}
|
||||
if((tmp[i]>='0')&&(tmp[i]<='9'))
|
||||
{
|
||||
adr = adr*16 + (tmp[i]-'0');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
win->curr_ligne = adr>>2;
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX));
|
||||
}
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
CDesView::CDesView(HINSTANCE hInst, HWND parent, char * titre, armcpu_t * CPU) :
|
||||
CWindow(hInst, parent, titre, IDD_DESASSEMBLEUR_VIEWER, des_view_proc), cpu(CPU), mode(0)
|
||||
{
|
||||
SetWindowLong(GetDlgItem(hwnd, IDC_DES_BOX), 0, (LONG)this);
|
||||
}
|
||||
|
||||
void CDesView::refresh()
|
||||
{
|
||||
if(((cpu->instruct_adr&0x0FFFFFFF)>>(2-cpu->CPSR.bits.T))>=8)
|
||||
if(((cpu->instruct_adr&0x0FFFFFFF)>>(2-cpu->CPSR.bits.T))<=0x3FFFFF7*(1+cpu->CPSR.bits.T))
|
||||
curr_ligne = ((cpu->instruct_adr&0x0FFFFFFF)>>(2-cpu->CPSR.bits.T))-8;
|
||||
else
|
||||
curr_ligne = 0x3FFFFEF*(1+cpu->CPSR.bits.T);
|
||||
else
|
||||
curr_ligne = 0;
|
||||
SetScrollRange(GetDlgItem(hwnd, IDC_DES_BOX), SB_VERT, 0, 0x3FFFFF7*(1+cpu->CPSR.bits.T), TRUE);
|
||||
SetScrollPos(GetDlgItem(hwnd, IDC_DES_BOX), SB_VERT, curr_ligne, TRUE);
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
}
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT DisViewBox_OnPaint(disview_struct *win, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hwnd = GetDlgItem(win->hwnd, IDC_DES_BOX);
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
SIZE fontsize;
|
||||
TCHAR text[100];
|
||||
TCHAR txt[100];
|
||||
RECT rect;
|
||||
int lg;
|
||||
int ht;
|
||||
HDC mem_dc;
|
||||
HBITMAP mem_bmp;
|
||||
u32 nbligne;
|
||||
|
||||
GetClientRect(hwnd, &rect);
|
||||
lg = rect.right - rect.left;
|
||||
ht = rect.bottom - rect.top;
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
mem_dc = CreateCompatibleDC(hdc);
|
||||
mem_bmp = CreateCompatibleBitmap(hdc, lg, ht);
|
||||
SelectObject(mem_dc, mem_bmp);
|
||||
|
||||
FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||
|
||||
SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT));
|
||||
|
||||
GetTextExtentPoint32(mem_dc, "0", 1, &fontsize);
|
||||
|
||||
nbligne = ht/fontsize.cy;
|
||||
|
||||
SetTextColor(mem_dc, RGB(0,0,0));
|
||||
|
||||
if((win->mode==1) || ((win->mode==0) && (win->cpu->CPSR.bits.T == 0)))
|
||||
{
|
||||
u32 i;
|
||||
u32 adr = win->curr_ligne*4;
|
||||
|
||||
for(i = 0; i < nbligne; ++i)
|
||||
{
|
||||
u32 ins = MMU_readWord(win->cpu->proc_ID, adr);
|
||||
des_arm_instructions_set[INDEX(ins)](adr, ins, txt);
|
||||
sprintf(text, "%04X:%04X %08X %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt);
|
||||
DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
rect.top+=fontsize.cy;
|
||||
adr += 4;
|
||||
}
|
||||
|
||||
if(((win->cpu->instruct_adr&0x0FFFFFFF) >= win->curr_ligne<<2)&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+nbligne<<2)))
|
||||
{
|
||||
HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0));
|
||||
SetBkColor(mem_dc, RGB(255, 255, 0));
|
||||
rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>2) - win->curr_ligne)*fontsize.cy;
|
||||
rect.bottom = rect.top + fontsize.cy;
|
||||
FillRect(mem_dc, &rect, brjaune);
|
||||
des_arm_instructions_set[INDEX(win->cpu->instruction)](win->cpu->instruct_adr, win->cpu->instruction, txt);
|
||||
sprintf(text, "%04X:%04X %08X %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)win->cpu->instruction, txt);
|
||||
DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
DeleteObject(brjaune);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 i;
|
||||
u32 adr = win->curr_ligne*2;
|
||||
|
||||
for(i = 0; i < nbligne; ++i)
|
||||
{
|
||||
u32 ins = MMU_readHWord(win->cpu->proc_ID, adr);
|
||||
des_thumb_instructions_set[ins>>6](adr, ins, txt);
|
||||
sprintf(text, "%04X:%04X %04X %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt);
|
||||
DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
rect.top+=fontsize.cy;
|
||||
adr += 2;
|
||||
}
|
||||
|
||||
if(((win->cpu->instruct_adr&0x0FFFFFFF) >= win->curr_ligne<<1)&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+nbligne<<1)))
|
||||
{
|
||||
HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0));
|
||||
SetBkColor(mem_dc, RGB(255, 255, 0));
|
||||
|
||||
rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>1) - win->curr_ligne)*fontsize.cy;
|
||||
rect.bottom = rect.top + fontsize.cy;
|
||||
FillRect(mem_dc, &rect, brjaune);
|
||||
des_thumb_instructions_set[((win->cpu->instruction)&0xFFFF)>>6](win->cpu->instruct_adr, win->cpu->instruction&0xFFFF, txt);
|
||||
sprintf(text, "%04X:%04X %04X %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)(win->cpu->instruction&0xFFFF), txt);
|
||||
DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
DeleteObject(brjaune);
|
||||
}
|
||||
}
|
||||
|
||||
BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY);
|
||||
|
||||
DeleteDC(mem_dc);
|
||||
DeleteObject(mem_bmp);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT DisViewDialog_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
TCHAR text[80];
|
||||
u32 i;
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
for(i = 0; i < 16; ++i)
|
||||
{
|
||||
sprintf(text, "%08X", (int)win->cpu->R[i]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_R0+i), text);
|
||||
}
|
||||
|
||||
#define OFF 16
|
||||
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
if(win->cpu->CPSR.bits.N)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 452+OFF, 238, "N", 1);
|
||||
|
||||
if(win->cpu->CPSR.bits.Z)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 464+OFF, 238, "Z", 1);
|
||||
|
||||
if(win->cpu->CPSR.bits.C)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 475+OFF, 238, "C", 1);
|
||||
|
||||
if(win->cpu->CPSR.bits.V)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 486+OFF, 238, "V", 1);
|
||||
|
||||
if(win->cpu->CPSR.bits.Q)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 497+OFF, 238, "Q", 1);
|
||||
|
||||
if(!win->cpu->CPSR.bits.I)
|
||||
SetTextColor(hdc, RGB(255,0,0));
|
||||
else
|
||||
SetTextColor(hdc, RGB(70, 70, 70));
|
||||
TextOut(hdc, 508+OFF, 238, "I", 1);
|
||||
|
||||
sprintf(text, "%02X", (int)win->cpu->CPSR.bits.mode);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_MODE), text);
|
||||
|
||||
sprintf(text, "%08X", MMU.timer[0][0]);//win->cpu->SPSR);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_TMP), text);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT CALLBACK DisViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
disview_struct *win = (disview_struct *)GetWindowLong(hwnd, 0);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_NCCREATE:
|
||||
SetScrollRange(hwnd, SB_VERT, 0, 0x3FFFFF7, TRUE);
|
||||
SetScrollPos(hwnd, SB_VERT, 10, TRUE);
|
||||
return 1;
|
||||
|
||||
case WM_NCDESTROY:
|
||||
free(win);
|
||||
return 1;
|
||||
|
||||
case WM_PAINT:
|
||||
DisViewBox_OnPaint(win, wParam, lParam);
|
||||
return 1;
|
||||
|
||||
case WM_VSCROLL :
|
||||
{
|
||||
RECT rect;
|
||||
SIZE fontsize;
|
||||
HDC dc;
|
||||
HFONT old;
|
||||
int nbligne;
|
||||
|
||||
GetClientRect(hwnd, &rect);
|
||||
dc = GetDC(hwnd);
|
||||
old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT));
|
||||
GetTextExtentPoint32(dc, "0", 1, &fontsize);
|
||||
|
||||
nbligne = (rect.bottom - rect.top)/fontsize.cy;
|
||||
|
||||
switch LOWORD(wParam)
|
||||
{
|
||||
case SB_LINEDOWN :
|
||||
win->curr_ligne = min(0x3FFFFF7*(1+win->cpu->CPSR.bits.T), win->curr_ligne+1);
|
||||
break;
|
||||
case SB_LINEUP :
|
||||
win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-1);
|
||||
break;
|
||||
case SB_PAGEDOWN :
|
||||
win->curr_ligne = min(0x3FFFFF7*(1+win->cpu->CPSR.bits.T), win->curr_ligne+nbligne);
|
||||
break;
|
||||
case SB_PAGEUP :
|
||||
win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-nbligne);
|
||||
break;
|
||||
}
|
||||
|
||||
SelectObject(dc, old);
|
||||
SetScrollPos(hwnd, SB_VERT, win->curr_ligne, TRUE);
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
UpdateWindow(hwnd);
|
||||
}
|
||||
return 1;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// DES VIEWER
|
||||
BOOL CALLBACK DisView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
disview_struct *win = (disview_struct *)GetWindowLong(hwnd, DWL_USER);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
SetDlgItemInt(hwnd, IDC_SETPNUM, 1, FALSE);
|
||||
SendMessage(GetDlgItem(hwnd, IDC_AUTO_DES), BM_SETCHECK, TRUE, 0);
|
||||
return 1;
|
||||
case WM_CLOSE :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
DisView_Deinit(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case WM_PAINT:
|
||||
DisViewDialog_OnPaint(hwnd, win, wParam, lParam);
|
||||
return 1;
|
||||
case WM_COMMAND :
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDC_FERMER :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
DisView_Deinit(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 0;
|
||||
case IDC_AUTO_DES :
|
||||
win->mode = 0;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX));
|
||||
return 1;
|
||||
case IDC_ARM :
|
||||
win->mode = 1;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX));
|
||||
return 1;
|
||||
case IDC_THUMB :
|
||||
win->mode = 2;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX));
|
||||
return 1;
|
||||
case IDC_AUTO_UPDATE :
|
||||
if(win->autoup)
|
||||
{
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
win->autoup = FALSE;
|
||||
return 1;
|
||||
}
|
||||
CWindow_AddToRefreshList(win);
|
||||
win->autoup = TRUE;
|
||||
return 1;
|
||||
case IDC_STEP :
|
||||
{
|
||||
BITMAPV4HEADER bmi;
|
||||
int ndstep;
|
||||
|
||||
//CreateBitmapIndirect(&bmi);
|
||||
memset(&bmi, 0, sizeof(bmi));
|
||||
bmi.bV4Size = sizeof(bmi);
|
||||
bmi.bV4Planes = 1;
|
||||
bmi.bV4BitCount = 16;
|
||||
bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS;
|
||||
bmi.bV4RedMask = 0x001F;
|
||||
bmi.bV4GreenMask = 0x03E0;
|
||||
bmi.bV4BlueMask = 0x7C00;
|
||||
bmi.bV4Width = 256;
|
||||
bmi.bV4Height = -192;
|
||||
ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE);
|
||||
NDS_exec(ndstep, TRUE);
|
||||
if(!win->autoup) win->Refresh(win);
|
||||
CWindow_RefreshALL();
|
||||
SetDIBitsToDevice(hdc, 0, 0, 256, 192*2, 0, 0, 0, 192*2, GPU_screen, (BITMAPINFO*)&bmi, DIB_RGB_COLORS);
|
||||
}
|
||||
return 1;
|
||||
case IDC_GO :
|
||||
{
|
||||
u16 i;
|
||||
char tmp[8];
|
||||
int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 8);
|
||||
u32 adr = 0;
|
||||
for(i = 0; i<lg; ++i)
|
||||
{
|
||||
if((tmp[i]>='A')&&(tmp[i]<='F'))
|
||||
{
|
||||
adr = adr*16 + (tmp[i]-'A'+10);
|
||||
continue;
|
||||
}
|
||||
if((tmp[i]>='0')&&(tmp[i]<='9'))
|
||||
{
|
||||
adr = adr*16 + (tmp[i]-'0');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
win->curr_ligne = adr>>2;
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX));
|
||||
}
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
disview_struct *DisView_Init(HINSTANCE hInst, HWND parent, char *title, armcpu_t *CPU)
|
||||
{
|
||||
disview_struct *DisView=NULL;
|
||||
|
||||
if ((DisView = (disview_struct *)malloc(sizeof(disview_struct))) == NULL)
|
||||
return DisView;
|
||||
|
||||
if (CWindow_Init2(DisView, hInst, parent, title, IDD_DESASSEMBLEUR_VIEWER, DisView_Proc) != 0)
|
||||
{
|
||||
free(DisView);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DisView->cpu = CPU;
|
||||
DisView->mode = 0;
|
||||
DisView->Refresh = (void (*)(void *))&DisView_Refresh;
|
||||
|
||||
SetWindowLong(GetDlgItem(DisView->hwnd, IDC_DES_BOX), 0, (LONG)DisView);
|
||||
|
||||
return DisView;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DisView_Deinit(disview_struct *DisView)
|
||||
{
|
||||
if (DisView)
|
||||
free(DisView);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DisView_Refresh(disview_struct *DisView)
|
||||
{
|
||||
if(((DisView->cpu->instruct_adr&0x0FFFFFFF)>>(2-DisView->cpu->CPSR.bits.T))>=8)
|
||||
if(((DisView->cpu->instruct_adr&0x0FFFFFFF)>>(2-DisView->cpu->CPSR.bits.T))<=0x3FFFFF7*(1+DisView->cpu->CPSR.bits.T))
|
||||
DisView->curr_ligne = ((DisView->cpu->instruct_adr&0x0FFFFFFF)>>(2-DisView->cpu->CPSR.bits.T))-8;
|
||||
else
|
||||
DisView->curr_ligne = 0x3FFFFEF*(1+DisView->cpu->CPSR.bits.T);
|
||||
else
|
||||
DisView->curr_ligne = 0;
|
||||
SetScrollRange(GetDlgItem(DisView->hwnd, IDC_DES_BOX), SB_VERT, 0, 0x3FFFFF7*(1+DisView->cpu->CPSR.bits.T), TRUE);
|
||||
SetScrollPos(GetDlgItem(DisView->hwnd, IDC_DES_BOX), SB_VERT, DisView->curr_ligne, TRUE);
|
||||
InvalidateRect(DisView->hwnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,49 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef DISVIEW_H
|
||||
#define DISVIEW_H
|
||||
|
||||
#include "../NDSSystem.h"
|
||||
#include "../armcpu.h"
|
||||
|
||||
#include "CWindow.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HWND hwnd;
|
||||
BOOL autoup;
|
||||
void *prev;
|
||||
void *next;
|
||||
void *first;
|
||||
void (*Refresh)(void *win);
|
||||
|
||||
u32 curr_ligne;
|
||||
armcpu_t *cpu;
|
||||
u16 mode;
|
||||
} disview_struct;
|
||||
|
||||
void InitDesViewBox();
|
||||
disview_struct *DisView_Init(HINSTANCE hInst, HWND parent, char *title, armcpu_t *CPU);
|
||||
void DisView_Deinit(disview_struct *DisView);
|
||||
void DisView_Refresh(disview_struct *DisView);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,91 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
#include "../NDSSystem.h"
|
||||
#include "../MMU.h"
|
||||
#include <stdio.h>
|
||||
#include "CWindow.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT Ginfo_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
TCHAR text[80];
|
||||
NDS_header * header = NDS_getROMHeader();
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
//sprintf(text, "%08X", MMU::ARM9_MEM_MASK[0x80]);
|
||||
// This needs to be done because some games use all 12 bytes for text
|
||||
// without a 0x00 termination
|
||||
memcpy(text, header->gameTile, 12);
|
||||
text[12] = 0x00;
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_NOM_JEU), text);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_CDE), header->gameCode);
|
||||
sprintf(text, "%d", header->makerCode);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_FAB), text);
|
||||
sprintf(text, "%d", header->cardSize);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_TAILLE), text);
|
||||
sprintf(text, "%d", (int)header->ARM9binSize);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_ARM9_T), text);
|
||||
sprintf(text, "%d", (int)header->ARM7binSize);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_ARM7_T), text);
|
||||
sprintf(text, "%d", (int)(header->ARM7binSize + header->ARM7src));
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_DATA), text);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
|
||||
free(header);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL CALLBACK GinfoView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
return 1;
|
||||
case WM_CLOSE :
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case WM_PAINT:
|
||||
Ginfo_OnPaint(hwnd, wParam, lParam);
|
||||
return 1;
|
||||
case WM_COMMAND :
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDC_FERMER :
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,28 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef GINFO_H
|
||||
#define GINFO_H
|
||||
|
||||
BOOL CALLBACK GinfoView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,222 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "mapview.h"
|
||||
#include "resource.h"
|
||||
#include "../MMU.h"
|
||||
#include "../NDSSystem.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
char text[80];
|
||||
u32 dispcnt = ((volatile u32 *)ARM9Mem.ARM9_REG)[(win->lcd*0x400)];
|
||||
u32 bgcnt = ((volatile u16 *)ARM9Mem.ARM9_REG)[(8 + (win->map<<1) + (win->lcd*0x1000))>>1];
|
||||
BITMAPV4HEADER bmi;
|
||||
u16 lg;
|
||||
u16 ht;
|
||||
|
||||
//CreateBitmapIndirect(&bmi);
|
||||
memset(&bmi, 0, sizeof(bmi));
|
||||
bmi.bV4Size = sizeof(bmi);
|
||||
bmi.bV4Planes = 1;
|
||||
bmi.bV4BitCount = 16;
|
||||
bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS;
|
||||
bmi.bV4RedMask = 0x001F;
|
||||
bmi.bV4GreenMask = 0x03E0;
|
||||
bmi.bV4BlueMask = 0x7C00;
|
||||
|
||||
if(win->lcd)
|
||||
{
|
||||
lg = SubScreen.gpu->BGSize[win->map][0];
|
||||
ht = SubScreen.gpu->BGSize[win->map][1];
|
||||
}
|
||||
else
|
||||
{
|
||||
lg = MainScreen.gpu->BGSize[win->map][0];
|
||||
ht = MainScreen.gpu->BGSize[win->map][1];
|
||||
}
|
||||
bmi.bV4Width = lg;
|
||||
bmi.bV4Height = -ht;
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
sprintf(text, "%d %08X, %08X", (int)(dispcnt&7), (int)dispcnt, (int)bgcnt);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_MODE), text);
|
||||
|
||||
if(!(bgcnt&(1<<7)))
|
||||
sprintf(text, "normale 16");
|
||||
else
|
||||
if(!(dispcnt&(1<<30)))
|
||||
sprintf(text, "normale 256");
|
||||
else
|
||||
switch(win->map)
|
||||
{
|
||||
case 0 :
|
||||
sprintf(text, "extended slot %d", (bgcnt&(1<<13))?2:0);
|
||||
break;
|
||||
case 1 :
|
||||
sprintf(text, "extended slot %d", (bgcnt&(1<<13))?3:1);
|
||||
break;
|
||||
default :
|
||||
sprintf(text, "extended slot %d", MainScreen.gpu->BGExtPalSlot[win->map]);
|
||||
break;
|
||||
}
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_PAL), text);
|
||||
|
||||
sprintf(text, "%d", (int)(bgcnt&3));
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_PRIO), text);
|
||||
|
||||
sprintf(text, "0x%08X", (int)(0x6000000 + ((bgcnt>>2)&0xF)*0x4000 + win->lcd*0x200000 +((dispcnt>>24)&7)*0x10000));
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_CHAR), text);
|
||||
|
||||
sprintf(text, "0x%08X", (int)(0x6000000 + 0x800*((bgcnt>>8)&0x1F) + win->lcd*0x200000 + ((dispcnt>>27)&7)*0x10000));
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_SCR), text);
|
||||
|
||||
//sprintf(text, "%d x %d", MainScreen.gpu->BGPA[win->map], MainScreen.gpu->BGPB[win->map]);
|
||||
sprintf(text, "%d x %d", (int)MainScreen.gpu->BGSize[win->map][0], (int)MainScreen.gpu->BGSize[win->map][1]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_MSIZE), text);
|
||||
|
||||
sprintf(text, "%d x %d", MainScreen.gpu->BGPC[win->map], MainScreen.gpu->BGPD[win->map]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_SCROLL), text);
|
||||
|
||||
if(win->lcd)
|
||||
textBG(SubScreen.gpu, win->map, (u8 *)win->bitmap);
|
||||
//rotBG(SubScreen.gpu, win->map, win->bitmap);
|
||||
//extRotBG(SubScreen.gpu, win->map, win->bitmap);
|
||||
else
|
||||
textBG(MainScreen.gpu, win->map, (u8 *)win->bitmap);
|
||||
//rotBG(MainScreen.gpu, win->map, win->bitmap);
|
||||
//extRotBG(MainScreen.gpu, win->map, win->bitmap);
|
||||
|
||||
SetDIBitsToDevice(hdc, 200, 4, lg, ht, 0, 0, 0, ht, win->bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS);
|
||||
//SetDIBitsToDevice(hdc, 200, 4, 256, 192, 0, 0, 0, 192, win->bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL CALLBACK MapView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
mapview_struct * win = (mapview_struct *)GetWindowLong(hwnd, DWL_USER);
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
HWND combo = GetDlgItem(hwnd, IDC_BG_SELECT);
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 0");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 1");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 2");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 3");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 0");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 1");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 2");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 3");
|
||||
SendMessage(combo, CB_SETCURSEL, 0, 0);
|
||||
}
|
||||
return 1;
|
||||
case WM_CLOSE :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
MapView_Deinit(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case WM_PAINT:
|
||||
MapView_OnPaint(win, hwnd, wParam, lParam);
|
||||
return 1;
|
||||
case WM_COMMAND :
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDC_FERMER :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
MapView_Deinit(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case IDC_BG_SELECT :
|
||||
switch(HIWORD(wParam))
|
||||
{
|
||||
case CBN_CLOSEUP :
|
||||
{
|
||||
u32 sel= SendMessage(GetDlgItem(hwnd, IDC_BG_SELECT), CB_GETCURSEL, 0, 0);
|
||||
switch(sel)
|
||||
{
|
||||
case 0 :
|
||||
case 1 :
|
||||
case 2 :
|
||||
case 3 :
|
||||
win->map = sel;
|
||||
win->lcd = 0;
|
||||
break;
|
||||
case 4 :
|
||||
case 5 :
|
||||
case 6 :
|
||||
case 7 :
|
||||
win->map = sel-4;
|
||||
win->lcd = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CWindow_Refresh(win);
|
||||
return 1;
|
||||
}//switch et case
|
||||
}//switch
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
mapview_struct *MapView_Init(HINSTANCE hInst, HWND parent)
|
||||
{
|
||||
mapview_struct *MapView=NULL;
|
||||
|
||||
if ((MapView = (mapview_struct *)malloc(sizeof(mapview_struct))) == NULL)
|
||||
return MapView;
|
||||
|
||||
if (CWindow_Init2(MapView, hInst, parent, "Map viewer", IDD_MAP, MapView_Proc) != 0)
|
||||
{
|
||||
free(MapView);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MapView->map = 0;
|
||||
MapView->lcd = 0;
|
||||
|
||||
return MapView;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void MapView_Deinit(mapview_struct *MapView)
|
||||
{
|
||||
if (MapView)
|
||||
free(MapView);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,45 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef MAPVIEW_H
|
||||
#define MAPVIEW_H
|
||||
|
||||
#include <windows.h>
|
||||
#include "CWindow.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HWND hwnd;
|
||||
BOOL autoup;
|
||||
void *prev;
|
||||
void *next;
|
||||
void *first;
|
||||
void (*Refresh)(void *win);
|
||||
|
||||
u16 map;
|
||||
u16 lcd;
|
||||
u16 bitmap[1024*1024];
|
||||
} mapview_struct;
|
||||
|
||||
mapview_struct *MapView_Init(HINSTANCE hInst, HWND parent);
|
||||
void MapView_Deinit(mapview_struct *MapView);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,579 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include "memView.h"
|
||||
#include "../MMU.h"
|
||||
#include "resource.h"
|
||||
|
||||
LRESULT CALLBACK MemViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
void InitMemViewBox()
|
||||
{
|
||||
WNDCLASSEX wc;
|
||||
|
||||
wc.cbSize = sizeof(wc);
|
||||
wc.lpszClassName = _T("MemViewBox");
|
||||
wc.hInstance = GetModuleHandle(0);
|
||||
wc.lpfnWndProc = MemViewBoxWndProc;
|
||||
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||
wc.hIcon = 0;
|
||||
wc.lpszMenuName = 0;
|
||||
wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE);
|
||||
wc.style = 0;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = sizeof(cwindow_struct *);
|
||||
wc.hIconSm = 0;
|
||||
|
||||
RegisterClassEx(&wc);
|
||||
}
|
||||
|
||||
/*
|
||||
LRESULT MemViewBox_OnPaint(CMemView * win, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hwnd = GetDlgItem(win->hwnd, IDC_MEM_BOX);
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
SIZE fontsize;
|
||||
TCHAR text[80];
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(hwnd, &rect);
|
||||
int lg = rect.right - rect.left;
|
||||
int ht = rect.bottom - rect.top;
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
HDC mem_dc = CreateCompatibleDC(hdc);
|
||||
HBITMAP mem_bmp = CreateCompatibleBitmap(hdc, lg, ht);
|
||||
SelectObject(mem_dc, mem_bmp);
|
||||
|
||||
FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||
|
||||
SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT));
|
||||
|
||||
GetTextExtentPoint32(mem_dc, "0", 1, &fontsize);
|
||||
|
||||
int nbligne = ht/fontsize.cy;
|
||||
|
||||
SetTextColor(mem_dc, RGB(0,0,0));
|
||||
|
||||
RECT r;
|
||||
|
||||
r.top = 3;
|
||||
r.left = 3;
|
||||
r.bottom = r.top+fontsize.cy;
|
||||
r.right = rect.right-3;
|
||||
|
||||
u32 adr = win->curr_ligne*0x10;
|
||||
|
||||
for(int i=0; i<nbligne; ++i)
|
||||
{
|
||||
sprintf(text, "%04X:%04X", (int)(adr>>16), (int)(adr&0xFFFF));
|
||||
DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
r.left += 11*fontsize.cx;
|
||||
int j;
|
||||
|
||||
if(win->representation == 0)
|
||||
for(j=0; j<16; ++j)
|
||||
{
|
||||
sprintf(text, "%02X", MMU_readByte(win->cpu, adr+j));
|
||||
DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
r.left+=3*fontsize.cx;
|
||||
}
|
||||
else
|
||||
if(win->representation == 1)
|
||||
for(j=0; j<16; j+=2)
|
||||
{
|
||||
sprintf(text, "%04X", MMU_readHWord(win->cpu, adr+j));
|
||||
DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
r.left+=5*fontsize.cx;
|
||||
}
|
||||
else
|
||||
for(j=0; j<16; j+=4)
|
||||
{
|
||||
sprintf(text, "%08X", (int)MMU_readWord(win->cpu, adr+j));
|
||||
DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
r.left+=9*fontsize.cx;
|
||||
}
|
||||
|
||||
r.left+=fontsize.cx;
|
||||
|
||||
for(j=0; j<16; ++j)
|
||||
{
|
||||
u8 c = MMU_readByte(win->cpu, adr+j);
|
||||
if(c >= 32 && c <= 127) {
|
||||
text[j] = (char)c;
|
||||
}
|
||||
else
|
||||
text[j] = '.';
|
||||
}
|
||||
text[j] = '\0';
|
||||
DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
|
||||
adr+=0x10;
|
||||
r.top += fontsize.cy;
|
||||
r.bottom += fontsize.cy;
|
||||
r.left = 3;
|
||||
}
|
||||
|
||||
BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY);
|
||||
|
||||
DeleteDC(mem_dc);
|
||||
DeleteObject(mem_bmp);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
return 1;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MemViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CMemView * win = (CMemView *)GetWindowLong(hwnd, 0);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_NCCREATE:
|
||||
SetScrollRange(hwnd, SB_VERT, 0, 0x0FFFFFFF, TRUE);
|
||||
SetScrollPos(hwnd, SB_VERT, 10, TRUE);
|
||||
return 1;
|
||||
|
||||
case WM_NCDESTROY:
|
||||
return 1;
|
||||
|
||||
case WM_PAINT:
|
||||
MemViewBox_OnPaint(win, wParam, lParam);
|
||||
return 1;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
case WM_VSCROLL :
|
||||
{
|
||||
RECT rect;
|
||||
SIZE fontsize;
|
||||
GetClientRect(hwnd, &rect);
|
||||
HDC dc = GetDC(hwnd);
|
||||
HFONT old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT));
|
||||
GetTextExtentPoint32(dc, "0", 1, &fontsize);
|
||||
|
||||
int nbligne = (rect.bottom - rect.top)/fontsize.cy;
|
||||
|
||||
switch LOWORD(wParam)
|
||||
{
|
||||
case SB_LINEDOWN :
|
||||
win->curr_ligne = min(0X0FFFFFFFF, win->curr_ligne+1);
|
||||
break;
|
||||
case SB_LINEUP :
|
||||
win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-1);
|
||||
break;
|
||||
case SB_PAGEDOWN :
|
||||
win->curr_ligne = min(0X0FFFFFFFF, win->curr_ligne+nbligne);
|
||||
break;
|
||||
case SB_PAGEUP :
|
||||
win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-nbligne);
|
||||
break;
|
||||
}
|
||||
|
||||
SelectObject(dc, old);
|
||||
SetScrollPos(hwnd, SB_VERT, win->curr_ligne, TRUE);
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
UpdateWindow(hwnd);
|
||||
}
|
||||
return 1;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
// MEM VIEWER
|
||||
BOOL CALLBACK mem_view_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CMemView * win = (CMemView *)GetWindowLong(hwnd, DWL_USER);
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
SendMessage(GetDlgItem(hwnd, IDC_8_BIT), BM_SETCHECK, TRUE, 0);
|
||||
return 1;
|
||||
case WM_CLOSE :
|
||||
win->remove2RefreshList();
|
||||
delete win;
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case WM_COMMAND :
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDC_8_BIT :
|
||||
win->representation = 0;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX));
|
||||
return 1;
|
||||
case IDC_16_BIT :
|
||||
win->representation = 1;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX));
|
||||
return 1;
|
||||
case IDC_32_BIT :
|
||||
win->representation = 2;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX));
|
||||
return 1;
|
||||
case IDC_AUTO_UPDATE :
|
||||
if(win->autoup)
|
||||
{
|
||||
win->remove2RefreshList();
|
||||
win->autoup = FALSE;
|
||||
return 1;
|
||||
}
|
||||
win->add2RefreshList();
|
||||
win->autoup = TRUE;
|
||||
return 1;
|
||||
case IDC_GO :
|
||||
{
|
||||
char tmp[8];
|
||||
int lg = GetDlgItemText(hwnd, IDC_GOTOMEM, tmp, 8);
|
||||
u32 adr = 0;
|
||||
for(u16 i = 0; i<lg; ++i)
|
||||
{
|
||||
if((tmp[i]>='A')&&(tmp[i]<='F'))
|
||||
{
|
||||
adr = adr*16 + (tmp[i]-'A'+10);
|
||||
continue;
|
||||
}
|
||||
if((tmp[i]>='0')&&(tmp[i]<='9'))
|
||||
{
|
||||
adr = adr*16 + (tmp[i]-'0');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
win->curr_ligne = (adr>>4);
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
UpdateWindow(hwnd);
|
||||
}
|
||||
return 1;
|
||||
case IDC_FERMER :
|
||||
win->remove2RefreshList();
|
||||
delete win;
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
CMemView::CMemView(HINSTANCE hInst, HWND parent, char * titre, u8 CPU) :
|
||||
CWindow(hInst, parent, titre, IDD_MEM_VIEWER, mem_view_proc), cpu(CPU), curr_ligne(0), representation(0)
|
||||
{
|
||||
SetWindowLong(GetDlgItem(hwnd, IDC_MEM_BOX), 0, (LONG)this);
|
||||
}
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT MemViewBox_OnPaint(memview_struct * win, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hwnd = GetDlgItem(win->hwnd, IDC_MEM_BOX);
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
SIZE fontsize;
|
||||
TCHAR text[80];
|
||||
int i;
|
||||
RECT rect;
|
||||
int lg;
|
||||
int ht;
|
||||
HDC mem_dc;
|
||||
HBITMAP mem_bmp;
|
||||
int nbligne;
|
||||
RECT r;
|
||||
u32 adr;
|
||||
|
||||
GetClientRect(hwnd, &rect);
|
||||
lg = rect.right - rect.left;
|
||||
ht = rect.bottom - rect.top;
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
mem_dc = CreateCompatibleDC(hdc);
|
||||
mem_bmp = CreateCompatibleBitmap(hdc, lg, ht);
|
||||
SelectObject(mem_dc, mem_bmp);
|
||||
|
||||
FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||
|
||||
SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT));
|
||||
|
||||
GetTextExtentPoint32(mem_dc, "0", 1, &fontsize);
|
||||
|
||||
nbligne = ht/fontsize.cy;
|
||||
|
||||
SetTextColor(mem_dc, RGB(0,0,0));
|
||||
|
||||
r.top = 3;
|
||||
r.left = 3;
|
||||
r.bottom = r.top+fontsize.cy;
|
||||
r.right = rect.right-3;
|
||||
|
||||
adr = win->curr_ligne*0x10;
|
||||
|
||||
for(i=0; i<nbligne; ++i)
|
||||
{
|
||||
int j;
|
||||
sprintf(text, "%04X:%04X", (int)(adr>>16), (int)(adr&0xFFFF));
|
||||
DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
r.left += 11*fontsize.cx;
|
||||
|
||||
if(win->representation == 0)
|
||||
for(j=0; j<16; ++j)
|
||||
{
|
||||
sprintf(text, "%02X", MMU_readByte(win->cpu, adr+j));
|
||||
DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
r.left+=3*fontsize.cx;
|
||||
}
|
||||
else
|
||||
if(win->representation == 1)
|
||||
for(j=0; j<16; j+=2)
|
||||
{
|
||||
sprintf(text, "%04X", MMU_readHWord(win->cpu, adr+j));
|
||||
DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
r.left+=5*fontsize.cx;
|
||||
}
|
||||
else
|
||||
for(j=0; j<16; j+=4)
|
||||
{
|
||||
sprintf(text, "%08X", (int)MMU_readWord(win->cpu, adr+j));
|
||||
DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
r.left+=9*fontsize.cx;
|
||||
}
|
||||
|
||||
r.left+=fontsize.cx;
|
||||
|
||||
for(j=0; j<16; ++j)
|
||||
{
|
||||
u8 c = MMU_readByte(win->cpu, adr+j);
|
||||
if(c >= 32 && c <= 127) {
|
||||
text[j] = (char)c;
|
||||
}
|
||||
else
|
||||
text[j] = '.';
|
||||
}
|
||||
text[j] = '\0';
|
||||
DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX);
|
||||
|
||||
adr+=0x10;
|
||||
r.top += fontsize.cy;
|
||||
r.bottom += fontsize.cy;
|
||||
r.left = 3;
|
||||
}
|
||||
|
||||
BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY);
|
||||
|
||||
DeleteDC(mem_dc);
|
||||
DeleteObject(mem_bmp);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT CALLBACK MemViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
memview_struct *win = (memview_struct *)GetWindowLong(hwnd, 0);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_NCCREATE:
|
||||
SetScrollRange(hwnd, SB_VERT, 0, 0x0FFFFFFF, TRUE);
|
||||
SetScrollPos(hwnd, SB_VERT, 10, TRUE);
|
||||
return 1;
|
||||
|
||||
case WM_NCDESTROY:
|
||||
return 1;
|
||||
|
||||
case WM_PAINT:
|
||||
MemViewBox_OnPaint(win, wParam, lParam);
|
||||
return 1;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
case WM_VSCROLL :
|
||||
{
|
||||
RECT rect;
|
||||
SIZE fontsize;
|
||||
HDC dc;
|
||||
HFONT old;
|
||||
int nbligne;
|
||||
|
||||
GetClientRect(hwnd, &rect);
|
||||
dc = GetDC(hwnd);
|
||||
old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT));
|
||||
GetTextExtentPoint32(dc, "0", 1, &fontsize);
|
||||
|
||||
nbligne = (rect.bottom - rect.top)/fontsize.cy;
|
||||
|
||||
switch LOWORD(wParam)
|
||||
{
|
||||
case SB_LINEDOWN :
|
||||
win->curr_ligne = min(0X0FFFFFFFF, win->curr_ligne+1);
|
||||
break;
|
||||
case SB_LINEUP :
|
||||
win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-1);
|
||||
break;
|
||||
case SB_PAGEDOWN :
|
||||
win->curr_ligne = min(0X0FFFFFFFF, win->curr_ligne+nbligne);
|
||||
break;
|
||||
case SB_PAGEUP :
|
||||
win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-nbligne);
|
||||
break;
|
||||
}
|
||||
|
||||
SelectObject(dc, old);
|
||||
SetScrollPos(hwnd, SB_VERT, win->curr_ligne, TRUE);
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
UpdateWindow(hwnd);
|
||||
}
|
||||
return 1;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// MEM VIEWER
|
||||
BOOL CALLBACK MemView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
memview_struct *win = (memview_struct *)GetWindowLong(hwnd, DWL_USER);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
SendMessage(GetDlgItem(hwnd, IDC_8_BIT), BM_SETCHECK, TRUE, 0);
|
||||
return 1;
|
||||
case WM_CLOSE :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
MemView_Deinit(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case WM_COMMAND :
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDC_8_BIT :
|
||||
win->representation = 0;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX));
|
||||
return 1;
|
||||
case IDC_16_BIT :
|
||||
win->representation = 1;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX));
|
||||
return 1;
|
||||
case IDC_32_BIT :
|
||||
win->representation = 2;
|
||||
InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE);
|
||||
UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX));
|
||||
return 1;
|
||||
case IDC_AUTO_UPDATE :
|
||||
if(win->autoup)
|
||||
{
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
win->autoup = FALSE;
|
||||
return 1;
|
||||
}
|
||||
CWindow_AddToRefreshList(win);
|
||||
win->autoup = TRUE;
|
||||
return 1;
|
||||
case IDC_GO :
|
||||
{
|
||||
char tmp[8];
|
||||
int lg = GetDlgItemText(hwnd, IDC_GOTOMEM, tmp, 8);
|
||||
u32 adr = 0;
|
||||
u16 i;
|
||||
|
||||
for(i = 0; i<lg; ++i)
|
||||
{
|
||||
if((tmp[i]>='A')&&(tmp[i]<='F'))
|
||||
{
|
||||
adr = adr*16 + (tmp[i]-'A'+10);
|
||||
continue;
|
||||
}
|
||||
if((tmp[i]>='0')&&(tmp[i]<='9'))
|
||||
{
|
||||
adr = adr*16 + (tmp[i]-'0');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
win->curr_ligne = (adr>>4);
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
UpdateWindow(hwnd);
|
||||
}
|
||||
return 1;
|
||||
case IDC_FERMER :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
MemView_Deinit(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
memview_struct *MemView_Init(HINSTANCE hInst, HWND parent, char *title, u8 CPU)
|
||||
{
|
||||
memview_struct *MemView = NULL;
|
||||
|
||||
if ((MemView = (memview_struct *)malloc(sizeof(memview_struct))) == NULL)
|
||||
return MemView;
|
||||
|
||||
if (CWindow_Init2(MemView, hInst, parent, title, IDD_MEM_VIEWER, MemView_Proc) != 0)
|
||||
{
|
||||
free(MemView);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MemView->cpu = CPU;
|
||||
MemView->curr_ligne = 0;
|
||||
MemView->representation = 0;
|
||||
|
||||
SetWindowLong(GetDlgItem(MemView->hwnd, IDC_MEM_BOX), 0, (LONG)MemView);
|
||||
|
||||
return MemView;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void MemView_Deinit(memview_struct *MemView)
|
||||
{
|
||||
if (MemView)
|
||||
free(MemView);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,57 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef MEM_VIEW_H
|
||||
#define MEM_VIEW_H
|
||||
|
||||
#include "CWindow.h"
|
||||
|
||||
/*
|
||||
class CMemView : public CWindow
|
||||
{
|
||||
public :
|
||||
CMemView(HINSTANCE hInst, HWND parent, char * titre, u8 CPU);
|
||||
|
||||
s8 cpu;
|
||||
u32 curr_ligne;
|
||||
u8 representation;
|
||||
};
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HWND hwnd;
|
||||
BOOL autoup;
|
||||
void *prev;
|
||||
void *next;
|
||||
void *first;
|
||||
void (*Refresh)(void *win);
|
||||
|
||||
s8 cpu;
|
||||
u32 curr_ligne;
|
||||
u8 representation;
|
||||
} memview_struct;
|
||||
|
||||
void InitMemViewBox();
|
||||
memview_struct *MemView_Init(HINSTANCE hInst, HWND parent, char *title, u8 CPU);
|
||||
void MemView_Deinit(memview_struct *MemView);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,339 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include "resource.h"
|
||||
#include "oamView.h"
|
||||
#include "../GPU.h"
|
||||
|
||||
#include "../MMU.h"
|
||||
|
||||
#include "../NDSSystem.h"
|
||||
|
||||
extern NDSSystem nds;
|
||||
|
||||
const char dimm[4][4][8] =
|
||||
{
|
||||
{"8 x 8", "16 x 8", "8 x 16", "- x -"},
|
||||
{"16 x 16", "32 x 8", "8 x 32", "- x -"},
|
||||
{"32 x 32", "32 x 16", "16 x 32", "- x -"},
|
||||
{"64 x 64", "64 x 32", "32 x 64", "- x -"},
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT CALLBACK OAMViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
void InitOAMViewBox()
|
||||
{
|
||||
WNDCLASSEX wc;
|
||||
|
||||
wc.cbSize = sizeof(wc);
|
||||
wc.lpszClassName = _T("OAMViewBox");
|
||||
wc.hInstance = GetModuleHandle(0);
|
||||
wc.lpfnWndProc = OAMViewBoxWndProc;
|
||||
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||
wc.hIcon = 0;
|
||||
wc.lpszMenuName = 0;
|
||||
wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE);
|
||||
wc.style = 0;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = sizeof(cwindow_struct *);
|
||||
wc.hIconSm = 0;
|
||||
|
||||
RegisterClassEx(&wc);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT OAMViewBox_OnPaint(oamview_struct * win, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hwnd = GetDlgItem(win->hwnd, IDC_OAM_BOX);
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
// TCHAR text[80];
|
||||
RECT rect;
|
||||
int lg;
|
||||
int ht;
|
||||
HDC mem_dc;
|
||||
HBITMAP mem_bmp;
|
||||
|
||||
GetClientRect(hwnd, &rect);
|
||||
lg = rect.right - rect.left;
|
||||
ht = rect.bottom - rect.top;
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
mem_dc = CreateCompatibleDC(hdc);
|
||||
mem_bmp = CreateCompatibleBitmap(hdc, lg, ht);
|
||||
SelectObject(mem_dc, mem_bmp);
|
||||
|
||||
FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||
|
||||
BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY);
|
||||
|
||||
DeleteDC(mem_dc);
|
||||
DeleteObject(mem_bmp);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT CALLBACK OAMViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// oamView * win = (oamView *)GetWindowLong(hwnd, 0);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_NCCREATE:
|
||||
return 1;
|
||||
case WM_NCDESTROY:
|
||||
return 1;
|
||||
/*case WM_PAINT:
|
||||
OAMViewBox_OnPaint(win, wParam, lParam);
|
||||
return 1;*/
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT OamView_OnPaint(oamview_struct *win, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hwnd = win->hwnd;
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
OAM * oam = &win->oam[win->num];
|
||||
char text[80];
|
||||
u16 bitmap[256*192];
|
||||
u8 prio[256*192];
|
||||
BITMAPV4HEADER bmi;
|
||||
u16 i;
|
||||
s16 x;
|
||||
|
||||
//CreateBitmapIndirect(&bmi);
|
||||
memset(&bmi, 0, sizeof(bmi));
|
||||
bmi.bV4Size = sizeof(bmi);
|
||||
bmi.bV4Planes = 1;
|
||||
bmi.bV4BitCount = 16;
|
||||
bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS;
|
||||
bmi.bV4RedMask = 0x001F;
|
||||
bmi.bV4GreenMask = 0x03E0;
|
||||
bmi.bV4BlueMask = 0x7C00;
|
||||
bmi.bV4Width = 256;
|
||||
bmi.bV4Height = -192;
|
||||
|
||||
for(i = 0; i < 256*192; ++i)
|
||||
{
|
||||
bitmap[i] = 0x7F0F;
|
||||
prio[i] = 4;
|
||||
}
|
||||
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
sprintf(text, "OAM : %d", win->num);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_OAMNUM), text);
|
||||
|
||||
switch(oam->attr0&(3<<10))
|
||||
{
|
||||
case 0 :
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_MODE), "Normal");
|
||||
break;
|
||||
case (1<<10) :
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_MODE), "Smi-transp");
|
||||
break;
|
||||
case (2<<10) :
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_MODE), "OBJ Window");
|
||||
break;
|
||||
case (3<<10) :
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_MODE), "Bitmap");
|
||||
}
|
||||
|
||||
sprintf(text, "0x%08X", oam->attr0/*oam->attr2&0x3FF*/);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_TILE), text);
|
||||
|
||||
sprintf(text, "0x%08X", oam->attr1/*oam->attr2&0x3FF*/);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_PAL), text);
|
||||
|
||||
//SetWindowText(GetDlgItem(hwnd, IDC_PAL), (oam->attr0&(1<<13))?"256 couleurs": "16 couleurs");
|
||||
|
||||
sprintf(text, "%d 0x%08X", (oam->attr2>>10)&3, oam->attr2);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_PRIO), text);
|
||||
|
||||
x = oam->attr1&0x1FF;
|
||||
x = ((s16)(x<<7)>>7);
|
||||
sprintf(text, "%d x %d", x, oam->attr0&0xFF);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_COOR), text);
|
||||
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_DIM), dimm[oam->attr1>>14][oam->attr0>>14]);
|
||||
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_ROT), oam->attr0&(1<<8)?"ON" : "OFF");
|
||||
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_MOS), oam->attr0&(1<<12)?"ON" : "OFF");
|
||||
|
||||
if(oam->attr0&(1<<8))
|
||||
{
|
||||
sprintf(text, "Rot param : %d", (oam->attr1>>9)&0x1F);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_PROP0), text);
|
||||
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_PROP1), (oam->attr0&(1<<9))?"Double size": "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(oam->attr0&(1<<9))
|
||||
sprintf(text, "INVISIBLE");
|
||||
else
|
||||
sprintf(text, "%s %s", oam->attr0&(1<<12)?"H FLIP":"", oam->attr0&(1<<13)?"V FLIP":"");
|
||||
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_PROP0), text);
|
||||
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_PROP1), "");
|
||||
}
|
||||
|
||||
for(i = 0; i < 192; ++i)
|
||||
{
|
||||
win->gpu->spriteRender(win->gpu, i, bitmap + i*256, prio + i*256);
|
||||
}
|
||||
|
||||
SetDIBitsToDevice(hdc, 180, 4, 256, 192, 0, 0, 0, 192, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL CALLBACK OamView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
oamview_struct *win = (oamview_struct *)GetWindowLong(hwnd, DWL_USER);
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
HWND combo = GetDlgItem(hwnd, IDC_SCR_SELECT);
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen sprite");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen sprite");
|
||||
SendMessage(combo, CB_SETCURSEL, 0, 0);
|
||||
}
|
||||
return 1;
|
||||
case WM_CLOSE :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
OamView_Deinit(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case WM_PAINT:
|
||||
OamView_OnPaint(win, wParam, lParam);
|
||||
return 1;
|
||||
case WM_HSCROLL :
|
||||
switch LOWORD(wParam)
|
||||
{
|
||||
case SB_LINERIGHT :
|
||||
++(win->num);
|
||||
if(win->num>127)
|
||||
win->num = 127;
|
||||
break;
|
||||
case SB_LINELEFT :
|
||||
--(win->num);
|
||||
if(win->num<0)
|
||||
win->num = 0;
|
||||
break;
|
||||
}
|
||||
CWindow_Refresh(win);
|
||||
return 1;
|
||||
case WM_COMMAND :
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDC_FERMER :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
OamView_Deinit(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case IDC_SCR_SELECT :
|
||||
switch(HIWORD(wParam))
|
||||
{
|
||||
case CBN_CLOSEUP :
|
||||
{
|
||||
u32 sel = SendMessage(GetDlgItem(hwnd, IDC_SCR_SELECT), CB_GETCURSEL, 0, 0);
|
||||
switch(sel)
|
||||
{
|
||||
case 0 :
|
||||
win->oam = (OAM *)ARM9Mem.ARM9_OAM;
|
||||
win->num = 0;
|
||||
win->gpu = MainScreen.gpu;
|
||||
break;
|
||||
case 1 :
|
||||
win->oam = (OAM *)(ARM9Mem.ARM9_OAM+0x400);
|
||||
win->num = 0;
|
||||
win->gpu = SubScreen.gpu;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CWindow_Refresh(win);
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
oamview_struct *OamView_Init(HINSTANCE hInst, HWND parent)
|
||||
{
|
||||
oamview_struct *OamView=NULL;
|
||||
|
||||
if ((OamView = (oamview_struct *)malloc(sizeof(oamview_struct))) == NULL)
|
||||
return OamView;
|
||||
|
||||
if (CWindow_Init2(OamView, hInst, parent, "OAM Viewer", IDD_OAM, OamView_Proc) != 0)
|
||||
{
|
||||
free(OamView);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OamView->oam = (OAM *)(ARM9Mem.ARM9_OAM);
|
||||
OamView->num = 0;
|
||||
OamView->gpu = MainScreen.gpu;
|
||||
|
||||
return OamView;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OamView_Deinit(oamview_struct *OamView)
|
||||
{
|
||||
if (OamView)
|
||||
free(OamView);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,46 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef OAMVIEW_H
|
||||
#define OAMVIEW_H
|
||||
|
||||
#include "CWindow.h"
|
||||
#include "../GPU.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HWND hwnd;
|
||||
BOOL autoup;
|
||||
void *prev;
|
||||
void *next;
|
||||
void *first;
|
||||
void (*Refresh)(void *win);
|
||||
|
||||
s16 num;
|
||||
OAM *oam;
|
||||
GPU *gpu;
|
||||
} oamview_struct;
|
||||
|
||||
extern void InitOAMViewBox();
|
||||
oamview_struct *OamView_Init(HINSTANCE hInst, HWND parent);
|
||||
void OamView_Deinit(oamview_struct *OamView);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,272 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME 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.
|
||||
|
||||
DeSmuME 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 DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
#include "palView.h"
|
||||
#include "../MMU.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT PalView_OnPaint(u16 * adr, u16 num, HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
RECT rect;
|
||||
HBRUSH brush;
|
||||
u16 c;
|
||||
char tmp[80];
|
||||
|
||||
rect.left = 3;
|
||||
rect.top = 55;
|
||||
rect.right = 13;
|
||||
rect.bottom = 65;
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
if(adr)
|
||||
{
|
||||
u32 y;
|
||||
|
||||
for(y = 0; y < 16; ++y)
|
||||
{
|
||||
u32 x;
|
||||
|
||||
for(x = 0; x < 16; ++x)
|
||||
{
|
||||
c = adr[(y<<4)+x+0x100*num];
|
||||
brush = CreateSolidBrush(RGB((c&0x1F)<<3, (c&0x3E0)>>2, (c&0x7C00)>>7));
|
||||
FillRect(hdc, &rect, brush);
|
||||
DeleteObject(brush);
|
||||
rect.left += 11;
|
||||
rect.right += 11;
|
||||
}
|
||||
rect.top += 11;
|
||||
rect.bottom += 11;
|
||||
rect.left = 3;
|
||||
rect.right = 13;
|
||||
}
|
||||
sprintf(tmp, "Pal : %d", num);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), tmp);
|
||||
}
|
||||
else
|
||||
TextOut(hdc, 3, 55, "Pas de palette", 14);
|
||||
EndPaint(hwnd, &ps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
//ATTENTION null <20>Ela creation donc la boite ne doit pas être visible a la création
|
||||
palview_struct *win = (palview_struct *)GetWindowLong(hwnd, DWL_USER);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
HWND combo = GetDlgItem(hwnd, IDC_PAL_SELECT);
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen BG PAL");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen BG PAL");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen SPR PAL");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen SPR PAL");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 0");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 1");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 2");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 3");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 0");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 1");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 2");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 3");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 0");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 1");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 0");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 1");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 0");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 1");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 2");
|
||||
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 3");
|
||||
SendMessage(combo, CB_SETCURSEL, 0, 0);
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE);
|
||||
}
|
||||
return 1;
|
||||
case WM_CLOSE :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
PalView_Deinit(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case WM_PAINT:
|
||||
PalView_OnPaint(win->adr, win->palnum, hwnd, wParam, lParam);
|
||||
return 1;
|
||||
case WM_HSCROLL :
|
||||
switch LOWORD(wParam)
|
||||
{
|
||||
case SB_LINERIGHT :
|
||||
++(win->palnum);
|
||||
if(win->palnum>15)
|
||||
win->palnum = 15;
|
||||
break;
|
||||
case SB_LINELEFT :
|
||||
--(win->palnum);
|
||||
if(win->palnum<0)
|
||||
win->palnum = 0;
|
||||
break;
|
||||
}
|
||||
CWindow_Refresh(win);
|
||||
return 1;
|
||||
case WM_COMMAND :
|
||||
switch (LOWORD (wParam))
|
||||
{
|
||||
case IDC_FERMER :
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
PalView_Deinit(win);
|
||||
EndDialog(hwnd, 0);
|
||||
return 1;
|
||||
case IDC_AUTO_UPDATE :
|
||||
if(win->autoup)
|
||||
{
|
||||
CWindow_RemoveFromRefreshList(win);
|
||||
win->autoup = FALSE;
|
||||
return 1;
|
||||
}
|
||||
CWindow_AddToRefreshList(win);
|
||||
win->autoup = TRUE;
|
||||
return 1;
|
||||
case IDC_PAL_SELECT :
|
||||
switch(HIWORD(wParam))
|
||||
{
|
||||
case CBN_CLOSEUP :
|
||||
{
|
||||
u32 sel = SendMessage(GetDlgItem(hwnd, IDC_PAL_SELECT), CB_GETCURSEL, 0, 0);
|
||||
switch(sel)
|
||||
{
|
||||
case 0 :
|
||||
win->adr = (u16 *)ARM9Mem.ARM9_VMEM;
|
||||
win->palnum = 0;
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE);
|
||||
break;
|
||||
case 1 :
|
||||
win->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200;
|
||||
win->palnum = 0;
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE);
|
||||
break;
|
||||
case 2 :
|
||||
win->adr = (u16 *)ARM9Mem.ARM9_VMEM + 0x100;
|
||||
win->palnum = 0;
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE);
|
||||
break;
|
||||
case 3 :
|
||||
win->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300;
|
||||
win->palnum = 0;
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE);
|
||||
break;
|
||||
case 4 :
|
||||
case 5 :
|
||||
case 6 :
|
||||
case 7 :
|
||||
win->adr = ((u16 *)(ARM9Mem.ExtPal[0][sel-4]));
|
||||
win->palnum = 0;
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE);
|
||||
break;
|
||||
case 8 :
|
||||
case 9 :
|
||||
case 10 :
|
||||
case 11 :
|
||||
win->adr = ((u16 *)(ARM9Mem.ExtPal[1][sel-8]));
|
||||
win->palnum = 0;
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE);
|
||||
break;
|
||||
case 12 :
|
||||
case 13 :
|
||||
win->adr = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12]));
|
||||
win->palnum = 0;
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE);
|
||||
break;
|
||||
case 14 :
|
||||
case 15 :
|
||||
win->adr = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14]));
|
||||
win->palnum = 0;
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE);
|
||||
break;
|
||||
case 16 :
|
||||
case 17 :
|
||||
case 18 :
|
||||
case 19 :
|
||||
win->adr = ((u16 *)(ARM9Mem.texPalSlot[sel-16]));
|
||||
win->palnum = 0;
|
||||
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW);
|
||||
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE);
|
||||
break;
|
||||
default :
|
||||
return 1;
|
||||
}
|
||||
CWindow_Refresh(win);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
palview_struct *PalView_Init(HINSTANCE hInst, HWND parent)
|
||||
{
|
||||
palview_struct *PalView=NULL;
|
||||
|
||||
if ((PalView = (palview_struct *)malloc(sizeof(palview_struct))) == NULL)
|
||||
return PalView;
|
||||
|
||||
if (CWindow_Init2(PalView, hInst, parent, "Palette viewer", IDD_PAL, PalView_Proc) != 0)
|
||||
{
|
||||
free(PalView);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PalView->palnum = 0;
|
||||
PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM;
|
||||
|
||||
return PalView;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void PalView_Deinit(palview_struct *PalView)
|
||||
{
|
||||
if (PalView)
|
||||
free(PalView);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue