diff --git a/tags/release_0_5_0/desmume/AUTHORS b/tags/release_0_5_0/desmume/AUTHORS new file mode 100644 index 000000000..18d33d5ca --- /dev/null +++ b/tags/release_0_5_0/desmume/AUTHORS @@ -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 diff --git a/tags/release_0_5_0/desmume/COPYING b/tags/release_0_5_0/desmume/COPYING new file mode 100644 index 000000000..d60c31a97 --- /dev/null +++ b/tags/release_0_5_0/desmume/COPYING @@ -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. + + + Copyright (C) + + 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. + + , 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. diff --git a/tags/release_0_5_0/desmume/ChangeLog b/tags/release_0_5_0/desmume/ChangeLog new file mode 100644 index 000000000..d180a020b --- /dev/null +++ b/tags/release_0_5_0/desmume/ChangeLog @@ -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. diff --git a/tags/release_0_5_0/desmume/INSTALL b/tags/release_0_5_0/desmume/INSTALL new file mode 100644 index 000000000..e69de29bb diff --git a/tags/release_0_5_0/desmume/Makefile.am b/tags/release_0_5_0/desmume/Makefile.am new file mode 100644 index 000000000..af437a64d --- /dev/null +++ b/tags/release_0_5_0/desmume/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/tags/release_0_5_0/desmume/NEWS b/tags/release_0_5_0/desmume/NEWS new file mode 100644 index 000000000..e69de29bb diff --git a/tags/release_0_5_0/desmume/README b/tags/release_0_5_0/desmume/README new file mode 100644 index 000000000..e2d149c21 --- /dev/null +++ b/tags/release_0_5_0/desmume/README @@ -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. diff --git a/tags/release_0_5_0/desmume/README.LIN b/tags/release_0_5_0/desmume/README.LIN new file mode 100644 index 000000000..963c6e6c5 --- /dev/null +++ b/tags/release_0_5_0/desmume/README.LIN @@ -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. diff --git a/tags/release_0_5_0/desmume/README.WIN b/tags/release_0_5_0/desmume/README.WIN new file mode 100644 index 000000000..a6e1c2266 --- /dev/null +++ b/tags/release_0_5_0/desmume/README.WIN @@ -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. diff --git a/tags/release_0_5_0/desmume/TODO b/tags/release_0_5_0/desmume/TODO new file mode 100644 index 000000000..e69de29bb diff --git a/tags/release_0_5_0/desmume/autopackage/default.apspec.in b/tags/release_0_5_0/desmume/autopackage/default.apspec.in new file mode 100644 index 000000000..80f83f957 --- /dev/null +++ b/tags/release_0_5_0/desmume/autopackage/default.apspec.in @@ -0,0 +1,38 @@ +# -*-shell-script-*- + +[Meta] +RootName: @desmume.sf.net/desmume:$SOFTWAREVERSION +DisplayName: DeSmuME Nintendo DS Emulator +ShortName: desmume +Maintainer: Guillaume Duhamel +Packager: Guillaume Duhamel +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 diff --git a/tags/release_0_5_0/desmume/compile b/tags/release_0_5_0/desmume/compile new file mode 100755 index 000000000..1b1d23216 --- /dev/null +++ b/tags/release_0_5_0/desmume/compile @@ -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 . +# +# 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 or send patches to +# . + +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 . +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: diff --git a/tags/release_0_5_0/desmume/configure.ac b/tags/release_0_5_0/desmume/configure.ac new file mode 100644 index 000000000..99bd59643 --- /dev/null +++ b/tags/release_0_5_0/desmume/configure.ac @@ -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 diff --git a/tags/release_0_5_0/desmume/src/ARM9.h b/tags/release_0_5_0/desmume/src/ARM9.h new file mode 100644 index 000000000..464765b93 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/ARM9.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/Disassembler.c b/tags/release_0_5_0/desmume/src/Disassembler.c new file mode 100644 index 000000000..5f1e685a0 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/Disassembler.c @@ -0,0 +1,3692 @@ +/* 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 +#include +#include "Disassembler.h" +#include "bits.h" + +#define ROR(i, j) ((((u32)(i))>>(j)) | (((u32)(i))<<(32-(j)))) + +const char Condition[16][3] = { + "EQ", + "NE", + "CS", + "CC", + "MI", + "PL", + "VS", + "VC", + "HI", + "LS", + "GE", + "LT", + "GT", + "LE", + "", + "" + }; + +const char Registre[16][4] = { + "R0", + "R1", + "R2", + "R3", + "R4", + "R5", + "R6", + "R7", + "R8", + "R9", + "R10", + "R11", + "R12", + "SP", + "LR", + "PC", + }; + +const char MSR_FIELD[16][5] = { + "", + "c", + "x", + "xc", + "s", + "sc", + "sx", + "sxc", + "f", + "fc", + "fx", + "fxc", + "fs", + "fsc", + "fsx", + "fsxc" + }; + +#define DATAPROC_LSL_IMM(nom, s) char tmp[10] = "";\ + if(((i>>7)&0x1F)!=0)\ + sprintf(tmp, ", LSL #%X", (int)((i>>7)&0x1F));\ + sprintf(txt, "%s%s%s %s, %s, %s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + Registre[REG_POS(i,0)],\ + tmp); +#define DATAPROC_ROR_IMM(nom, s) char tmp[10] = "";\ + if(((i>>7)&0x1F)!=0)\ + sprintf(tmp, ", RRX");\ + sprintf(txt, "%s%s%s %s, %s, %s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + Registre[REG_POS(i,0)],\ + tmp\ + ); + +#define DATAPROC_REG_SHIFT(nom, shift,s) sprintf(txt, "%s%s%s %s, %s, %s, %s %s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + Registre[REG_POS(i,0)],\ + #shift,\ + Registre[REG_POS(i,8)]\ + ); + +#define DATAPROC_IMM_SHIFT(nom, shift, s) sprintf(txt, "%s%s%s %s, %s, %s, %s #%X",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + Registre[REG_POS(i,0)],\ + #shift,\ + (int)((i>>7)&0x1F)\ + ); + +#define DATAPROC_IMM_VALUE(nom,s) u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E);\ + sprintf(txt, "%s%s%s %s, %s, #%X",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + (int)shift_op\ + ); + +#define DATAPROC_ONE_OP_LSL_IMM(nom, s, v) char tmp[10] = "";\ + if(((i>>7)&0x1F)!=0)\ + sprintf(tmp, ", LSL #%X", (int)((i>>7)&0x1F));\ + sprintf(txt, "%s%s%s %s, %s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,v)],\ + Registre[REG_POS(i,0)],\ + tmp); + +#define DATAPROC_ONE_OP_ROR_IMM(nom, s, v) char tmp[10] = "";\ + if(((i>>7)&0x1F)==0)\ + sprintf(tmp, ", RRX");\ + else\ + sprintf(tmp, ", ROR %d", (int)((i>>7)&0x1F));\ + sprintf(txt, "%s%s%s %s, %s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,v)],\ + Registre[REG_POS(i,0)],\ + tmp\ + ); + +#define DATAPROC_ONE_OP_REG_SHIFT(nom, shift,s, v) sprintf(txt, "%s%s%s %s, %s, %s %s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,v)],\ + Registre[REG_POS(i,0)],\ + #shift,\ + Registre[REG_POS(i,8)]\ + ); + +#define DATAPROC_ONE_OP_IMM_SHIFT(nom, shift, s, v) sprintf(txt, "%s%s%s %s, %s, %s #%X",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,v)],\ + Registre[REG_POS(i,0)],\ + #shift,\ + (int)((i>>7)&0x1F)\ + ); + +#define DATAPROC_ONE_OP_IMM_VALUE(nom, s, v)\ + u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E);\ + sprintf(txt, "%s%s%s %s, #%X",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,v)],\ + (int)shift_op\ + ); + +#define SIGNEXTEND_24(i) (((i)&0xFFFFFF)|(0xFF000000*BIT23(i))) + +#define LDRSTR_LSL_IMM(nom, op, op2, op3) char tmp[10] = "";\ + if(((i>>7)&0x1F)!=0)\ + sprintf(tmp, ", LSL #%X", (int)((i>>7)&0x1F));\ + sprintf(txt, "%s%s %s, [%s%s, %s%s%s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + op2,\ + op,\ + Registre[REG_POS(i,0)],\ + tmp,\ + op3); +#define LDRSTR_ROR_IMM(nom, op, op2, op3) char tmp[10] = "";\ + if(((i>>7)&0x1F)!=0)\ + sprintf(tmp, ", RRX");\ + sprintf(txt, "%s%s %s, [%s%s, %s%s%s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + op2,\ + op,\ + Registre[REG_POS(i,0)],\ + tmp,\ + op3\ + ); + +#define LDRSTR_IMM_SHIFT(nom, shift, op, op2, op3)\ + sprintf(txt, "%s%s %s, [%s%s, %s%s, %s #%X%s",\ + #nom,\ + Condition[CONDITION(i)],\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + op2,\ + op,\ + Registre[REG_POS(i,0)],\ + #shift,\ + (int)((i>>7)&0x1F),\ + op3\ + ); + +#define RegList(nb) char lreg[100] = "";\ + int prec = 0;\ + int j;\ + for(j = 0; j < nb; j++)\ + {\ + if(prec)\ + {\ + if((!BIT_N(i, j+1))||(j==nb-1))\ + {\ + sprintf(lreg, "%s%s,", lreg, Registre[j]);\ + prec = 0;\ + }\ + }\ + else\ + {\ + if(BIT_N(i, j))\ + {\ + if((BIT_N(i, j+1))&&(j!=nb-1))\ + {\ + sprintf(lreg, "%s%s-", lreg, Registre[j]);\ + prec = 1;\ + }\ + else\ + sprintf(lreg, "%s%s,", lreg, Registre[j]);\ + }\ + }\ + }\ + lreg[strlen(lreg)-1]='\0'; + +static char * OP_UND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "----"); + return txt; +} + +//-----------------------AND------------------------------------ +static char * OP_AND_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(AND, ""); + return txt; +} + +static char * OP_AND_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, LSL, ""); + return txt; +} + +static char * OP_AND_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(AND, LSR, ""); + return txt; +} + +static char * OP_AND_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, LSR, ""); + return txt; +} + +static char * OP_AND_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(AND, ASR, ""); + return txt; +} + +static char * OP_AND_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, ASR, ""); + return txt; +} + +static char * OP_AND_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(AND, ""); + return txt; +} + +static char * OP_AND_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, ROR, ""); + return txt; +} + +static char * OP_AND_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(AND, ""); + return txt; +} + +static char * OP_AND_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(AND, "S"); + return txt; +} + +static char * OP_AND_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, LSL, "S"); + return txt; +} + +static char * OP_AND_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(AND, LSR, "S"); + return txt; +} + +static char * OP_AND_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, LSR, "S"); + return txt; +} + +static char * OP_AND_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(AND, ASR, "S"); + return txt; +} + +static char * OP_AND_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, ASR, "S"); + return txt; +} + +static char * OP_AND_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(AND, "S"); + return txt; +} + +static char * OP_AND_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, ROR, "S"); + return txt; +} + +static char * OP_AND_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(AND, "S"); + return txt; +} + +//--------------EOR------------------------------ +static char * OP_EOR_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(EOR, ""); + return txt; +} + +static char * OP_EOR_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, LSL, ""); + return txt; +} + +static char * OP_EOR_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(EOR, LSR, ""); + return txt; +} + +static char * OP_EOR_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, LSR, ""); + return txt; +} + +static char * OP_EOR_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(EOR, ASR, ""); + return txt; +} + +static char * OP_EOR_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, ASR, ""); + return txt; +} + +static char * OP_EOR_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(EOR, ""); + return txt; +} + +static char * OP_EOR_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, ROR, ""); + return txt; +} + +static char * OP_EOR_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(EOR, ""); + return txt; +} + +static char * OP_EOR_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(EOR, "S"); + return txt; +} + +static char * OP_EOR_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, LSL, "S"); + return txt; +} + +static char * OP_EOR_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(EOR, LSR, "S"); + return txt; +} + +static char * OP_EOR_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, LSR, "S"); + return txt; +} + +static char * OP_EOR_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(EOR, ASR, "S"); + return txt; +} + +static char * OP_EOR_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, ASR, "S"); + return txt; +} + +static char * OP_EOR_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(EOR, "S"); + return txt; +} + +static char * OP_EOR_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, ROR, "S"); + return txt; +} + +static char * OP_EOR_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(EOR, "S"); + return txt; +} + +//-------------SUB------------------------------------- + +static char * OP_SUB_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(SUB, ""); + return txt; +} + +static char * OP_SUB_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, LSL, ""); + return txt; +} + +static char * OP_SUB_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SUB, LSR, ""); + return txt; +} + +static char * OP_SUB_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, LSR, ""); + return txt; +} + +static char * OP_SUB_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SUB, ASR, ""); + return txt; +} + +static char * OP_SUB_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, ASR, ""); +return txt;} + +static char * OP_SUB_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(SUB, ""); +return txt;} + +static char * OP_SUB_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, ROR, ""); +return txt;} + +static char * OP_SUB_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(SUB, ""); +return txt;} + +static char * OP_SUB_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(SUB, "S"); +return txt;} + +static char * OP_SUB_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, LSL, "S"); +return txt;} + +static char * OP_SUB_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SUB, LSR, "S"); +return txt;} + +static char * OP_SUB_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, LSR, "S"); +return txt;} + +static char * OP_SUB_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SUB, ASR, "S"); +return txt;} + +static char * OP_SUB_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, ASR, "S"); +return txt;} + +static char * OP_SUB_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(SUB, "S"); +return txt;} + +static char * OP_SUB_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, ROR, "S"); +return txt;} + +static char * OP_SUB_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(SUB, "S"); +return txt;} + +//------------------RSB------------------------ + +static char * OP_RSB_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(RSB, ""); +return txt;} + +static char * OP_RSB_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, LSL, ""); +return txt;} + +static char * OP_RSB_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSB, LSR, ""); +return txt;} + +static char * OP_RSB_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, LSR, ""); +return txt;} + +static char * OP_RSB_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSB, ASR, ""); +return txt;} + +static char * OP_RSB_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, ASR, ""); +return txt;} + +static char * OP_RSB_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(RSB, ""); +return txt;} + +static char * OP_RSB_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, ROR, ""); +return txt;} + +static char * OP_RSB_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(RSB, ""); +return txt;} + +static char * OP_RSB_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(RSB, "S"); +return txt;} + +static char * OP_RSB_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, LSL, "S"); +return txt;} + +static char * OP_RSB_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSB, LSR, "S"); +return txt;} + +static char * OP_RSB_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, LSR, "S"); +return txt;} + +static char * OP_RSB_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSB, ASR, "S"); +return txt;} + +static char * OP_RSB_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, ASR, "S"); +return txt;} + +static char * OP_RSB_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(RSB, "S"); +return txt;} + +static char * OP_RSB_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, ROR, "S"); +return txt;} + +static char * OP_RSB_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(RSB, "S"); +return txt;} + +//------------------ADD----------------------------------- + +static char * OP_ADD_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ADD, ""); +return txt;} + +static char * OP_ADD_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, LSL, ""); +return txt;} + +static char * OP_ADD_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADD, LSR, ""); +return txt;} + +static char * OP_ADD_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, LSR, ""); +return txt;} + +static char * OP_ADD_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADD, ASR, ""); +return txt;} + +static char * OP_ADD_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, ASR, ""); +return txt;} + +static char * OP_ADD_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ADD, ""); +return txt;} + +static char * OP_ADD_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, ROR, ""); +return txt;} + +static char * OP_ADD_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ADD, ""); +return txt;} + +static char * OP_ADD_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ADD, "S"); +return txt;} + +static char * OP_ADD_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, LSL, "S"); +return txt;} + +static char * OP_ADD_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADD, LSR, "S"); +return txt;} + +static char * OP_ADD_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, LSR, "S"); +return txt;} + +static char * OP_ADD_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADD, ASR, "S"); +return txt;} + +static char * OP_ADD_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, ASR, "S"); +return txt;} + +static char * OP_ADD_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ADD, "S"); +return txt;} + +static char * OP_ADD_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, ROR, "S"); +return txt;} + +static char * OP_ADD_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ADD, "S"); +return txt;} + +//------------------ADC----------------------------------- + +static char * OP_ADC_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ADC, ""); +return txt;} + +static char * OP_ADC_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, LSL, ""); +return txt;} + +static char * OP_ADC_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADC, LSR, ""); +return txt;} + +static char * OP_ADC_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, LSR, ""); +return txt;} + +static char * OP_ADC_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADC, ASR, ""); +return txt;} + +static char * OP_ADC_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, ASR, ""); +return txt;} + +static char * OP_ADC_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ADC, ""); +return txt;} + +static char * OP_ADC_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, ROR, ""); +return txt;} + +static char * OP_ADC_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ADC, ""); +return txt;} + +static char * OP_ADC_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ADC, "S"); +return txt;} + +static char * OP_ADC_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, LSL, "S"); +return txt;} + +static char * OP_ADC_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADC, LSR, "S"); +return txt;} + +static char * OP_ADC_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, LSR, "S"); +return txt;} + +static char * OP_ADC_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADC, ASR, "S"); +return txt;} + +static char * OP_ADC_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, ASR, "S"); +return txt;} + +static char * OP_ADC_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ADC, "S"); +return txt;} + +static char * OP_ADC_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, ROR, "S"); +return txt;} + +static char * OP_ADC_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ADC, "S"); +return txt;} + +//-------------SBC------------------------------------- + +static char * OP_SBC_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(SBC, ""); +return txt;} + +static char * OP_SBC_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, LSL, ""); +return txt;} + +static char * OP_SBC_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SBC, LSR, ""); +return txt;} + +static char * OP_SBC_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, LSR, ""); +return txt;} + +static char * OP_SBC_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SBC, ASR, ""); +return txt;} + +static char * OP_SBC_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, ASR, ""); +return txt;} + +static char * OP_SBC_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(SBC, ""); +return txt;} + +static char * OP_SBC_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, ROR, ""); +return txt;} + +static char * OP_SBC_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(SBC, ""); +return txt;} + +static char * OP_SBC_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(SBC, "S"); +return txt;} + +static char * OP_SBC_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, LSL, "S"); +return txt;} + +static char * OP_SBC_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SBC, LSR, "S"); +return txt;} + +static char * OP_SBC_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, LSR, "S"); +return txt;} + +static char * OP_SBC_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SBC, ASR, "S"); +return txt;} + +static char * OP_SBC_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, ASR, "S"); +return txt;} + +static char * OP_SBC_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(SBC, "S"); +return txt;} + +static char * OP_SBC_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, ROR, "S"); +return txt;} + +static char * OP_SBC_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(SBC, "S"); +return txt;} + +//---------------RSC---------------------------------- + +static char * OP_RSC_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(RSC, ""); +return txt;} + +static char * OP_RSC_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, LSL, ""); +return txt;} + +static char * OP_RSC_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSC, LSR, ""); +return txt;} + +static char * OP_RSC_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, LSR, ""); +return txt;} + +static char * OP_RSC_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSC, ASR, ""); +return txt;} + +static char * OP_RSC_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, ASR, ""); +return txt;} + +static char * OP_RSC_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(RSC, ""); +return txt;} + +static char * OP_RSC_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, ROR, ""); +return txt;} + +static char * OP_RSC_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(RSC, ""); +return txt;} + +static char * OP_RSC_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(RSC, "S"); +return txt;} + +static char * OP_RSC_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, LSL, "S"); +return txt;} + +static char * OP_RSC_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSC, LSR, "S"); +return txt;} + +static char * OP_RSC_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, LSR, "S"); +return txt;} + +static char * OP_RSC_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSC, ASR, "S"); +return txt;} + +static char * OP_RSC_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, ASR, "S"); +return txt;} + +static char * OP_RSC_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(RSC, "S"); +return txt;} + +static char * OP_RSC_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, ROR, "S"); +return txt;} + +static char * OP_RSC_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(RSC, "S"); +return txt;} + +//-------------------TST---------------------------- + +static char * OP_TST_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(TST, "", 16); +return txt;} + +static char * OP_TST_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TST, LSL, "", 16); +return txt;} + +static char * OP_TST_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(TST, LSR, "", 16); +return txt;} + +static char * OP_TST_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TST, LSR, "", 16); +return txt;} + +static char * OP_TST_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(TST, ASR, "", 16); +return txt;} + +static char * OP_TST_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TST, ASR, "", 16); +return txt;} + +static char * OP_TST_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(TST, "", 16); +return txt;} + +static char * OP_TST_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TST, ROR, "", 16); +return txt;} + +static char * OP_TST_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(TST, "", 16); +return txt;} + +//-------------------TEQ---------------------------- + +static char * OP_TEQ_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(TEQ, "", 16); +return txt;} + +static char * OP_TEQ_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TEQ, LSL, "", 16); +return txt;} + +static char * OP_TEQ_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(TEQ, LSR, "", 16); +return txt;} + +static char * OP_TEQ_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TEQ, LSR, "", 16); +return txt;} + +static char * OP_TEQ_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(TEQ, ASR, "", 16); +return txt;} + +static char * OP_TEQ_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TEQ, ASR, "", 16); +return txt;} + +static char * OP_TEQ_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(TEQ, "", 16); +return txt;} + +static char * OP_TEQ_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TEQ, ROR, "", 16); +return txt;} + +static char * OP_TEQ_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(TEQ, "", 16); +return txt;} + +//-------------CMP------------------------------------- + +static char * OP_CMP_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(CMP, "", 16); +return txt;} + +static char * OP_CMP_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMP, LSL, "", 16); +return txt;} + +static char * OP_CMP_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(CMP, LSR, "", 16); +return txt;} + +static char * OP_CMP_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMP, LSR, "", 16); +return txt;} + +static char * OP_CMP_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(CMP, ASR, "", 16); +return txt;} + +static char * OP_CMP_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMP, ASR, "", 16); +return txt;} + +static char * OP_CMP_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(CMP, "", 16); +return txt;} + +static char * OP_CMP_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMP, ROR, "", 16); +return txt;} + +static char * OP_CMP_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(CMP, "", 16); +return txt;} + +//---------------CMN--------------------------- + +static char * OP_CMN_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(CMN, "", 16); +return txt;} + +static char * OP_CMN_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMN, LSL, "", 16); +return txt;} + +static char * OP_CMN_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(CMP, ASR, "", 16); +return txt;} + +static char * OP_CMN_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMN, LSR, "", 16); +return txt;} + +static char * OP_CMN_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(CMN, ASR, "", 16); +return txt;} + +static char * OP_CMN_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMN, ASR, "", 16); +return txt;} + +static char * OP_CMN_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(CMN, "", 16); +return txt;} + +static char * OP_CMN_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMN, ROR, "", 16); +return txt;} + +static char * OP_CMN_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(CMN, "", 16); +return txt;} + +//------------------ORR------------------- + +static char * OP_ORR_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ORR, ""); +return txt;} + +static char * OP_ORR_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, LSL, ""); +return txt;} + +static char * OP_ORR_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ORR, LSR, ""); +return txt;} + +static char * OP_ORR_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, LSR, ""); +return txt;} + +static char * OP_ORR_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ORR, ASR, ""); +return txt;} + +static char * OP_ORR_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, ASR, ""); +return txt;} + +static char * OP_ORR_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ORR, ""); +return txt;} + +static char * OP_ORR_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, ROR, ""); +return txt;} + +static char * OP_ORR_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ORR, ""); +return txt;} + +static char * OP_ORR_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ORR, "S"); +return txt;} + +static char * OP_ORR_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, LSL, "S"); +return txt;} + +static char * OP_ORR_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ORR, LSR, "S"); +return txt;} + +static char * OP_ORR_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, LSR, "S"); +return txt;} + +static char * OP_ORR_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ORR, ASR, "S"); +return txt;} + +static char * OP_ORR_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, ASR, "S"); +return txt;} + +static char * OP_ORR_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ORR, "S"); +return txt;} + +static char * OP_ORR_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, ROR, "S"); +return txt;} + +static char * OP_ORR_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ORR, "S"); +return txt;} + +//------------------MOV------------------- + +static char * OP_MOV_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(MOV, "", 12); +return txt;} + +static char * OP_MOV_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, LSL, "", 12); +return txt;} + +static char * OP_MOV_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MOV, LSR, "", 12); +return txt;} + +static char * OP_MOV_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, LSR, "", 12); +return txt;} + +static char * OP_MOV_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MOV, ASR, "", 12); +return txt;} + +static char * OP_MOV_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, ASR, "", 12); +return txt;} + +static char * OP_MOV_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(MOV, "", 12); +return txt;} + +static char * OP_MOV_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, ROR, "", 12); +return txt;} + +static char * OP_MOV_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(MOV, "", 12); +return txt;} + +static char * OP_MOV_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(MOV, "S", 12); +return txt;} + +static char * OP_MOV_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, LSL, "S", 12); +return txt;} + +static char * OP_MOV_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MOV, LSR, "S", 12); +return txt;} + +static char * OP_MOV_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, LSR, "S", 12); +return txt;} + +static char * OP_MOV_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MOV, ASR, "S", 12); +return txt;} + +static char * OP_MOV_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, ASR, "S", 12); +return txt;} + +static char * OP_MOV_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(MOV, "S", 12); +return txt;} + +static char * OP_MOV_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, ROR, "S", 12); +return txt;} + +static char * OP_MOV_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(MOV, "S", 12); +return txt;} + +//------------------BIC------------------- + +static char * OP_BIC_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(BIC, ""); +return txt;} + +static char * OP_BIC_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, LSL, ""); +return txt;} + +static char * OP_BIC_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(BIC, LSR, ""); +return txt;} + +static char * OP_BIC_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, LSR, ""); +return txt;} + +static char * OP_BIC_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(BIC, ASR, ""); +return txt;} + +static char * OP_BIC_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, ASR, ""); +return txt;} + +static char * OP_BIC_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(BIC, ""); +return txt;} + +static char * OP_BIC_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, ROR, ""); +return txt;} + +static char * OP_BIC_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(BIC, ""); +return txt;} + +static char * OP_BIC_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(BIC, "S"); +return txt;} + +static char * OP_BIC_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, LSL, "S"); +return txt;} + +static char * OP_BIC_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(BIC, LSR, "S"); +return txt;} + +static char * OP_BIC_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, LSR, "S"); +return txt;} + +static char * OP_BIC_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(BIC, ASR, "S"); +return txt;} + +static char * OP_BIC_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, ASR, "S"); +return txt;} + +static char * OP_BIC_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(BIC, "S"); +return txt;} + +static char * OP_BIC_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, ROR, "S"); +return txt;} + +static char * OP_BIC_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(BIC, "S"); +return txt;} + +//------------------MVN------------------- + +static char * OP_MVN_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(MVN, "", 12); +return txt;} + +static char * OP_MVN_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, LSL, "", 12); +return txt;} + +static char * OP_MVN_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MVN, LSR, "", 12); +return txt;} + +static char * OP_MVN_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, LSR, "", 12); +return txt;} + +static char * OP_MVN_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MVN, ASR, "", 12); +return txt;} + +static char * OP_MVN_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, ASR, "", 12); +return txt;} + +static char * OP_MVN_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(MVN, "", 12); +return txt;} + +static char * OP_MVN_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, ROR, "", 12); +return txt;} + +static char * OP_MVN_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(MVN, "", 12); +return txt;} + +static char * OP_MVN_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(MVN, "S", 12); +return txt;} + +static char * OP_MVN_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, LSL, "S", 12); +return txt;} + +static char * OP_MVN_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MVN, LSR, "S", 12); +return txt;} + +static char * OP_MVN_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, LSR, "S", 12); +return txt;} + +static char * OP_MVN_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MOV, ASR, "S", 12); +return txt;} + +static char * OP_MVN_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, ASR, "S", 12); +return txt;} + +static char * OP_MVN_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(MVN, "S", 12); +return txt;} + +static char * OP_MVN_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, ROR, "S", 12); +return txt;} + +static char * OP_MVN_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(MVN, "S", 12); +return txt;} + + +//-------------MUL------------------------ + +static char * OP_MUL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MUL%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_MLA(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MLA%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_MUL_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MUL%sS %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_MLA_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MLA%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + + +//----------UMUL-------------------------- + +static char * OP_UMULL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "UMULL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_UMLAL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "UMLAL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_UMULL_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "UMULL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_UMLAL_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "UMLAL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +//----------SMUL-------------------------- + +static char * OP_SMULL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMLAL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLAL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMULL_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMLAL_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLAL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +//---------------SWP------------------------------ + +static char * OP_SWP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SWP%s %s, %s, [%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +static char * OP_SWPB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SWPB%s %s, %s, [%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +//------------LDRH----------------------------- + +static char * OP_LDRH_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRH_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRH_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRH_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRH_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRH_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +//------------STRH----------------------------- + +static char * OP_STRH_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_STRH_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_STRH_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_STRH_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_STRH_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_STRH_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +//----------------LDRSH-------------------------- + +static char * OP_LDRSH_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSH_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSH_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSH_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSH_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSH_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +//----------------------LDRSB---------------------- + +static char * OP_LDRSB_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSB_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSB_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSB_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSB_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSB_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +//--------------MRS-------------------------------- + +static char * OP_MRS_CPSR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MRS%s %s, CPSR", Condition[CONDITION(i)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_MRS_SPSR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MRS%s %s, SPSR", Condition[CONDITION(i)], Registre[REG_POS(i,12)]); +return txt;} + +//--------------MSR-------------------------------- + +static char * OP_MSR_CPSR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MSR%s CPSR_%s, %s", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_MSR_SPSR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MSR%s SPSR_%s, %s", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_MSR_CPSR_IMM_VAL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MSR%s CPSR_%s, #%X", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], (int)ROR((i&0xFF), ((i>>7)&0x1E))); +return txt;} + +static char * OP_MSR_SPSR_IMM_VAL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MSR%s SPSR_%s, #%X", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], (int)ROR((i&0xFF), (i>>7)&0x1E)); +return txt;} + +//-----------------BRANCH-------------------------- + +static char * OP_BX(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BX%s %s", Condition[CONDITION(i)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_BLX_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BLX%s %s", Condition[CONDITION(i)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_B(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "BLX%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+8)); + return txt;} + sprintf(txt, "B%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+8)); +return txt;} + +static char * OP_BL(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "BLX%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+10)); + return txt;} + sprintf(txt, "BL%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+8)); +return txt;} + +//----------------CLZ------------------------------- + +static char * OP_CLZ(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "CLZ%s %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)]); +return txt;} + + +//--------------------QADD--QSUB------------------------------ + +static char * OP_QADD(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "QADD%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +static char * OP_QSUB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "QSUB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +static char * OP_QDADD(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "QDADD%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +static char * OP_QDSUB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "QDSUB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +//-----------------SMUL------------------------------- + +static char * OP_SMUL_B_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULBB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMUL_B_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULBT%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMUL_T_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULTB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMUL_T_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULTT%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +//-----------SMLA---------------------------- + +static char * OP_SMLA_B_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLABB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_SMLA_B_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLABT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_SMLA_T_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLATB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_SMLA_T_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLATT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +//--------------SMLAL--------------------------------------- + +static char * OP_SMLAL_B_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLABB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMLAL_B_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLABT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMLAL_T_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLATB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMLAL_T_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLATT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +//--------------SMULW-------------------- + +static char * OP_SMULW_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULWB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMULW_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULWT%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +//--------------SMLAW------------------- +static char * OP_SMLAW_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLAWB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_SMLAW_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLAWT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +//------------LDR--------------------------- + +static char * OP_LDR_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDR_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDR_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "", "", "]"); +return txt;} + +static char * OP_LDR_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "-", "", "]"); +return txt;} + +static char * OP_LDR_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "", "", "]"); +return txt;} + +static char * OP_LDR_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "M", "", "]"); +return txt;} + +static char * OP_LDR_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "", "", "]"); +return txt;} + +static char * OP_LDR_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "-", "", "]"); +return txt;} + +static char * OP_LDR_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "", "", "]"); +return txt;} + +static char * OP_LDR_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "-", "", "]"); +return txt;} + +static char * OP_LDR_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDR_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDR_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "", "", "]!"); +return txt;} + +static char * OP_LDR_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "-", "", "]!"); +return txt;} + +static char * OP_LDR_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "", "", "]!"); +return txt;} + +static char * OP_LDR_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "-", "", "]!"); +return txt;} + +static char * OP_LDR_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "", "", "]!"); +return txt;} + +static char * OP_LDR_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "-", "", "]!"); +return txt;} + +static char * OP_LDR_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "", "", "]!"); +return txt;} + +static char * OP_LDR_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "-", "", "]!"); +return txt;} + +static char * OP_LDR_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDR_P_IMM_OFF_POSTIND2(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDR_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDR_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "", "]", ""); +return txt;} + +static char * OP_LDR_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "-", "]", ""); +return txt;} + +static char * OP_LDR_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "", "]", ""); +return txt;} + +static char * OP_LDR_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "-", "]", ""); +return txt;} + +static char * OP_LDR_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "", "]", ""); +return txt;} + +static char * OP_LDR_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "-", "]", ""); +return txt;} + +static char * OP_LDR_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "", "]", ""); +return txt;} + +static char * OP_LDR_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "-", "]", ""); +return txt;} + +//-----------------LDRB------------------------------------------- + +static char * OP_LDRB_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDRB_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDRB_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "", "", "]"); +return txt;} + +static char * OP_LDRB_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "-", "", "]"); +return txt;} + +static char * OP_LDRB_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "", "", "]"); +return txt;} + +static char * OP_LDRB_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "M", "", "]"); +return txt;} + +static char * OP_LDRB_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "", "", "]"); +return txt;} + +static char * OP_LDRB_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "-", "", "]"); +return txt;} + +static char * OP_LDRB_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "", "", "]"); +return txt;} + +static char * OP_LDRB_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "-", "", "]"); +return txt;} + +static char * OP_LDRB_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDRB_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDRB_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "", "", "]!"); +return txt;} + +static char * OP_LDRB_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "-", "", "]!"); +return txt;} + +static char * OP_LDRB_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "", "", "]!"); +return txt;} + +static char * OP_LDRB_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "-", "", "]!"); +return txt;} + +static char * OP_LDRB_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "", "", "]!"); +return txt;} + +static char * OP_LDRB_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "-", "", "]!"); +return txt;} + +static char * OP_LDRB_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "", "", "]!"); +return txt;} + +static char * OP_LDRB_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "-", "", "]!"); +return txt;} + +static char * OP_LDRB_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDRB_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDRB_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "", "]", ""); +return txt;} + +static char * OP_LDRB_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "-", "]", ""); +return txt;} + +static char * OP_LDRB_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "", "]", ""); +return txt;} + +static char * OP_LDRB_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "-", "]", ""); +return txt;} + +static char * OP_LDRB_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "", "]", ""); +return txt;} + +static char * OP_LDRB_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "-", "]", ""); +return txt;} + +static char * OP_LDRB_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "", "]", ""); +return txt;} + +static char * OP_LDRB_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "-", "]", ""); +return txt;} + +//----------------------STR-------------------------------- + +static char * OP_STR_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STR_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STR_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "", "", "]"); +return txt;} + +static char * OP_STR_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "-", "", "]"); +return txt;} + +static char * OP_STR_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "", "", "]"); +return txt;} + +static char * OP_STR_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "M", "", "]"); +return txt;} + +static char * OP_STR_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "", "", "]"); +return txt;} + +static char * OP_STR_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "-", "", "]"); +return txt;} + +static char * OP_STR_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "", "", "]"); +return txt;} + +static char * OP_STR_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "-", "", "]"); +return txt;} + +static char * OP_STR_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STR_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STR_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "", "", "]!"); +return txt;} + +static char * OP_STR_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "-", "", "]!"); +return txt;} + +static char * OP_STR_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "", "", "]!"); +return txt;} + +static char * OP_STR_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "-", "", "]!"); +return txt;} + +static char * OP_STR_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "", "", "]!"); +return txt;} + +static char * OP_STR_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "-", "", "]!"); +return txt;} + +static char * OP_STR_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "", "", "]!"); +return txt;} + +static char * OP_STR_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "-", "", "]!"); +return txt;} + +static char * OP_STR_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STR_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STR_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "", "]", ""); +return txt;} + +static char * OP_STR_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "-", "]", ""); +return txt;} + +static char * OP_STR_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "", "]", ""); +return txt;} + +static char * OP_STR_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "-", "]", ""); +return txt;} + +static char * OP_STR_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "", "]", ""); +return txt;} + +static char * OP_STR_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "-", "]", ""); +return txt;} + +static char * OP_STR_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "", "]", ""); +return txt;} + +static char * OP_STR_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "-", "]", ""); +return txt;} + +//-----------------------STRB------------------------------------- + +static char * OP_STRB_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STRB_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STRB_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "", "", "]"); +return txt;} + +static char * OP_STRB_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "-", "", "]"); +return txt;} + +static char * OP_STRB_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "", "", "]"); +return txt;} + +static char * OP_STRB_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "M", "", "]"); +return txt;} + +static char * OP_STRB_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "", "", "]"); +return txt;} + +static char * OP_STRB_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "-", "", "]"); +return txt;} + +static char * OP_STRB_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "", "", "]"); +return txt;} + +static char * OP_STRB_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "-", "", "]"); +return txt;} + +static char * OP_STRB_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STRB_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STRB_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "", "", "]!"); +return txt;} + +static char * OP_STRB_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "-", "", "]!"); +return txt;} + +static char * OP_STRB_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "", "", "]!"); +return txt;} + +static char * OP_STRB_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "-", "", "]!"); +return txt;} + +static char * OP_STRB_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "", "", "]!"); +return txt;} + +static char * OP_STRB_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "-", "", "]!"); +return txt;} + +static char * OP_STRB_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "", "", "]!"); +return txt;} + +static char * OP_STRB_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "-", "", "]!"); +return txt;} + +static char * OP_STRB_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STRB_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STRB_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "", "]", ""); +return txt;} + +static char * OP_STRB_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "-", "]", ""); +return txt;} + +static char * OP_STRB_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "", "]", ""); +return txt;} + +static char * OP_STRB_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "-", "]", ""); +return txt;} + +static char * OP_STRB_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "", "]", ""); +return txt;} + +static char * OP_STRB_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "-", "]", ""); +return txt;} + +static char * OP_STRB_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "", "]", ""); +return txt;} + +static char * OP_STRB_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "-", "]", ""); +return txt;} + +//-----------------------LDRBT------------------------------------- + +static char * OP_LDRBT_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRBT%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDRBT_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRBT%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_LDRBT_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRBT, "", "]", ""); +return txt;} + +static char * OP_LDRBT_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRBT, "-", "]", ""); +return txt;} + +static char * OP_LDRBT_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRBT, LSR, "", "]", ""); +return txt;} + +static char * OP_LDRBT_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRBT, LSR, "-", "]", ""); +return txt;} + +static char * OP_LDRBT_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRBT, ASR, "", "]", ""); +return txt;} + +static char * OP_LDRBT_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRBT, ASR, "-", "]", ""); +return txt;} + +static char * OP_LDRBT_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRBT, "", "]", ""); +return txt;} + +static char * OP_LDRBT_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRBT, "-", "]", ""); +return txt;} + +//----------------------STRBT---------------------------- + +static char * OP_STRBT_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRBT%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STRBT_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRBT%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0xFF)); +return txt;} + +static char * OP_STRBT_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRBT, "", "]", ""); +return txt;} + +static char * OP_STRBT_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRBT, "-", "]", ""); +return txt;} + +static char * OP_STRBT_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRBT, LSR, "", "]", ""); +return txt;} + +static char * OP_STRBT_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRBT, LSR, "-", "]", ""); +return txt;} + +static char * OP_STRBT_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRBT, ASR, "", "]", ""); +return txt;} + +static char * OP_STRBT_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRBT, ASR, "-", "]", ""); +return txt;} + +static char * OP_STRBT_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRBT, "", "]", ""); +return txt;} + +static char * OP_STRBT_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRBT, "-", "]", ""); +return txt;} + +//---------------------LDM----------------------------- + +static char * OP_LDMIA(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIB(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDA(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDB(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIA_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIB_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDA_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDB_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIA2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIB2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDA2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDB2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIA2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIA%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); +return txt;} + +static char * OP_LDMIB2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIB%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); +return txt;} + +static char * OP_LDMDA2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDA%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); +return txt;} + +static char * OP_LDMDB2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDB%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); +return txt;} + +//------------------------------STM---------------------------------- + +static char * OP_STMIA(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIB(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDA(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDB(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIA_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIB_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDA_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDB_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIA2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIB2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDA2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDB2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIA2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIA%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIB2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIB%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDA2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDA%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + return txt; +} + +static char * OP_STMDB2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDB%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + return txt; +} + +//---------------------STC---------------------------------- + +static char * OP_STC_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s, #%X]", (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)],(int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s %X, CP%X, [%s, #%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)],(int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s, #-%X]",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)],(int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s, #-%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_P_PREIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s, #%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s, #%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_M_PREIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s, #-%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s, #-%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_P_POSTIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s], #%X",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s], #%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_M_POSTIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s], #-%X",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s], #-%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_OPTION(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s], {%X}",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s], {%X}",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); + return txt; +} + +//---------------------LDC---------------------------------- + +static char * OP_LDC_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s, #%X]",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s, #%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s, #-%X]",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s, #-%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_P_PREIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s, #%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s, #%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_M_PREIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s, #-%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s, #-%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_P_POSTIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s], #%X",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s], #%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_M_POSTIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s], #-%X", (int)REG_POS(i, 8), (int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s], #-%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_OPTION(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s], {%X}", (int)REG_POS(i, 8), (int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s], {%X}",Condition[CONDITION(i)], (int)REG_POS(i, 8), (int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); + return txt; +} + +//----------------MCR----------------------- + +static char * OP_MCR(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "MCR2 CP%d, %X, %s, CR%d, CR%d, %X",(int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); + return txt; + } + sprintf(txt, "MCR%s CP%d, %X, %s, CR%d, CR%d, %X",Condition[CONDITION(i)], (int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); + return txt; +} + +//----------------MRC----------------------- + +static char * OP_MRC(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "MRC2 CP%d, %X, %s, CR%d, CR%d, %X",(int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); + return txt; + } + sprintf(txt, "MRC%s CP%d, %X, %s, CR%d, CR%d, %X",Condition[CONDITION(i)], (int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); + return txt; +} + +//--------------SWI-------------------------- + +static char * OP_SWI(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SWI%s %X",Condition[CONDITION(i)], (int)((i&0xFFFFFF)>>16)); + return txt; +} + +//----------------BKPT------------------------- +static char * OP_BKPT(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BKPT #%X",(int)(((i>>4)&0xFFF)|(i&0xF))); + return txt; +} + +//----------------CDP----------------------- + +char * OP_CDP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "CDP-------------------------------"); + return txt; +} + +//------------------------------------------------------------ +// THUMB +//------------------------------------------------------------ +#define REG_NUM(i, n) (((i)>>n)&0x7) + +static char * OP_UND_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "----"); + return txt; +} + +static char * OP_LSL_0(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSL %s, %s, #0", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_LSL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSL %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6) & 0x1F)); + return txt; +} + +static char * OP_LSR_0(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSR %s, %s, #0", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_LSR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSR %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6) & 0x1F)); + return txt; +} + +static char * OP_ASR_0(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ASR %s, %s, #0", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ASR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ASR %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6) & 0x1F)); + return txt; +} + +static char * OP_ADD_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD %s, %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_SUB_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SUB %s, %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_ADD_IMM3(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)REG_NUM(i, 6)); + return txt; +} + +static char * OP_SUB_IMM3(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SUB %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)REG_NUM(i, 6)); + return txt; +} + +static char * OP_MOV_IMM8(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MOV %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); + return txt; +} + +static char * OP_CMP_IMM8(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "CMP %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); + return txt; +} + +static char * OP_ADD_IMM8(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); + return txt; +} + +static char * OP_SUB_IMM8(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SUB %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); + return txt; +} + +static char * OP_AND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "AND %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_EOR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "EOR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_LSL_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSL %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_LSR_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ASR_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ASR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ADC_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADC %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_SBC_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SBC %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ROR_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ROR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_TST(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "TST %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_NEG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "NEG %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_CMP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "CMP %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_CMN(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "CMN %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ORR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ORR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_MUL_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MUL %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_BIC(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BIC %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_MVN(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MVN %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ADD_SPE(u32 adr, u32 i, char * txt) +{ + u8 Rd = (i&7) | ((i>>4)&8); + sprintf(txt, "ADD %s, %s", Registre[Rd], Registre[REG_POS(i, 3)]); + return txt; +} + +static char * OP_CMP_SPE(u32 adr, u32 i, char * txt) +{ + u8 Rd = (i&7) | ((i>>4)&8); + sprintf(txt, "CMP %s, %s", Registre[Rd], Registre[REG_POS(i, 3)]); + return txt; +} + +static char * OP_MOV_SPE(u32 adr, u32 i, char * txt) +{ + u8 Rd = (i&7) | ((i>>4)&8); + sprintf(txt, "MOV %s, %s", Registre[Rd], Registre[REG_POS(i, 3)]); + return txt; +} + +static char * OP_BX_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BX %s", Registre[REG_POS(i, 3)]); + return txt; +} + +static char * OP_BLX_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BLX %s", Registre[REG_POS(i, 3)]); + return txt; +} + +static char * OP_LDR_PCREL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR %s, [PC, #%X]", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STR_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_STRH_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_STRB_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_LDRSB_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_LDR_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_LDRH_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_LDRB_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_LDRSH_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_STR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>4)&0x7C)); + return txt; +} + +static char * OP_LDR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>4)&0x7C)); + return txt; +} + +static char * OP_STRB_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6)&0x1F)); + return txt; +} + +static char * OP_LDRB_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6)&0x1F)); + return txt; +} + +static char * OP_STRH_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>5)&0x3E)); + return txt; +} + +static char * OP_LDRH_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>5)&0x3E)); + return txt; +} + +static char * OP_STR_SPREL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR %s, [SP, #%X]", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDR_SPREL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR %s, [SP, #%X]", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_ADD_2PC(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD %s, PC, #%X", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_ADD_2SP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD %s, SP, #%X", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_ADJUST_P_SP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD SP, #%X", (int)((i&0x7F)<<2)); + return txt; +} + +static char * OP_ADJUST_M_SP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SUB SP, #%X", (int)((i&0x7F)<<2)); + return txt; +} + +static char * OP_PUSH(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "PUSH {%s}", lreg); + return txt; +} + +static char * OP_PUSH_LR(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "PUSH {%s, LR}", lreg); + return txt; +} + +static char * OP_POP(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "POP {%s}", lreg); + return txt; +} + +static char * OP_POP_PC(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "POP {%s, PC}", lreg); + return txt; +} + +static char * OP_BKPT_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BKPT"); + return txt; +} + +static char * OP_STMIA_THUMB(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "STMIA %s!, {%s}", Registre[REG_NUM(i, 8)], lreg); + return txt; +} + +static char * OP_LDMIA_THUMB(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "LDMIA %s!, {%s}", Registre[REG_NUM(i, 8)], lreg); + return txt; +} + +static char * OP_B_COND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "B%s #%X", Condition[(i>>8)&0xF], (int)(adr+(((signed long)((signed char)(i&0xFF)))<<1)+4)); + return txt; +} + +static char * OP_SWI_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SWI #%X", (int)(i & 0xFF)); + return txt; +} + +#define SIGNEEXT_IMM11(i) (((i)&0x7FF) | (BIT10(i) * 0xFFFFF800)) + +static char * OP_B_UNCOND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "B #%X", (int)(adr+(SIGNEEXT_IMM11(i)<<1)+4)); + return txt; +} + +u32 part = 0; + +static char * OP_BLX(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BLX #%X", (int)(part + ((i&0x7FF)<<1))&0xFFFFFFFC); + return txt; +} + +static char * OP_BL_10(u32 adr, u32 i, char * txt) +{ + part = adr+4 + (SIGNEEXT_IMM11(i)<<12); + sprintf(txt, "CALCUL LA PARTIE HAUTE DE L'ADRESSE"); + return txt; + +} + +static char * OP_BL_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BL #%X", (int)(part + ((i&0x7FF)<<1))&0xFFFFFFFC); + return txt; +} + +#define TYPE_RETOUR char * +#define PARAMETRES u32 adr, u32 i, char * txt +#define CALLTYPE +#define NOM_TAB des_arm_instructions_set +#define NOM_THUMB_TAB des_thumb_instructions_set + +#include "instruction_tabdef.inc" +#include "thumb_tabdef.inc" + diff --git a/tags/release_0_5_0/desmume/src/Disassembler.h b/tags/release_0_5_0/desmume/src/Disassembler.h new file mode 100644 index 000000000..367b070b3 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/Disassembler.h @@ -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 + + diff --git a/tags/release_0_5_0/desmume/src/FIFO.c b/tags/release_0_5_0/desmume/src/FIFO.c new file mode 100644 index 000000000..b49de3c87 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/FIFO.c @@ -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; +} diff --git a/tags/release_0_5_0/desmume/src/FIFO.h b/tags/release_0_5_0/desmume/src/FIFO.h new file mode 100644 index 000000000..0bc6eb095 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/FIFO.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/GPU.c b/tags/release_0_5_0/desmume/src/GPU.c new file mode 100644 index 000000000..2c428160d --- /dev/null +++ b/tags/release_0_5_0/desmume/src/GPU.c @@ -0,0 +1,1374 @@ +/* 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 +*/ + +#include +#include + +#include "GPU.h" +#include "debug.h" + +ARM9_struct ARM9Mem; + +extern BOOL click; +Screen MainScreen; +Screen SubScreen; + +//#define DEBUG_TRI + +u8 GPU_screen[4*256*192]; + +short sizeTab[4][4][2] = +{ + {{256,256}, {512, 256}, {256, 512}, {512, 512}}, + {{128,128}, {256, 256}, {512, 512}, {1024, 1024}}, +// {{128,128}, {256, 256}, {512, 256}, {512, 512}}, + {{512,1024}, {1024, 512}, {0, 0}, {0, 0}}, + {{0, 0}, {0, 0}, {0, 0}, {0, 0}} +}; + +size sprSizeTab[4][4] = +{ + {{8, 8}, {16, 8}, {8, 16}, {8, 8}}, + {{16, 16}, {32, 8}, {8, 32}, {8, 8}}, + {{32, 32}, {32, 16}, {16, 32}, {8, 8}}, + {{64, 64}, {64, 32}, {32, 64}, {8, 8}}, +}; + +s8 mode2type[8][4] = +{ + {0, 0, 0, 0}, + {0, 0, 0, 1}, + {0, 0, 1, 1}, + {0, 0, 0, 1}, + {0, 0, 1, 1}, + {0, 0, 1, 1}, + {3, 3, 2, 3}, + {0, 0, 0, 0} +}; + +void lineText(GPU * gpu, u8 num, u16 l, u8 * DST); +void lineRot(GPU * gpu, u8 num, u16 l, u8 * DST); +void lineExtRot(GPU * gpu, u8 num, u16 l, u8 * DST); + +void (*modeRender[8][4])(GPU * gpu, u8 num, u16 l, u8 * DST)= +{ + {lineText, lineText, lineText, lineText}, //0 + {lineText, lineText, lineText, lineRot}, //1 + {lineText, lineText, lineRot, lineRot}, //2 + {lineText, lineText, lineText, lineExtRot}, //3 + {lineText, lineText, lineRot, lineExtRot}, //4 + {lineText, lineText, lineExtRot, lineExtRot}, //5 + {lineText, lineText, lineText, lineText}, //6 + {lineText, lineText, lineText, lineText}, //7 +}; + +GPU * GPU_Init(u8 l) +{ + GPU * g; + + if ((g = (GPU *) malloc(sizeof(GPU))) == NULL) + return NULL; + + GPU_Reset(g, l); + + return g; +} + +void GPU_Reset(GPU *g, u8 l) +{ + memset(g, 0, sizeof(GPU)); + + g->lcd = l; + g->core = l; + g->BGSize[0][0] = g->BGSize[1][0] = g->BGSize[2][0] = g->BGSize[3][0] = 256; + g->BGSize[0][1] = g->BGSize[1][1] = g->BGSize[2][1] = g->BGSize[3][1] = 256; + g->dispBG[0] = g->dispBG[1] = g->dispBG[2] = g->dispBG[3] = TRUE; + + g->spriteRender = sprite1D; + + if(g->core == GPU_SUB) + { + g->oam = (OAM *)(ARM9Mem.ARM9_OAM + 0x400); + g->sprMem = ARM9Mem.ARM9_BOBJ; + } + else + { + g->oam = (OAM *)(ARM9Mem.ARM9_OAM); + g->sprMem = ARM9Mem.ARM9_AOBJ; + } +} + +void GPU_DeInit(GPU * gpu) +{ + free(gpu); +} + +/* Sets up LCD control variables for Display Engines A and B for quick reading */ +void GPU_setVideoProp(GPU * gpu, u32 p) +{ + gpu->prop = p; + + gpu->dispMode = p >> 16; + if (gpu->lcd == 0) + gpu->dispMode &= 0x3; + else + gpu->dispMode &= 0x1; + switch (gpu->dispMode) + { + case 0: // Display Off + return; + case 1: // Display BG and OBJ layers + break; + case 2: // Display framebuffer + gpu->vramBlock = (p >> 18) & 0x3; + return; + case 3: // Display from Main RAM + LOG("FIXME: Display Mode 3 not supported(Display from Main RAM)\n"); + return; + } + + gpu->nbBGActif = 0; + if(p & 0x10) + { + /* 1-d sprite mapping */ + + gpu->sprBlock = 5 + ((p>>20)&3); /* TODO: better comment (and understanding btw 8S) */ + if((gpu->core == GPU_SUB) && (((p>>20)&3) == 3)) + { + gpu->sprBlock = 7; + } + gpu->spriteRender = sprite1D; + } + else + { + /* 2d sprite mapping */ + gpu->sprBlock = 5; + gpu->spriteRender = sprite2D; + } + + if((p & 0x400000) && (gpu->core == GPU_MAIN)) + { + gpu->sprBMPBlock = 8; + } + else + { + gpu->sprBMPBlock = 7; + } + + GPU_setBGProp(gpu, 3, T1ReadWord(ARM9Mem.ARM9_REG, (gpu->core * 0x800 + 7) << 1)); + GPU_setBGProp(gpu, 2, T1ReadWord(ARM9Mem.ARM9_REG, (gpu->core * 0x800 + 6) << 1)); + GPU_setBGProp(gpu, 1, T1ReadWord(ARM9Mem.ARM9_REG, (gpu->core * 0x800 + 5) << 1)); + GPU_setBGProp(gpu, 0, T1ReadWord(ARM9Mem.ARM9_REG, (gpu->core * 0x800 + 4) << 1)); + + if((p & 0x800) && gpu->dispBG[3]) + { + gpu->ordre[0] = 3; + gpu->BGIndex[3] = 1; + gpu->nbBGActif++; + } + else + { + gpu->BGIndex[3] = 0; + } + + if((p & 0x400) && gpu->dispBG[2]) + { + if(gpu->nbBGActif) + { + if((gpu->BGProp[2] & 0x3) > (gpu->BGProp[3] & 0x3)) + { + gpu->ordre[0] = 2; + gpu->BGIndex[2] = 1; + gpu->ordre[1] = 3; + gpu->BGIndex[3] = 2; + } + else + { + gpu->ordre[1] = 2; + gpu->BGIndex[2] = 2; + } + } + else + { + gpu->ordre[0] = 2; + gpu->BGIndex[2] = 1; + } + + gpu->nbBGActif++; + + } + else + { + gpu->BGIndex[2] = 0; + } + + if((p & 0x200) && gpu->dispBG[1]) + { + if(gpu->nbBGActif == 0) + { + gpu->ordre[0] = 1; + gpu->BGIndex[1] = 1; + } + else + { + u8 i = 0; + s8 j; + for(; (i < gpu->nbBGActif) && ((gpu->BGProp[gpu->ordre[i]] & 0x3) >= (gpu->BGProp[1] & 0x3)); ++i); + for(j = gpu->nbBGActif-1; j >= i; --j) + { + gpu->ordre[j+1] = gpu->ordre[j]; + gpu->BGIndex[gpu->ordre[j]]++; + } + gpu->ordre[i] = 1; + gpu->BGIndex[1] = i+1; + } + gpu->nbBGActif++; + } + else + { + gpu->BGIndex[1] = 0; + } + + if((p & 0x100) && (!(p & 0x8)) && gpu->dispBG[0]) + { + if(gpu->nbBGActif == 0) + { + gpu->ordre[0] = 0; + gpu->BGIndex[0] = 1; + } + else + { + u8 i = 0; + s8 j; + for(; (i < gpu->nbBGActif) && ((gpu->BGProp[gpu->ordre[i]] & 0x3) >= (gpu->BGProp[0] & 0x3)); ++i); + for(j = gpu->nbBGActif-1; j >= i; --j) + { + gpu->ordre[j+1] = gpu->ordre[j]; + gpu->BGIndex[gpu->ordre[j]]++; + } + gpu->ordre[i] = 0; + gpu->BGIndex[0] = i+1; + } + gpu->nbBGActif++; + } + else + { + gpu->BGIndex[0] = 0; + } + + /* FIXME: this debug won't work, obviously ... */ +#ifdef DEBUG_TRI + log::ajouter("------------------"); + for(u8 i = 0; i < gpu->nbBGActif; ++i) + { + sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->BGProp[gpu->ordre[i]]&3); + log::ajouter(logbuf); + } + log::ajouter("_________________"); +#endif +} + +/* this is writing in BGxCNT */ +/* FIXME: all DEBUG_TRI are broken */ +void GPU_setBGProp(GPU * gpu, u16 num, u16 p) +{ + u8 index = gpu->BGIndex[num]; + + if((gpu->nbBGActif != 0) && (index != 0)) + { + index--; + if((gpu->BGProp[num] & 0x3) < (p & 0x3)) + { +#ifdef DEBUG_TRI + sprintf(logbuf, "INF NEW bg %d prio %d %d", num, p&3, index); + log::ajouter(logbuf); + for(u8 i = 0; i < gpu->nbBGActif; ++i) + { + sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->BGProp[gpu->ordre[i]]&3); + log::ajouter(logbuf); + } +#endif + u8 i = 0; + for(; (i < index) && ((((gpu->BGProp[gpu->ordre[i]] & 0x3))>((p & 0x3))) || ((((gpu->BGProp[gpu->ordre[i]] & 0x3))==((p & 0x3)))&&(gpu->ordre[i]>num))); ++i); /* TODO: commenting and understanding */ + +#ifdef DEBUG_TRI + + sprintf(logbuf, "new i %d old %d", i, index); + log::ajouter(logbuf); +#endif + + if(i != index) + { + s8 j; + for(j = index-1; j>=i; --j) + { + gpu->ordre[j+1] = gpu->ordre[j]; + ++gpu->BGIndex[gpu->ordre[j]]; + } + gpu->ordre[i] = num; + gpu->BGIndex[num] = i + 1; + } +#ifdef DEBUG_TRI + log::ajouter(""); + for(u8 i = 0; i < gpu->nbBGActif; ++i) + { + sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->BGProp[gpu->ordre[i]]&3); + log::ajouter(logbuf); + } + log::ajouter("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); +#endif + } + else + { + if((gpu->BGProp[num]&3)>(p&3)) + { +#ifdef DEBUG_TRI + sprintf(logbuf, "SUP NEW bg %d prio %d", num, p&3); + log::ajouter(logbuf); + for(u8 i = 0; i < gpu->nbBGActif; ++i) + { + sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->BGProp[gpu->ordre[i]]&3); + log::ajouter(logbuf); + } +#endif + u8 i = gpu->nbBGActif-1; + for(; (i>index) && (((gpu->BGProp[gpu->ordre[i]]&3)<(p&3)) || (((gpu->BGProp[gpu->ordre[i]]&3)==(p&3))&&(gpu->ordre[i]ordre[j] = gpu->ordre[j+1]; + gpu->BGIndex[gpu->ordre[j]]--; + } + gpu->ordre[i] = num; + gpu->BGIndex[num] = i + 1; + } +#ifdef DEBUG_TRI + log::ajouter(""); + for(u8 i = 0; i < gpu->nbBGActif; ++i) + { + sprintf(logbuf, "bg %d prio %d", gpu->ordre[i], gpu->BGProp[gpu->ordre[i]]&3); + log::ajouter(logbuf); + } + log::ajouter("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); +#endif + } + } + } + + gpu->BGProp[num] = p; + + if(gpu->core == GPU_SUB) + { + gpu->BG_bmp_ram[num] = ((u8 *)ARM9Mem.ARM9_BBG) + ((p>>8)&0x1F) * 0x4000; + gpu->BG_tile_ram[num] = ((u8 *)ARM9Mem.ARM9_BBG) + ((p>>2)&0xF) * 0x4000; + gpu->BG_map_ram[num] = ARM9Mem.ARM9_BBG + ((p>>8)&0x1F) * 0x800; + } + else + { + gpu->BG_bmp_ram[num] = ((u8 *)ARM9Mem.ARM9_ABG) + ((p>>8)&0x1F) * 0x4000; + gpu->BG_tile_ram[num] = ((u8 *)ARM9Mem.ARM9_ABG) + ((p>>2)&0xF) * 0x4000 + ((gpu->prop >> 24) & 0x7) * 0x10000; + gpu->BG_map_ram[num] = ARM9Mem.ARM9_ABG + ((p>>8)&0x1F) * 0x800 + ((gpu->prop >> 27) & 0x7) * 0x10000; + } + + /*if(!(p&(1<<7))) + BGExtPalSlot[num] = 0; + else + if(!(prop&(1<<30))) + BGExtPalSlot[num] = 0; + else*/ + switch(num) + { + case 0 : + gpu->BGExtPalSlot[num] = (p & 0x2000) ? 2 : 0; + break; + + case 1 : + gpu->BGExtPalSlot[num] = (p & 0x2000) ? 3 : 1; + break; + + default : + gpu->BGExtPalSlot[num] = num; + break; + } + + /*if(!(prop&(3<<16))) + { + BGSize[num][0] = lcdSizeTab[p>>14][0]; + BGSize[num][1] = lcdSizeTab[p>>14][1]; + return; + }*/ + + gpu->BGSize[num][0] = sizeTab[mode2type[gpu->prop & 0x7][num]][p >> 14][0]; + gpu->BGSize[num][1] = sizeTab[mode2type[gpu->prop & 0x7][num]][p >> 14][1]; +} + +void GPU_remove(GPU * gpu, u8 num) +{ + u8 index; + //!!!!AJOUTER UN CRITICAL SECTION + if(index = gpu->BGIndex[num]) + { + u8 i; + --index; + --gpu->nbBGActif; + for(i = index; i < gpu->nbBGActif; ++i) + { + gpu->ordre[i] = gpu->ordre[i+1]; + --gpu->BGIndex[gpu->ordre[i]]; + } + gpu->BGIndex[num] = 0; + } + gpu->dispBG[num] = !gpu->dispBG[num]; +} + +void GPU_addBack(GPU * gpu, u8 num) +{ + if((!gpu->BGIndex[num])&&(gpu->prop&((1<<8)<BGProp[num]&3; + for(; (inbBGActif) && (((gpu->BGProp[gpu->ordre[i]]&3)>p) || (((gpu->BGProp[gpu->ordre[i]]&3)==p)&&(gpu->ordre[i]>num))); ++i); + for(j = gpu->nbBGActif-1; j >= i; --j) + { + gpu->ordre[j+1] = gpu->ordre[j]; + ++gpu->BGIndex[gpu->ordre[j]]; + } + gpu->ordre[i] = num; + gpu->BGIndex[num] = i+1; + ++gpu->nbBGActif; + } + gpu->dispBG[num] = !gpu->dispBG[num]; +} + +void GPU_scrollX(GPU * gpu, u8 num, u16 v) +{ + gpu->BGSX[num] = v; +} + +void GPU_scrollY(GPU * gpu, u8 num, u16 v) +{ + gpu->BGSY[num] = v; +} + +void GPU_scrollXY(GPU * gpu, u8 num, u32 v) +{ + gpu->BGSX[num] = (v & 0xFFFF); + gpu->BGSY[num] = (v >> 16); +} + +void GPU_setX(GPU * gpu, u8 num, u32 v) +{ + gpu->BGX[num] = (((s32)(v<<4))>>4); +} + +void GPU_setXH(GPU * gpu, u8 num, u16 v) +{ + gpu->BGX[num] = (((s32)((s16)(v<<4)))<<12) | (gpu->BGX[num]&0xFFFF); +} + +void GPU_setXL(GPU * gpu, u8 num, u16 v) +{ + gpu->BGX[num] = (gpu->BGX[num]&0xFFFF0000) | v; +} + +void GPU_setY(GPU * gpu, u8 num, u32 v) +{ + gpu->BGY[num] = (((s32)(v<<4))>>4); +} + +void GPU_setYH(GPU * gpu, u8 num, u16 v) +{ + gpu->BGY[num] = (((s32)((s16)(v<<4)))<<12) | (gpu->BGY[num]&0xFFFF); +} + +void GPU_setYL(GPU * gpu, u8 num, u16 v) +{ + gpu->BGY[num] = (gpu->BGY[num]&0xFFFF0000) | v; +} + +void GPU_setPA(GPU * gpu, u8 num, u16 v) +{ + gpu->BGPA[num] = (s32)v; +} + +void GPU_setPB(GPU * gpu, u8 num, u16 v) +{ + gpu->BGPB[num] = (s32)v; +} + +void GPU_setPC(GPU * gpu, u8 num, u16 v) +{ + gpu->BGPC[num] = (s32)v; +} + +void GPU_setPD(GPU * gpu, u8 num, u16 v) +{ + gpu->BGPD[num] = (s32)v; +} + +void GPU_setPAPB(GPU * gpu, u8 num, u32 v) +{ + gpu->BGPA[num] = (s16)v; + gpu->BGPB[num] = (s16)(v>>16); +} + +void GPU_setPCPD(GPU * gpu, u8 num, u32 v) +{ + gpu->BGPC[num] = (s16)v; + gpu->BGPD[num] = (s16)(v>>16); +} + +INLINE void renderline_textBG(GPU * gpu, u8 num, u8 * DST, u16 X, u16 Y, u16 LG) +{ + u32 bgprop = gpu->BGProp[num]; + u16 lg = gpu->BGSize[num][0]; + u16 ht = gpu->BGSize[num][1]; + u16 tmp = ((Y&(ht-1))>>3); + u8 * map = gpu->BG_map_ram[num] + (tmp&31) * 64; + u8 *dst = DST; + u8 *tile; + u16 xoff = X; + u8 * pal; + u16 yoff; + u16 x; + + if(tmp>31) + { + switch(bgprop >> 14) + { + case 2 : + map += 32 * 32 * 2; + break; + case 3 : + map += 32 * 64 * 2; + break; + } + } + + tile = (u8*) gpu->BG_tile_ram[num]; + + if((!tile) || (!gpu->BG_map_ram[num])) return; + + xoff = X; + + if(!(bgprop & 0x80)) + { + yoff = ((Y&7)<<2); + pal = ARM9Mem.ARM9_VMEM + gpu->core * 0x400; + + for(x = 0; x < LG;) + { + u8 * mapinfo; + u16 mapinfovalue; + u8 *line; + u16 xfin; + tmp = ((xoff&(lg-1))>>3); + mapinfo = map + (tmp&0x1F) * 2; + mapinfovalue; + + if(tmp>31) mapinfo += 32*32*2; + + mapinfovalue = T1ReadWord(mapinfo, 0); + + line = (u8 * )tile + ((mapinfovalue&0x3FF) * 0x20) + (((mapinfovalue)& 0x800 ? (7*4)-yoff : yoff)); + xfin = x + (8 - (xoff&7)); + if (xfin > LG) + xfin = LG; + + if((mapinfovalue) & 0x400) + { + line += 3 - ((xoff&7)>>1); + for(; x < xfin; ) + { + if((*line)>>4) T2WriteWord(dst, 0, T1ReadWord(pal, (((*line)>>4) + ((mapinfovalue>>12)&0xF) * 0x10) << 1)); + dst += 2; x++; xoff++; + if((*line)&0xF) T2WriteWord(dst, 0, T1ReadWord(pal, (((*line)&0xF) + ((mapinfovalue>>12)&0xF) * 0x10) << 1)); + dst += 2; x++; xoff++; + line--; + } + } + else + { + line += ((xoff&7)>>1); + for(; x < xfin; ) + { + if((*line)&0xF) T2WriteWord(dst, 0, T1ReadWord(pal, (((*line)&0xF) + ((mapinfovalue>>12)&0xF) * 0x10) << 1)); + dst += 2; x++; xoff++; + if((*line)>>4) T2WriteWord(dst, 0, T1ReadWord(pal, (((*line)>>4) + ((mapinfovalue>>12)&0xF) * 0x10) << 1)); + dst += 2; x++; xoff++; + line++; + } + } + } + return; + } + + if(!(gpu->prop & 0x40000000)) + { + yoff = ((Y&7)<<3); + pal = ARM9Mem.ARM9_VMEM + gpu->core * 0x400; + + for(x = 0; x < LG;) + { + u8 * mapinfo; + u16 mapinfovalue; + u8 *line; + u16 xfin; + tmp = ((xoff&(lg-1))>>3); + mapinfo = map + (tmp & 31) * 2; + mapinfovalue; + + if(tmp > 31) mapinfo += 32*32*2; + + mapinfovalue = T1ReadWord(mapinfo, 0); + + line = (u8 * )tile + ((mapinfovalue&0x3FF)*0x40) + (((mapinfovalue)& 0x800 ? (7*8)-yoff : yoff)); + xfin = x + (8 - (xoff&7)); + if (xfin > LG) + xfin = LG; + + if((mapinfovalue)& 0x400) + { + line += (7 - (xoff&7)); + for(; x < xfin; ++x, ++xoff) + { + if(*line) T2WriteWord(dst, 0, T1ReadWord(pal, *line << 1)); + dst += 2; + line--; + } + } + else + { + line += (xoff&7); + for(; x < xfin; ++x, ++xoff) + { + if(*line) T2WriteWord(dst, 0, T1ReadWord(pal, *line << 1)); + dst += 2; + line++; + } + } + } + return; + } + + pal = ARM9Mem.ExtPal[gpu->core][gpu->BGExtPalSlot[num]]; + + if(!pal) return; + + yoff = ((Y&7)<<3); + + for(x = 0; x < LG;) + { + u8 * mapinfo; + u16 mapinfovalue; + u8 * line; + u16 xfin; + tmp = ((xoff&(lg-1))>>3); + mapinfo = map + (tmp & 0x1F) * 2; + mapinfovalue; + + if(tmp>31) mapinfo += 32 * 32 * 2; + + mapinfovalue = T1ReadWord(mapinfo, 0); + + line = (u8 * )tile + ((mapinfovalue&0x3FF)*0x40) + (((mapinfovalue)& 0x800 ? (7*8)-yoff : yoff)); + xfin = x + (8 - (xoff&7)); + if (xfin > LG) + xfin = LG; + + if((mapinfovalue)& 0x400) + { + line += (7 - (xoff&7)); + for(; x < xfin; ++x, ++xoff) + { + if(*line) T2WriteWord(dst, 0, T1ReadWord(pal, (*line + ((mapinfovalue>>12)&0xF)*0x100) << 1)); + dst += 2; + line--; + } + } + else + { + line += (xoff&7); + for(; x < xfin; ++x, ++xoff) + { + if(*line) T2WriteWord(dst, 0, T1ReadWord(pal, (*line + ((mapinfovalue>>12)&0xF)*0x100) << 1)); + dst += 2; + line++; + } + } + } +} + +INLINE void rotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, u16 LG) +{ + u32 bgprop = gpu->BGProp[num]; + + s32 x = X + (s32)PB*(s32)H; + s32 y = Y + (s32)PD*(s32)H; + + + s32 dx = (s32)PA; + s32 dy = (s32)PC; + + s32 auxX; + s32 auxY; + + s32 lg = gpu->BGSize[num][0]; + s32 ht = gpu->BGSize[num][1]; + s32 lgmap = (lg>>3); + + u8 * map = gpu->BG_map_ram[num]; + u8 * tile = (u8 *)gpu->BG_tile_ram[num]; + u8 * dst = DST; + u8 mapinfo; + u8 coul; + u8 * pal; + u32 i; + + if((!tile)||(!map)) return; + + pal = ARM9Mem.ARM9_VMEM + gpu->core * 0x400; + for(i = 0; i < LG; ++i) + { + auxX = x>>8; + auxY = y>>8; + + if(bgprop&(1<<13)) + { + auxX &= (lg-1); + auxY &= (ht-1); + } + + if ((auxX >= 0) && (auxX < lg) && (auxY >= 0) && (auxY < ht)) + { + mapinfo = map[(auxX>>3) + ((auxY>>3) * lgmap)]; + coul = tile[mapinfo*64 + ((auxY&7)<<3) + (auxX&7)]; + if(coul) + T2WriteWord(dst, 0, T1ReadWord(pal, coul << 1)); + } + dst += 2; + x += dx; + y += dy; + } +} + +INLINE void extRotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, s16 LG) +{ + u32 bgprop = gpu->BGProp[num]; + + s32 x = X + (s32)PB*(s32)H; + s32 y = Y + (s32)PD*(s32)H; + + s32 dx = PA; + s32 dy = PC; + + s32 auxX; + s32 auxY; + + s16 lg = gpu->BGSize[num][0]; + s16 ht = gpu->BGSize[num][1]; + u16 lgmap = (lg>>3); + + u8 * tile = (u8 *)gpu->BG_tile_ram[num]; + u8 * dst = DST; + u16 mapinfo; + u8 coul; + + switch(((bgprop>>2)&1)|((bgprop>>6)&2)) + { + case 0 : + case 1 : + { + u8 * map = gpu->BG_map_ram[num]; + u8 * pal = ARM9Mem.ExtPal[gpu->core][gpu->BGExtPalSlot[num]]; + u16 i; + + if(!pal) return; + for(i = 0; i < LG; ++i) + { + auxX = x>>8; + auxY = y>>8; + + if(bgprop&(1<<13)) + { + auxX &= (lg-1); + auxY &= (ht-1); + } + if ((auxX >= 0) && (auxX < lg) && (auxY >= 0) && (auxY < ht)) + { + u16 x1; + u16 y1; + mapinfo = T1ReadWord(map, ((auxX>>3) + (auxY>>3) * lgmap) << 1); + + x1 = (mapinfo & 0x400) ? 7 - (auxX&7) : (auxX&7); + y1 = (mapinfo & 0x800) ? 7 - (auxY&7) : (auxY&7); + coul = tile[(mapinfo&0x3FF)*64 + x1 + (y1<<3)]; + if(coul) + T2WriteWord(dst, 0, T1ReadWord(pal, (coul + (mapinfo>>12)*0x100) << 1)); + } + dst += 2; + x += dx; + y += dy; + } + } + return; + case 2 : + { + u8 * map = gpu->BG_bmp_ram[num]; + u8 * pal = ARM9Mem.ARM9_VMEM + gpu->core * 0x400; + u16 i; + for(i = 0; i < LG; ++i) + { + auxX = x>>8; + auxY = y>>8; + if(bgprop&(1<<13)) + { + auxX &= (lg-1); + auxY &= (ht-1); + } + if ((auxX >= 0) && (auxX < lg) && (auxY >= 0) && (auxY < ht)) + { + mapinfo = map[auxX + auxY * lg]; + if(mapinfo) + T2WriteWord(dst, 0, T1ReadWord(pal, mapinfo << 1)); + } + dst += 2; + x += dx; + y += dy; + } + } + return; + case 3 : + { + u8 * map = gpu->BG_bmp_ram[num]; + u16 i; + for(i = 0; i < LG; ++i) + { + auxX = x>>8; + auxY = y>>8; + if(bgprop&(1<<13)) + { + auxX &= (lg-1); + auxY &= (ht-1); + } + if ((auxX >= 0) && (auxX < lg) && (auxY >= 0) && (auxY < ht)) + { + mapinfo = T1ReadWord(map, (auxX + auxY * lg) << 1); + if(mapinfo) + T2WriteWord(dst, 0, mapinfo); + } + dst += 2; + x += dx; + y += dy; + } + } + return; + } +} + +void lineText(GPU * gpu, u8 num, u16 l, u8 * DST) +{ + renderline_textBG(gpu, num, DST, gpu->BGSX[num], l + gpu->BGSY[num], 256); +} + +void lineRot(GPU * gpu, u8 num, u16 l, u8 * DST) +{ + rotBG2(gpu, num, DST, l, + gpu->BGX[num], + gpu->BGY[num], + gpu->BGPA[num], + gpu->BGPB[num], + gpu->BGPC[num], + gpu->BGPD[num], + 256); +} + +void lineExtRot(GPU * gpu, u8 num, u16 l, u8 * DST) +{ + extRotBG2(gpu, num, DST, l, + gpu->BGX[num], + gpu->BGY[num], + gpu->BGPA[num], + gpu->BGPB[num], + gpu->BGPC[num], + gpu->BGPD[num], + 256); +} + +void textBG(GPU * gpu, u8 num, u8 * DST) +{ + u32 i; + for(i = 0; i < gpu->BGSize[num][1]; ++i) + { + renderline_textBG(gpu, num, DST + i*gpu->BGSize[num][0], 0, i, gpu->BGSize[num][0]); + } +} + +void rotBG(GPU * gpu, u8 num, u8 * DST) +{ + u32 i; + for(i = 0; i < gpu->BGSize[num][1]; ++i) + rotBG2(gpu, num, DST + i*gpu->BGSize[num][0], i, 0, 0, 256, 0, 0, 256, gpu->BGSize[num][0]); +} + +void extRotBG(GPU * gpu, u8 num, u8 * DST) +{ + u32 i; + for(i = 0; i < gpu->BGSize[num][1]; ++i) + extRotBG2(gpu, num, DST + i*gpu->BGSize[num][0], i, 0, 0, 256, 0, 0, 256, gpu->BGSize[num][0]); +} + +#define nbShow 128 + +void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab) +{ + OAM * aux = gpu->oam + (nbShow-1);// + 127; + + u8 block = gpu->sprBlock; + u16 i; + + for(i = 0; iattr1 & 0x1FF; + s32 sprY; + s32 x = 0; + u32 lg; + size sprSize; + s32 y; + u8 prio; + u8 * src; + u8 * pal; + u16 j; + + sprX = ((s32)(sprX<<23))>>23; + sprY = aux->attr0 & 0xFF; + + sprSize = sprSizeTab[(aux->attr1>>14)][(aux->attr0>>14)]; + + lg = sprSize.x; + + if(sprY>192) + sprY = (s32)((s8)(aux->attr0 & 0xFF)); + + if( ((aux->attr0&(1<<9))&&(!(aux->attr0&(1<<8)))) || + (l=sprY+sprSize.y) || + (sprX==256) ) + continue; + + if(sprX<0) + { + if(sprX+sprSize.x<=0) continue; + lg += sprX; + x = -sprX; + sprX = 0; + } + else + if(sprX+sprSize.x>256) + lg = 255 - sprX; + + y = l - sprY; + prio = (aux->attr2>>10)&3; + + if(aux->attr1&(1<<13)) y = sprSize.y - y -1; + + if((aux->attr0&(3<<10))==(3<<10)) + { + u16 i; + src = (gpu->sprMem) +(aux->attr2&0x3FF)*16 + (y<sprBMPBlock); + + if(aux->attr1&(1<<12)) + { + x = sprSize.x -x - 1; + for(i = 0; i < lg; ++i, --x, ++sprX) + { + u8 c = src[x]; + if((c>>15) && (prioTab[sprX]>=prio)) // What's the point in shifting down by 15 when c is 8-bits? + { + T2WriteByte(dst, sprX << 1, c); + prioTab[sprX] = prio; + } + } + continue; + } + for(i = 0; i < lg; ++i, ++x, ++sprX) + { + u16 c = T1ReadWord(src, x << 1); + if((c>>15) && (prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, c); + prioTab[sprX] = prio; + } + } + continue; + } + + if(aux->attr0&(1<<13)) + { + u16 i; + src = gpu->sprMem + ((aux->attr2&0x3FF)<>3)*sprSize.x*8) + ((y&0x7)*8); + + if(gpu->prop&(1<<31)) + pal = ARM9Mem.ObjExtPal[gpu->core][0]+((aux->attr2>>12)*0x200); + else + pal = ARM9Mem.ARM9_VMEM + 0x200 + gpu->core *0x400; + + if(aux->attr1&(1<<12)) + { + x = sprSize.x -x - 1; + for(i = 0; i < lg; ++i, --x, ++sprX) + { + u8 c = src[(x&0x7) + ((x&0xFFF8)<<3)]; + if((c) && (prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, c << 1)); + prioTab[sprX] = prio; + } + } + continue; + } + + for(i = 0; i < lg; ++i, ++x, ++sprX) + { + u8 c = src[(x&0x7) + ((x&0xFFF8)<<3)]; + + if((c) && (prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, c << 1)); + prioTab[sprX] = prio; + } + } + continue; + } + src = gpu->sprMem + ((aux->attr2&0x3FF)<>3)*sprSize.x*4) + ((y&0x7)*4); + pal = ARM9Mem.ARM9_VMEM + 0x200 + gpu->core * 0x400; + + if(x&1) + { + if(aux->attr1&(1<<12)) + { + s32 x1 = ((sprSize.x-x)>>1); + u8 c = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; + if((c&0xF)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c&0xF)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + x1 = ((sprSize.x-x-lg)>>1); + c = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; + if((c&0xF)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, (sprX+lg-1) << 1, T1ReadWord(pal, ((c&0xF)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX+lg-1] = prio; + } + } + else + { + s32 x1 = (x>>1); + u8 c = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; + if((c>>4)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c>>4)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + x1 = ((x+lg-1)>>1); + c = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; + if((c>>4)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, (sprX+lg-1) << 1, T1ReadWord(pal, ((c>>4)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX+lg-1] = prio; + } + } + ++sprX; + ++x; + } + lg >>= 1; + x >>= 1; + if(aux->attr1&(1<<12)) + { + u16 i; + x = (sprSize.x>>1) - x -1; + for(i = 0; i < lg; ++i, --x) + { + u8 c = src[(x&0x3) + ((x&0xFFFC)<<3)]; + if((c>>4)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c>>4)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + ++sprX; + + if((c&0xF)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c&0xF)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + ++sprX; + } + continue; + } + + for(j = 0; j < lg; ++j, ++x) + { + u8 c = src[(x&0x3) + ((x&0xFFFC)<<3)]; + + if((c&0xF)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c&0xF)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + ++sprX; + + if((c>>4)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c>>4)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + ++sprX; + } + } +} + +void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab) +{ + u16 i; + OAM * aux = gpu->oam + (nbShow-1);// + 127; + + for(i = 0; iattr1 & 0x1FF; + s32 sprY; + s32 x = 0; + size sprSize; + u32 lg; + s32 y; + u8 prio; + u8 * src; + u8 * pal; + u16 j; + + sprX = ((s32)(sprX<<23))>>23; + sprY = aux->attr0 & 0xFF; + + sprSize = sprSizeTab[(aux->attr1>>14)][(aux->attr0>>14)]; + + lg = sprSize.x; + + if(sprY>192) + sprY = (s32)((s8)(aux->attr0 & 0xFF)); + + if( ((aux->attr0&(1<<9))&&(!(aux->attr0&(1<<8)))) || + (l=sprY+sprSize.y) || + (sprX==256) ) + continue; + + if(sprX<0) + { + if(sprX+sprSize.x<=0) continue; + lg += sprX; + x = -sprX; + sprX = 0; + } + else + if(sprX+sprSize.x>256) + lg = 255 - sprX; + + y = l - sprY; + prio = (aux->attr2>>10)&3; + + if(aux->attr1&(1<<13)) y = sprSize.y - y -1; + + if((aux->attr0&(3<<10))==(3<<10)) + { + u16 i; + src = (gpu->sprMem) + (((aux->attr2&0x3E0) * 64 + (aux->attr2&0x1F) * 8 + ( y << 8)) << 1); + + if(aux->attr1&(1<<12)) + { + LOG("Using fubared h-flip\n"); + + x = sprSize.x -x - 1; + for(i = 0; i < lg; ++i, --x, ++sprX) + { + u8 c = src[x << 1]; + if((c>>15) && (prioTab[sprX]>=prio)) // What's the point in shifting down by 15 when c is 8-bits? + { + T2WriteByte(dst, sprX << 1, c); + prioTab[sprX] = prio; + } + } + continue; + } + for(i = 0; i < lg; ++i, ++x, ++sprX) + { + u16 c = T1ReadWord(src, x << 1); + if((c>>15) && (prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, c); + prioTab[sprX] = prio; + } + }// + continue; + } + + if(aux->attr0&(1<<13)) + { + u16 i; + src = gpu->sprMem + ((aux->attr2&0x3FF)<<5) + ((y>>3)<<10) + ((y&0x7)*8); + pal = ARM9Mem.ARM9_VMEM + 0x200 + gpu->core * 0x400; + + if(aux->attr1&(1<<12)) + { + x = sprSize.x -x - 1; + for(i = 0; i < lg; ++i, --x, ++sprX) + { + u8 c = src[(x&0x7) + ((x&0xFFF8)<<3)]; + if((c) && (prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, c << 1)); + prioTab[sprX] = prio; + } + } + continue; + } + + for(i = 0; i < lg; ++i, ++x, ++sprX) + { + u8 c = src[(x&0x7) + ((x&0xFFF8)<<3)]; + + if((c) && (prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, c << 1)); + prioTab[sprX] = prio; + } + } + continue; + } + src = gpu->sprMem + ((aux->attr2&0x3FF)<<5) + ((y>>3)<<10) + ((y&0x7)*4); + pal = ARM9Mem.ARM9_VMEM + 0x200 + gpu->core * 0x400; + if(x&1) + { + if(aux->attr1&(1<<12)) + { + s32 x1 = ((sprSize.x-x)>>1); + u8 c = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; + if((c&0xF)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c&0xF)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + x1 = ((sprSize.x-x-lg)>>1); + c = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; + if((c&0xF)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, (sprX+lg-1) << 1, T1ReadWord(pal, ((c&0xF)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX+lg-1] = prio; + } + } + else + { + s32 x1 = (x>>1); + u8 c = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; + if((c>>4)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c>>4)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + x1 = ((x+lg-1)>>1); + c = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; + if((c>>4)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, (sprX+lg-1) << 1, T1ReadWord(pal, ((c>>4)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX+lg-1] = prio; + } + } + ++sprX; + ++x; + } + lg >>= 1; + x >>= 1; + if(aux->attr1&(1<<12)) + { + u16 i; + x = (sprSize.x>>1) - x -1; + for(i = 0; i < lg; ++i, --x) + { + u8 c = src[(x&0x3) + ((x&0xFFFC)<<3)]; + if((c>>4)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c>>4)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + ++sprX; + + if((c&0xF)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c&0xF)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + ++sprX; + } + continue; + } + + for(j = 0; j < lg; ++j, ++x) + { + u8 c = src[(x&0x3) + ((x&0xFFFC)<<3)]; + + if((c&0xF)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c&0xF)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + ++sprX; + + if((c>>4)&&(prioTab[sprX]>=prio)) + { + T2WriteWord(dst, sprX << 1, T1ReadWord(pal, ((c>>4)+((aux->attr2>>12)*0x10)) << 1)); + prioTab[sprX] = prio; + } + ++sprX; + } + } +} + +void Screen_Init(void) { + MainScreen.gpu = GPU_Init(0); + SubScreen.gpu = GPU_Init(1); +} + +void Screen_Reset(void) { + GPU_Reset(MainScreen.gpu, 0); + GPU_Reset(SubScreen.gpu, 1); +} + +void Screen_DeInit(void) { + GPU_DeInit(MainScreen.gpu); + GPU_DeInit(SubScreen.gpu); +} diff --git a/tags/release_0_5_0/desmume/src/GPU.h b/tags/release_0_5_0/desmume/src/GPU.h new file mode 100644 index 000000000..d1b5c12f0 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/GPU.h @@ -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 +#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 + diff --git a/tags/release_0_5_0/desmume/src/MMU.c b/tags/release_0_5_0/desmume/src/MMU.c new file mode 100644 index 000000000..d1a5c6818 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/MMU.c @@ -0,0 +1,2289 @@ +/* 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 +*/ + +//#define RENDER3D + +#include +#include +#include + +#include "debug.h" +#include "NDSSystem.h" +#include "cflash.h" + +#include "registers.h" + +#define ROM_MASK 3 + +//#define LOG_CARD +//#define LOG_GPU +//#define LOG_DMA +//#define LOG_DMA2 +//#define LOG_DIV + +char szRomPath[512]; +char szRomBaseName[512]; + +MMU_struct MMU; + +u8 * MMU_ARM9_MEM_MAP[256]={ + //0X + ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, + //1X + //ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, ARM9Mem.ARM9_ITCM, + ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, ARM9Mem.ARM9_WRAM, + //2X + ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, + //3x + MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, + //4X + ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, ARM9Mem.ARM9_REG, + //5X + ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, ARM9Mem.ARM9_VMEM, + //60 61 + ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, + //62 63 + ARM9Mem.ARM9_BBG, ARM9Mem.ARM9_BBG, + //64 65 + ARM9Mem.ARM9_AOBJ, ARM9Mem.ARM9_AOBJ, + //66 67 + ARM9Mem.ARM9_BOBJ, ARM9Mem.ARM9_BOBJ, + //68 69 .. + ARM9Mem.ARM9_LCD, ARM9Mem.ARM9_LCD, ARM9Mem.ARM9_LCD, ARM9Mem.ARM9_LCD, ARM9Mem.ARM9_LCD, ARM9Mem.ARM9_LCD, ARM9Mem.ARM9_LCD, ARM9Mem.ARM9_LCD, + //7X + ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, ARM9Mem.ARM9_OAM, + //8X + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + //9X + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + //AX + MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, + //BX + //CX + //DX + //EX + //FX + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, ARM9Mem.ARM9_BIOS, +}; + +u32 MMU_ARM9_MEM_MASK[256]={ + //0X + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + //1X + 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, + //0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + //2x + 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, + //3X + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + //4X + 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, + //5X + 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, + //60 61 + 0x7FFFF, 0x7FFFF, + //62 63 + 0x1FFFF, 0x1FFFF, + //64 65 + 0x3FFFF, 0x3FFFF, + //66 67 + 0x1FFFF, 0x1FFFF, + //68 69 .... + 0xFFFFF, 0xFFFFF, 0xFFFFF, 0xFFFFF, 0xFFFFF, 0xFFFFF, 0xFFFFF, 0xFFFFF, + //7X + 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, 0x7FF, + //8X + ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, + //9x + ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, + //AX + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + //BX + //CX + //DX + //EX + //FX + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x0003, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, +}; + +u8 * MMU_ARM7_MEM_MAP[256]={ + //0X + MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, MMU.ARM7_BIOS, + //1X + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + //2X + ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, ARM9Mem.MAIN_MEM, + //30 - 37 + MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, MMU.SWIRAM, + //38 - 3F + MMU.ARM7_ERAM, MMU.ARM7_ERAM, MMU.ARM7_ERAM, MMU.ARM7_ERAM, MMU.ARM7_ERAM, MMU.ARM7_ERAM, MMU.ARM7_ERAM, MMU.ARM7_ERAM, + //40 - 47 + MMU.ARM7_REG, MMU.ARM7_REG, MMU.ARM7_REG, MMU.ARM7_REG, MMU.ARM7_REG, MMU.ARM7_REG, MMU.ARM7_REG, MMU.ARM7_REG, + //48 - 4F + MMU.ARM7_WIRAM, MMU.ARM7_WIRAM, MMU.ARM7_WIRAM, MMU.ARM7_WIRAM, MMU.ARM7_WIRAM, MMU.ARM7_WIRAM, MMU.ARM7_WIRAM, MMU.ARM7_WIRAM, + //5X + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + //6X + ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, ARM9Mem.ARM9_ABG, + //7X + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + //8X + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + //9X + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + //AX + MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, MMU.CART_RAM, + //BX + //CX + //DX + //EX + //FX + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, + MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, MMU.UNUSED_RAM, +}; + +u32 MMU_ARM7_MEM_MASK[256]={ + //0X + 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, 0x3FFF, + //1X + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + //2x + 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, 0x3FFFFF, + //30 - 37 + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + //38 - 3F + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + //40 - 47 + 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, + //48 - 4F + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + //5X + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + //6X + 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, 0x3FFFF, + //7X + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + //8X + ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, + //9x + ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, ROM_MASK, + //AX + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + //BX + //CX + //DX + //EX + //FX + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, + 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, +}; + +u32 MMU_ARM9_WAIT16[16]={ + 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1, +}; + +u32 MMU_ARM9_WAIT32[16]={ + 1, 1, 1, 1, 1, 2, 2, 1, 8, 8, 5, 1, 1, 1, 1, 1, +}; + +u32 MMU_ARM7_WAIT16[16]={ + 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1, +}; + +u32 MMU_ARM7_WAIT32[16]={ + 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, 5, 1, 1, 1, 1, 1, +}; + +void MMU_Init(void) { + int i; + + LOG("MMU init\n"); + + memset(&MMU, 0, sizeof(MMU_struct)); + + MMU.CART_ROM = MMU.UNUSED_RAM; + + for(i = 0x80; i<0xA0; ++i) + { + MMU_ARM9_MEM_MAP[i] = MMU.CART_ROM; + MMU_ARM7_MEM_MAP[i] = MMU.CART_ROM; + } + + MMU.MMU_MEM[0] = MMU_ARM9_MEM_MAP; + MMU.MMU_MEM[1] = MMU_ARM7_MEM_MAP; + MMU.MMU_MASK[0]= MMU_ARM9_MEM_MASK; + MMU.MMU_MASK[1] = MMU_ARM7_MEM_MASK; + + MMU.ITCMRegion = 0x00800000; + + MMU.MMU_WAIT16[0] = MMU_ARM9_WAIT16; + MMU.MMU_WAIT16[1] = MMU_ARM7_WAIT16; + MMU.MMU_WAIT32[0] = MMU_ARM9_WAIT32; + MMU.MMU_WAIT32[1] = MMU_ARM7_WAIT32; + + for(i = 0;i < 16;i++) + FIFOInit(MMU.fifos + i); + + mc_init(&MMU.fw, MC_TYPE_FLASH); /* init fw device */ + mc_alloc(&MMU.fw, NDS_FW_SIZE_V1); + MMU.fw.fp = NULL; + + // Init Backup Memory device, this should really be done when the rom is loaded + mc_init(&MMU.bupmem, MC_TYPE_AUTODETECT); + mc_alloc(&MMU.bupmem, 1); + MMU.bupmem.fp = NULL; +} + +void MMU_DeInit(void) { + LOG("MMU deinit\n"); + if (MMU.fw.fp) + fclose(MMU.fw.fp); + mc_free(&MMU.fw); + if (MMU.bupmem.fp) + fclose(MMU.bupmem.fp); + mc_free(&MMU.bupmem); +} + +//Card rom & ram + +u16 SPI_CNT = 0; +u16 SPI_CMD = 0; +u16 AUX_SPI_CNT = 0; +u16 AUX_SPI_CMD = 0; + +u32 rom_mask = 0; + +u32 DMASrc[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; +u32 DMADst[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; + +void MMU_clearMem() +{ + int i; + + memset(ARM9Mem.ARM9_ABG, 0, 0x80000); + memset(ARM9Mem.ARM9_AOBJ, 0, 0x40000); + memset(ARM9Mem.ARM9_BBG, 0, 0x20000); + memset(ARM9Mem.ARM9_BOBJ, 0, 0x20000); + memset(ARM9Mem.ARM9_DTCM, 0, 0x4000); + memset(ARM9Mem.ARM9_ITCM, 0, 0x8000); + memset(ARM9Mem.ARM9_LCD, 0, 0xA4000); + memset(ARM9Mem.ARM9_OAM, 0, 0x800); + memset(ARM9Mem.ARM9_REG, 0, 0x1000000); + memset(ARM9Mem.ARM9_VMEM, 0, 0x800); + memset(ARM9Mem.ARM9_WRAM, 0, 0x1000000); + memset(ARM9Mem.MAIN_MEM, 0, 0x400000); + + memset(MMU.ARM7_ERAM, 0, 0x10000); + memset(MMU.ARM7_REG, 0, 0x10000); + + for(i = 0;i < 16;i++) + FIFOInit(MMU.fifos + i); + + MMU.DTCMRegion = 0; + MMU.ITCMRegion = 0x00800000; + + memset(MMU.timer, 0, sizeof(u16) * 2 * 4); + memset(MMU.timerMODE, 0, sizeof(s32) * 2 * 4); + memset(MMU.timerON, 0, sizeof(u32) * 2 * 4); + memset(MMU.timerRUN, 0, sizeof(u32) * 2 * 4); + memset(MMU.timerReload, 0, sizeof(u16) * 2 * 4); + + memset(MMU.reg_IME, 0, sizeof(u32) * 2); + memset(MMU.reg_IE, 0, sizeof(u32) * 2); + memset(MMU.reg_IF, 0, sizeof(u32) * 2); + + memset(MMU.DMAStartTime, 0, sizeof(u32) * 2 * 4); + memset(MMU.DMACycle, 0, sizeof(s32) * 2 * 4); + memset(MMU.DMACrt, 0, sizeof(u32) * 2 * 4); + memset(MMU.DMAing, 0, sizeof(BOOL) * 2 * 4); + + memset(MMU.dscard, 0, sizeof(nds_dscard) * 2); + + MainScreen.offset = 192; + SubScreen.offset = 0; +} + +void MMU_setRom(u8 * rom, u32 mask) +{ + unsigned int i; + MMU.CART_ROM = rom; + + for(i = 0x80; i<0xA0; ++i) + { + MMU_ARM9_MEM_MAP[i] = rom; + MMU_ARM7_MEM_MAP[i] = rom; + MMU_ARM9_MEM_MASK[i] = mask; + MMU_ARM7_MEM_MASK[i] = mask; + } + rom_mask = mask; +} + +void MMU_unsetRom() +{ + unsigned int i; + MMU.CART_ROM=MMU.UNUSED_RAM; + + for(i = 0x80; i<0xA0; ++i) + { + MMU_ARM9_MEM_MAP[i] = MMU.UNUSED_RAM; + MMU_ARM7_MEM_MAP[i] = MMU.UNUSED_RAM; + MMU_ARM9_MEM_MASK[i] = ROM_MASK; + MMU_ARM7_MEM_MASK[i] = ROM_MASK; + } + rom_mask = ROM_MASK; +} +char txt[80]; + +u8 FASTCALL MMU_read8(u32 proc, u32 adr) +{ + if((proc==ARMCPU_ARM9)&((adr&(~0x3FFF))==MMU.DTCMRegion)) + { + return ARM9Mem.ARM9_DTCM[adr&0x3FFF]; + } + + // CFlash reading, Mic + if ((adr>=0x9000000)&&(adr<0x9900000)) + return (unsigned char)cflash_read(adr); + + adr &= 0x0FFFFFFF; + + switch(adr) + { + case 0x027FFCDC : + return 0x20; + case 0x027FFCDD : + return 0x20; + case 0x027FFCE2 : + //execute = FALSE; + return 0xE0; + case 0x027FFCE3 : + return 0x80; + /*case REG_POSTFLG : + return 1; + case REG_IME : + execute = FALSE;*/ + default : + return MMU.MMU_MEM[proc][(adr>>20)&0xFF][adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF]]; + } +} + + + +u16 FASTCALL MMU_read16(u32 proc, u32 adr) +{ + if((proc == ARMCPU_ARM9) && ((adr & ~0x3FFF) == MMU.DTCMRegion)) + { + /* Returns data from DTCM (ARM9 only) */ + return T1ReadWord(ARM9Mem.ARM9_DTCM, adr & 0x3FFF); + } + + // CFlash reading, Mic + if ((adr>=0x08800000)&&(adr<0x09900000)) + return (unsigned short)cflash_read(adr); + + adr &= 0x0FFFFFFF; + + if((adr>>24)==4) + { + /* Adress is an IO register */ + switch(adr) + { + case REG_IPCFIFORECV : /* TODO (clear): ??? */ + execute = FALSE; + return 1; + + case REG_IME : + return (u16)MMU.reg_IME[proc]; + + case REG_IE : + return (u16)MMU.reg_IE[proc]; + case REG_IE + 2 : + return (u16)(MMU.reg_IE[proc]>>16); + + case REG_IF : + return (u16)MMU.reg_IF[proc]; + case REG_IF + 2 : + return (u16)(MMU.reg_IF[proc]>>16); + + case REG_TM0CNTL : + case REG_TM1CNTL : + case REG_TM2CNTL : + case REG_TM3CNTL : + return MMU.timer[proc][(adr&0xF)>>2]; + + case 0x04000630 : + LOG("vect res\r\n"); /* TODO (clear): ??? */ + //execute = FALSE; + return 0; + //case 0x27FFFAA : + //case 0x27FFFAC : + /*case 0x2330F84 : + if(click) execute = FALSE;*/ + //case 0x27FF018 : execute = FALSE; + case REG_POSTFLG : + return 1; + default : + break; + } + } + else + { + /* TODO (clear): i don't known what are these 'registers', perhaps reset vectors ... */ + switch(adr) + { + case 0x027FFCD8 : + return (0x20<<4); + case 0x027FFCDA : + return (0x20<<4); + case 0x027FFCDE : + return (0xE0<<4); + case 0x027FFCE0 : + //execute = FALSE; + return (0x80<<4); + default : + break; + } + } + + /* Returns data from memory */ + return T1ReadWord(MMU.MMU_MEM[proc][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[proc][(adr >> 20) & 0xFF]); +} + +u32 FASTCALL MMU_read32(u32 proc, u32 adr) +{ + if((proc == ARMCPU_ARM9) && ((adr & ~0x3FFF) == MMU.DTCMRegion)) + { + /* Returns data from DTCM (ARM9 only) */ + return T1ReadLong(ARM9Mem.ARM9_DTCM, adr & 0x3FFF); + } + + // CFlash reading, Mic + if ((adr>=0x9000000)&&(adr<0x9900000)) + return (unsigned long)cflash_read(adr); + + adr &= 0x0FFFFFFF; + + if((adr >> 24) == 4) + { + /* Adress is an IO register */ + switch(adr) + { + #ifdef RENDER3D + case 0x04000600 : + return ((OGLRender::nbpush[0]&1)<<13) | ((OGLRender::nbpush[2]&0x1F)<<8); + #endif + + case REG_IME : + return MMU.reg_IME[proc]; + case REG_IE : + return MMU.reg_IE[proc]; + case REG_IF : + return MMU.reg_IF[proc]; + + case REG_IPCFIFORECV : + { + u16 IPCFIFO_CNT = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184); + if(IPCFIFO_CNT&0x8000) + { + //execute = FALSE; + u32 fifonum = IPCFIFO+proc; + u32 val = FIFOValue(MMU.fifos + fifonum); + u32 remote = (proc+1) & 1; + u16 IPCFIFO_CNT_remote = T1ReadWord(MMU.MMU_MEM[remote][0x40], 0x184); + IPCFIFO_CNT |= (MMU.fifos[fifonum].empty<<8) | (MMU.fifos[fifonum].full<<9) | (MMU.fifos[fifonum].error<<14); + IPCFIFO_CNT_remote |= (MMU.fifos[fifonum].empty) | (MMU.fifos[fifonum].full<<1); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, IPCFIFO_CNT); + T1WriteWord(MMU.MMU_MEM[remote][0x40], 0x184, IPCFIFO_CNT_remote); + if(MMU.fifos[fifonum].empty) + MMU.reg_IF[proc] |= ((IPCFIFO_CNT & (1<<2))<<15);// & (MMU.reg_IME[proc]<<17);// & (MMU.reg_IE[proc] & (1<<17));// + return val; + } + } + return 0; + case REG_TM0CNTL : + case REG_TM1CNTL : + case REG_TM2CNTL : + case REG_TM3CNTL : + { + u32 val = T1ReadWord(MMU.MMU_MEM[proc][0x40], (adr + 2) & 0xFFF); + return MMU.timer[proc][(adr&0xF)>>2] | (val<<16); + } + case 0x04000640 : /* TODO (clear): again, ??? */ + LOG("read proj\r\n"); + return 0; + case 0x04000680 : + LOG("read roat\r\n"); + return 0; + case 0x04000620 : + LOG("point res\r\n"); + return 0; + + case REG_GCDATAIN: + { + u32 val; + + if(!MMU.dscard[proc].adress) return 0; + + val = T1ReadLong(MMU.CART_ROM, MMU.dscard[proc].adress); + + MMU.dscard[proc].adress += 4; /* increment adress */ + + MMU.dscard[proc].transfer_count--; /* update transfer counter */ + if(MMU.dscard[proc].transfer_count) /* if transfer is not ended */ + { + return val; /* return data */ + } + else /* transfer is done */ + { + T1WriteLong(MMU.MMU_MEM[proc][(REG_GCROMCTRL >> 20) & 0xff], REG_GCROMCTRL & 0xfff, T1ReadLong(MMU.MMU_MEM[proc][(REG_GCROMCTRL >> 20) & 0xff], REG_GCROMCTRL & 0xfff) & ~(0x00800000 | 0x80000000)); + /* = 0x7f7fffff */ + + /* if needed, throw irq for the end of transfer */ + if(T1ReadWord(MMU.MMU_MEM[proc][(REG_AUXSPICNT >> 20) & 0xff], REG_AUXSPICNT & 0xfff) & 0x4000) + { + if(proc == ARMCPU_ARM7) NDS_makeARM7Int(19); + else NDS_makeARM9Int(19); + } + + return val; + } + } + + default : + break; + } + } + + /* Returns data from memory */ + return T1ReadLong(MMU.MMU_MEM[proc][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[proc][(adr >> 20) & 0xFF]); +} + +void FASTCALL MMU_write8(u32 proc, u32 adr, u8 val) +{ + if((proc == ARMCPU_ARM9) && ((adr & ~0x3FFF) == MMU.DTCMRegion)) + { + /* Writes data in DTCM (ARM9 only) */ + ARM9Mem.ARM9_DTCM[adr&0x3FFF] = val; + return ; + } + + // CFlash writing, Mic + if ((adr>=0x9000000)&&(adr<0x9900000)) { + cflash_write(adr,val); + return; + } + + adr &= 0x0FFFFFFF; + + // This is bad, remove it + if(proc == ARMCPU_ARM7) + { + if ((adr>=0x04000400)&&(adr<0x0400051D)) + { + SPU_WriteByte(adr, val); + return; + } + } + + switch(adr) + { + /* TODO: EEEK ! Controls for VRAMs A, B, C, D are missing ! */ + /* TODO: Not all mappings of VRAMs are handled... (especially BG and OBJ modes) */ + case REG_VRAMCNTE : + if(proc == ARMCPU_ARM9) + { + if((val & 7) == 5) + { + ARM9Mem.ExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x80000; + ARM9Mem.ExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x82000; + ARM9Mem.ExtPal[0][2] = ARM9Mem.ARM9_LCD + 0x84000; + ARM9Mem.ExtPal[0][3] = ARM9Mem.ARM9_LCD + 0x86000; + } + else if((val & 7) == 3) + { + ARM9Mem.texPalSlot[0] = ARM9Mem.ARM9_LCD + 0x80000; + ARM9Mem.texPalSlot[1] = ARM9Mem.ARM9_LCD + 0x82000; + ARM9Mem.texPalSlot[2] = ARM9Mem.ARM9_LCD + 0x84000; + ARM9Mem.texPalSlot[3] = ARM9Mem.ARM9_LCD + 0x86000; + } + } + break; + + case REG_VRAMCNTF : + if(proc == ARMCPU_ARM9) + { + switch(val & 0x1F) + { + case 4 : + ARM9Mem.ExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x90000; + ARM9Mem.ExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x92000; + break; + + case 4 | (1 << 3) : + ARM9Mem.ExtPal[0][2] = ARM9Mem.ARM9_LCD + 0x90000; + ARM9Mem.ExtPal[0][3] = ARM9Mem.ARM9_LCD + 0x92000; + break; + + case 3 : + ARM9Mem.texPalSlot[0] = ARM9Mem.ARM9_LCD + 0x90000; + break; + + case 3 | (1 << 3) : + ARM9Mem.texPalSlot[1] = ARM9Mem.ARM9_LCD + 0x90000; + break; + + case 3 | (2 << 3) : + ARM9Mem.texPalSlot[2] = ARM9Mem.ARM9_LCD + 0x90000; + break; + + case 3 | (3 << 3) : + ARM9Mem.texPalSlot[3] = ARM9Mem.ARM9_LCD + 0x90000; + break; + + case 5 : + case 5 | (1 << 3) : + case 5 | (2 << 3) : + case 5 | (3 << 3) : + ARM9Mem.ObjExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x90000; + ARM9Mem.ObjExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x92000; + break; + } + } + break; + case REG_VRAMCNTG : + if(proc == ARMCPU_ARM9) + { + switch(val & 0x1F) + { + case 4 : + ARM9Mem.ExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x94000; + ARM9Mem.ExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x96000; + break; + + case 4 | (1 << 3) : + ARM9Mem.ExtPal[0][2] = ARM9Mem.ARM9_LCD + 0x94000; + ARM9Mem.ExtPal[0][3] = ARM9Mem.ARM9_LCD + 0x96000; + break; + + case 3 : + ARM9Mem.texPalSlot[0] = ARM9Mem.ARM9_LCD + 0x94000; + break; + + case 3 | (1 << 3) : + ARM9Mem.texPalSlot[1] = ARM9Mem.ARM9_LCD + 0x94000; + break; + + case 3 | (2 << 3) : + ARM9Mem.texPalSlot[2] = ARM9Mem.ARM9_LCD + 0x94000; + break; + + case 3 | (3 << 3) : + ARM9Mem.texPalSlot[3] = ARM9Mem.ARM9_LCD + 0x94000; + break; + + case 5 : + case 5 | (1 << 3) : + case 5 | (2 << 3) : + case 5 | (3 << 3) : + ARM9Mem.ObjExtPal[0][0] = ARM9Mem.ARM9_LCD + 0x94000; + ARM9Mem.ObjExtPal[0][1] = ARM9Mem.ARM9_LCD + 0x96000; + break; + } + } + break; + + case REG_VRAMCNTH : + if(proc == ARMCPU_ARM9) + { + if((val & 7) == 2) + { + ARM9Mem.ExtPal[1][0] = ARM9Mem.ARM9_LCD + 0x98000; + ARM9Mem.ExtPal[1][1] = ARM9Mem.ARM9_LCD + 0x9A000; + ARM9Mem.ExtPal[1][2] = ARM9Mem.ARM9_LCD + 0x9C000; + ARM9Mem.ExtPal[1][3] = ARM9Mem.ARM9_LCD + 0x9E000; + } + } + break; + + case REG_VRAMCNTI : + if(proc == ARMCPU_ARM9) + { + if((val & 7) == 3) + { + ARM9Mem.ObjExtPal[1][0] = ARM9Mem.ARM9_LCD + 0xA0000; + ARM9Mem.ObjExtPal[1][1] = ARM9Mem.ARM9_LCD + 0xA2000; + } + } + break; +#ifdef LOG_CARD + case 0x040001A0 : /* TODO (clear): ??? */ + case 0x040001A1 : + case 0x040001A2 : + case 0x040001A8 : + case 0x040001A9 : + case 0x040001AA : + case 0x040001AB : + case 0x040001AC : + case 0x040001AD : + case 0x040001AE : + case 0x040001AF : + LOG("%08X : %02X\r\n", adr, val); +#endif + + default : + break; + } + + MMU.MMU_MEM[proc][(adr>>20)&0xFF][adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF]]=val; +} + +u16 partie = 1; + +void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val) +{ + if((proc == ARMCPU_ARM9) && ((adr & ~0x3FFF) == MMU.DTCMRegion)) + { + /* Writes in DTCM (ARM9 only) */ + T1WriteWord(ARM9Mem.ARM9_DTCM, adr & 0x3FFF, val); + return; + } + + // CFlash writing, Mic + if ((adr>=0x08800000)&&(adr<0x09900000)) + { + cflash_write(adr,val); + return; + } + + adr &= 0x0FFFFFFF; + + // This is bad, remove it + if(proc == ARMCPU_ARM7) + { + if ((adr>=0x04000400)&&(adr<0x0400051D)) + { + SPU_WriteWord(adr, val); + return; + } + } + + if((adr >> 24) == 4) + { + /* Adress is an IO register */ + switch(adr) + { + #ifdef RENDER3D + case 0x04000610 : + if(proc == ARMCPU_ARM9) + { + LOG("CUT DEPTH %08X\r\n", val); + } + return; + case 0x04000340 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glAlphaFunc(val); + } + return; + case REG_DISPA_DISP3DCNT : + if(proc == ARMCPU_ARM9) + { + OGLRender::glControl(val); + } + return; + case 0x04000354 : + if(proc == ARMCPU_ARM9) + OGLRender::glClearDepth(val); + return; + #endif + + case REG_POWCNT1 : + if(proc == ARMCPU_ARM9) + { + if(val & (1<<15)) + { + LOG("Main core on top\n"); + MainScreen.offset = 0; + SubScreen.offset = 192; + //nds.swapScreen(); + } + else + { + LOG("Main core on bottom (%04X)\n", val); + MainScreen.offset = 192; + SubScreen.offset = 0; + } + } + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x304, val); + return; + + case REG_AUXSPICNT: + T1WriteWord(MMU.MMU_MEM[proc][(REG_AUXSPICNT >> 20) & 0xff], REG_AUXSPICNT & 0xfff, val); + AUX_SPI_CNT = val; + + if (val == 0) + mc_reset_com(&MMU.bupmem); /* reset backup memory device communication */ + return; + + case REG_AUXSPIDATA: + if(val!=0) + { + AUX_SPI_CMD = val & 0xFF; + } + + T1WriteWord(MMU.MMU_MEM[proc][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); + return; + + case REG_SPICNT : + if(proc == ARMCPU_ARM7) + { + SPI_CNT = val; + + //MMU.fw.com == 0; /* reset fw device communication */ + + mc_reset_com(&MMU.fw); /* reset fw device communication */ + } + + T1WriteWord(MMU.MMU_MEM[proc][(REG_SPICNT >> 20) & 0xff], REG_SPICNT & 0xfff, val); + return; + + case REG_SPIDATA : + if(proc==ARMCPU_ARM7) + { + u16 spicnt; + + if(val!=0) + { + SPI_CMD = val; + } + + spicnt = T1ReadWord(MMU.MMU_MEM[proc][(REG_SPICNT >> 20) & 0xff], REG_SPICNT & 0xfff); + + switch((spicnt >> 8) & 0x3) + { + case 0 : + break; + + case 1 : /* firmware memory device */ + if(spicnt & 0x3 != 0) /* check SPI baudrate (must be 4mhz) */ + { + T1WriteWord(MMU.MMU_MEM[proc][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, 0); + break; + } + T1WriteWord(MMU.MMU_MEM[proc][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, fw_transfer(&MMU.fw, val)); + return; + + case 2 : + switch(SPI_CMD & 0x70) + { + case 0x00 : + val = 0; + break; + case 0x10 : + //execute = FALSE; + if(SPI_CNT&(1<<11)) + { + if(partie) + { + val = ((nds.touchY<<3)&0x7FF); + partie = 0; + //execute = FALSE; + break; + } + val = (nds.touchY>>5); + partie = 1; + break; + } + val = ((nds.touchY<<3)&0x7FF); + partie = 1; + break; + case 0x20 : + val = 0; + break; + case 0x30 : + val = 0; + break; + case 0x40 : + val = 0; + break; + case 0x50 : + if(spicnt & 0x800) + { + if(partie) + { + val = ((nds.touchX<<3)&0x7FF); + partie = 0; + break; + } + val = (nds.touchX>>5); + partie = 1; + break; + } + val = ((nds.touchX<<3)&0x7FF); + partie = 1; + break; + case 0x60 : + val = 0; + break; + case 0x70 : + val = 0; + break; + } + break; + + case 3 : + /* NOTICE: Device 3 of SPI is reserved (unused and unusable) */ + break; + } + } + + T1WriteWord(MMU.MMU_MEM[proc][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, val); + return; + + /* NOTICE: Perhaps we have to use gbatek-like reg names instead of libnds-like ones ...*/ + + case REG_DISPA_BG0HOFS : + GPU_scrollX(MainScreen.gpu, 0, val); + return; + case REG_DISPA_BG1HOFS : + GPU_scrollX(MainScreen.gpu, 1, val); + return; + case REG_DISPA_BG2HOFS : + GPU_scrollX(MainScreen.gpu, 2, val); + return; + case REG_DISPA_BG3HOFS : + GPU_scrollX(MainScreen.gpu, 3, val); + return; + case REG_DISPB_BG0HOFS : + GPU_scrollX(SubScreen.gpu, 0, val); + return; + case REG_DISPB_BG1HOFS : + GPU_scrollX(SubScreen.gpu, 1, val); + return; + case REG_DISPB_BG2HOFS : + GPU_scrollX(SubScreen.gpu, 2, val); + return; + case REG_DISPB_BG3HOFS : + GPU_scrollX(SubScreen.gpu, 3, val); + return; + case REG_DISPA_BG0VOFS : + GPU_scrollY(MainScreen.gpu, 0, val); + return; + case REG_DISPA_BG1VOFS : + GPU_scrollY(MainScreen.gpu, 1, val); + return; + case REG_DISPA_BG2VOFS : + GPU_scrollY(MainScreen.gpu, 2, val); + return; + case REG_DISPA_BG3VOFS : + GPU_scrollY(MainScreen.gpu, 3, val); + return; + case REG_DISPB_BG0VOFS : + GPU_scrollY(SubScreen.gpu, 0, val); + return; + case REG_DISPB_BG1VOFS : + GPU_scrollY(SubScreen.gpu, 1, val); + return; + case REG_DISPB_BG2VOFS : + GPU_scrollY(SubScreen.gpu, 2, val); + return; + case REG_DISPB_BG3VOFS : + GPU_scrollY(SubScreen.gpu, 3, val); + return; + case REG_DISPA_BG2PA : + GPU_setPA(MainScreen.gpu, 2, val); + return; + case REG_DISPA_BG2PB : + GPU_setPB(MainScreen.gpu, 2, val); + return; + case REG_DISPA_BG2PC : + GPU_setPC(MainScreen.gpu, 2, val); + return; + case REG_DISPA_BG2PD : + GPU_setPD(MainScreen.gpu, 2, val); + return; + case REG_DISPB_BG2PA : + GPU_setPA(SubScreen.gpu, 2, val); + return; + case REG_DISPB_BG2PB : + GPU_setPB(SubScreen.gpu, 2, val); + return; + case REG_DISPB_BG2PC : + GPU_setPC(SubScreen.gpu, 2, val); + return; + case REG_DISPB_BG2PD : + GPU_setPD(SubScreen.gpu, 2, val); + return; + case REG_DISPA_BG3PA : + GPU_setPA(MainScreen.gpu, 3, val); + return; + case REG_DISPA_BG3PB : + GPU_setPB(MainScreen.gpu, 3, val); + return; + case REG_DISPA_BG3PC : + GPU_setPC(MainScreen.gpu, 3, val); + return; + case REG_DISPA_BG3PD : + GPU_setPD(MainScreen.gpu, 3, val); + return; + case REG_DISPB_BG3PA : + GPU_setPA(SubScreen.gpu, 3, val); + return; + case REG_DISPB_BG3PB : + GPU_setPB(SubScreen.gpu, 3, val); + return; + case REG_DISPB_BG3PC : + GPU_setPC(SubScreen.gpu, 3, val); + return; + case REG_DISPB_BG3PD : + GPU_setPD(SubScreen.gpu, 3, val); + return; + case REG_DISPA_BG2XL : + GPU_setXL(MainScreen.gpu, 2, val); + return; + case REG_DISPA_BG2XH : + GPU_setXH(MainScreen.gpu, 2, val); + return; + case REG_DISPB_BG2XL : + GPU_setXL(SubScreen.gpu, 2, val); + return; + case REG_DISPB_BG2XH : + GPU_setXH(SubScreen.gpu, 2, val); + return; + case REG_DISPA_BG3XL : + GPU_setXL(MainScreen.gpu, 3, val); + return; + case REG_DISPA_BG3XH : + GPU_setXH(MainScreen.gpu, 3, val); + return; + case REG_DISPB_BG3XL : + GPU_setXL(SubScreen.gpu, 3, val); + return; + case REG_DISPB_BG3XH : + GPU_setXH(SubScreen.gpu, 3, val); + return; + case REG_DISPA_BG2YL : + GPU_setYL(MainScreen.gpu, 2, val); + return; + case REG_DISPA_BG2YH : + GPU_setYH(MainScreen.gpu, 2, val); + return; + case REG_DISPB_BG2YL : + GPU_setYL(SubScreen.gpu, 2, val); + return; + case REG_DISPB_BG2YH : + GPU_setYH(SubScreen.gpu, 2, val); + return; + case REG_DISPA_BG3YL : + GPU_setYL(MainScreen.gpu, 3, val); + return; + case REG_DISPA_BG3YH : + GPU_setYH(MainScreen.gpu, 3, val); + return; + case REG_DISPB_BG3YL : + GPU_setYL(SubScreen.gpu, 3, val); + return; + case REG_DISPB_BG3YH : + GPU_setYH(SubScreen.gpu, 3, val); + return; + case REG_DISPA_BG0CNT : + //GPULOG("MAIN BG0 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(MainScreen.gpu, 0, val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x8, val); + return; + case REG_DISPA_BG1CNT : + //GPULOG("MAIN BG1 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(MainScreen.gpu, 1, val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xA, val); + return; + case REG_DISPA_BG2CNT : + //GPULOG("MAIN BG2 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(MainScreen.gpu, 2, val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xC, val); + return; + case REG_DISPA_BG3CNT : + //GPULOG("MAIN BG3 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(MainScreen.gpu, 3, val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xE, val); + return; + case REG_DISPB_BG0CNT : + //GPULOG("SUB BG0 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(SubScreen.gpu, 0, val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x1008, val); + return; + case REG_DISPB_BG1CNT : + //GPULOG("SUB BG1 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(SubScreen.gpu, 1, val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x100A, val); + return; + case REG_DISPB_BG2CNT : + //GPULOG("SUB BG2 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(SubScreen.gpu, 2, val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x100C, val); + return; + case REG_DISPB_BG3CNT : + //GPULOG("SUB BG3 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(SubScreen.gpu, 3, val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x100E, val); + return; + + case REG_IME : + MMU.reg_IME[proc] = val&1; + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x208, val); + return; + + case REG_IE : + MMU.reg_IE[proc] = (MMU.reg_IE[proc]&0xFFFF0000) | val; + return; + case REG_IE + 2 : + execute = FALSE; + MMU.reg_IE[proc] = (MMU.reg_IE[proc]&0xFFFF) | (((u32)val)<<16); + return; + + case REG_IF : + execute = FALSE; + MMU.reg_IF[proc] &= (~((u32)val)); + return; + case REG_IF + 2 : + execute = FALSE; + MMU.reg_IF[proc] &= (~(((u32)val)<<16)); + return; + + case REG_IPCSYNC : + { + u32 remote = (proc+1)&1; + u16 IPCSYNC_remote = T1ReadWord(MMU.MMU_MEM[remote][0x40], 0x180); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x180, (val&0xFFF0)|((IPCSYNC_remote>>8)&0xF)); + T1WriteWord(MMU.MMU_MEM[remote][0x40], 0x180, (IPCSYNC_remote&0xFFF0)|((val>>8)&0xF)); + MMU.reg_IF[remote] |= ((IPCSYNC_remote & (1<<14))<<2) & ((val & (1<<13))<<3);// & (MMU.reg_IME[remote] << 16);// & (MMU.reg_IE[remote] & (1<<16));// + //execute = FALSE; + } + return; + case REG_IPCFIFOCNT : + { + if(val & 0x4008) + { + FIFOInit(MMU.fifos + (IPCFIFO+((proc+1)&1))); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, (val & 0xBFF4) | 1); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184) | 1); + MMU.reg_IF[proc] |= ((val & 4)<<15);// & (MMU.reg_IME[proc]<<17);// & (MMU.reg_IE[proc]&0x20000);// + return; + } + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184) | (val & 0xBFF4)); + } + return; + case REG_TM0CNTL : + case REG_TM1CNTL : + case REG_TM2CNTL : + case REG_TM3CNTL : + MMU.timerReload[proc][(adr>>2)&3] = val; + return; + case REG_TM0CNTH : + case REG_TM1CNTH : + case REG_TM2CNTH : + case REG_TM3CNTH : + if(val&0x80) + { + if(!(val&4)) MMU.timer[proc][((adr-2)>>2)&0x3] = MMU.timerReload[proc][((adr-2)>>2)&0x3]; + else MMU.timer[proc][((adr-2)>>2)&0x3] = 0; + } + MMU.timerON[proc][((adr-2)>>2)&0x3] = val & 0x80; + switch(val&7) + { + case 0 : + MMU.timerMODE[proc][((adr-2)>>2)&0x3] = 0+1;//proc; + break; + case 1 : + MMU.timerMODE[proc][((adr-2)>>2)&0x3] = 6+1;//proc; + break; + case 2 : + MMU.timerMODE[proc][((adr-2)>>2)&0x3] = 8+1;//proc; + break; + case 3 : + MMU.timerMODE[proc][((adr-2)>>2)&0x3] = 10+1;//proc; + break; + default : + MMU.timerMODE[proc][((adr-2)>>2)&0x3] = 0xFFFF; + break; + } + if(!(val & 0x80)) + MMU.timerRUN[proc][((adr-2)>>2)&0x3] = FALSE; + T1WriteWord(MMU.MMU_MEM[proc][0x40], adr & 0xFFF, val); + return; + case REG_DISPA_DISPCNT+2 : + { + //execute = FALSE; + u32 v = (T1ReadLong(MMU.MMU_MEM[proc][0x40], 0) & 0xFFFF) | ((u32) val << 16); + GPU_setVideoProp(MainScreen.gpu, v); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0, v); + } + return; + case REG_DISPA_DISPCNT : + { + u32 v = (T1ReadLong(MMU.MMU_MEM[proc][0x40], 0) & 0xFFFF0000) | val; + GPU_setVideoProp(MainScreen.gpu, v); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0, v); + } + return; + case REG_DISPB_DISPCNT+2 : + { + //execute = FALSE; + u32 v = (T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x1000) & 0xFFFF) | ((u32) val << 16); + GPU_setVideoProp(SubScreen.gpu, v); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x1000, v); + } + return; + case REG_DISPB_DISPCNT : + { + u32 v = (T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x1000) & 0xFFFF0000) | val; + GPU_setVideoProp(SubScreen.gpu, v); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x1000, v); + } + return; + //case 0x020D8460 : + /*case 0x0235A904 : + LOG("ECRIRE %d %04X\r\n", proc, val); + execute = FALSE;*/ + case REG_DMA0CNTH : + { + u32 v; + + //if(val&0x8000) execute = FALSE; + //LOG("16 bit dma0 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xBA, val); + DMASrc[proc][0] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB0); + DMADst[proc][0] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB4); + v = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB8); + MMU.DMAStartTime[proc][0] = (proc ? (v>>28) & 0x3 : (v>>27) & 0x7); + MMU.DMACrt[proc][0] = v; + if(MMU.DMAStartTime[proc][0] == 0) + MMU_doDMA(proc, 0); + #ifdef LOG_DMA2 + //else + { + LOG("proc %d, dma %d src %08X dst %08X %s\r\n", proc, 0, DMASrc[proc][0], DMADst[proc][0], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + case REG_DMA1CNTH : + { + u32 v; + //if(val&0x8000) execute = FALSE; + //LOG("16 bit dma1 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xC6, val); + DMASrc[proc][1] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xBC); + DMASrc[proc][1] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xC0); + v = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xC4); + MMU.DMAStartTime[proc][1] = (proc ? (v>>28) & 0x3 : (v>>27) & 0x7); + MMU.DMACrt[proc][1] = v; + if(MMU.DMAStartTime[proc][1] == 0) + MMU_doDMA(proc, 1); + #ifdef LOG_DMA2 + //else + { + LOG("proc %d, dma %d src %08X dst %08X %s\r\n", proc, 1, DMASrc[proc][1], DMADst[proc][1], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + case REG_DMA2CNTH : + { + u32 v; + //if(val&0x8000) execute = FALSE; + //LOG("16 bit dma2 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xD2, val); + DMASrc[proc][2] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xC8); + DMASrc[proc][2] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xCC); + v = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xD0); + MMU.DMAStartTime[proc][2] = (proc ? (v>>28) & 0x3 : (v>>27) & 0x7); + MMU.DMACrt[proc][2] = v; + if(MMU.DMAStartTime[proc][2] == 0) + MMU_doDMA(proc, 2); + #ifdef LOG_DMA2 + //else + { + LOG("proc %d, dma %d src %08X dst %08X %s\r\n", proc, 2, DMASrc[proc][2], DMADst[proc][2], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + case REG_DMA3CNTH : + { + u32 v; + //if(val&0x8000) execute = FALSE; + //LOG("16 bit dma3 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0xDE, val); + DMASrc[proc][3] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xD4); + DMASrc[proc][3] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xD8); + v = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xDC); + MMU.DMAStartTime[proc][3] = (proc ? (v>>28) & 0x3 : (v>>27) & 0x7); + MMU.DMACrt[proc][3] = v; + + if(MMU.DMAStartTime[proc][3] == 0) + MMU_doDMA(proc, 3); + #ifdef LOG_DMA2 + //else + { + LOG("proc %d, dma %d src %08X dst %08X %s\r\n", proc, 3, DMASrc[proc][3], DMADst[proc][3], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + //case REG_AUXSPICNT : execute = FALSE; + default : + T1WriteWord(MMU.MMU_MEM[proc][0x40], adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF], val); + return; + } + } + T1WriteWord(MMU.MMU_MEM[proc][(adr>>20)&0xFF], adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF], val); +} + +u32 testval = 0; + +void FASTCALL MMU_write32(u32 proc, u32 adr, u32 val) +{ + if((proc==ARMCPU_ARM9)&((adr&(~0x3FFF))==MMU.DTCMRegion)) + { + T1WriteLong(ARM9Mem.ARM9_DTCM, adr & 0x3FFF, val); + return ; + } + + // CFlash writing, Mic + if ((adr>=0x9000000)&&(adr<0x9900000)) { + cflash_write(adr,val); + return; + } + + adr &= 0x0FFFFFFF; + + // This is bad, remove it + if(proc == ARMCPU_ARM7) + { + if ((adr>=0x04000400)&&(adr<0x0400051D)) + { + SPU_WriteLong(adr, val); + return; + } + } + + if((adr>>24)==4) + { + switch(adr) + { +#ifdef RENDER3D + case 0x040004AC : + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x4AC, val); + if(proc==ARMCPU_ARM9) + OGLRender::glTexImage2D(testval, TRUE); + //execute = FALSE; + return; + case 0x040004A8 : + if(proc==ARMCPU_ARM9) + { + OGLRender::glTexImage2D(val, FALSE); + //execute = FALSE; + testval = val; + } + return; + case 0x04000488 : + if(proc==ARMCPU_ARM9) + { + OGLRender::glTexCoord(val); + //execute = FALSE; + } + return; + case 0x0400046C : + if(proc==ARMCPU_ARM9) + { + OGLRender::glScale(val); + } + return; + case 0x04000490 : + if(proc==ARMCPU_ARM9) + { + //GPULOG("VERTEX 10 %d\r\n",val); + } + return; + case 0x04000494 : + if(proc==ARMCPU_ARM9) + { + //GPULOG(printf(txt, "VERTEXY %d\r\n",val); + } + return; + case 0x04000498 : + if(proc==ARMCPU_ARM9) + { + //GPULOG("VERTEXZ %d\r\n",val); + } + return; + case 0x0400049C : + if(proc==ARMCPU_ARM9) + { + //GPULOG("VERTEYZ %d\r\n",val); + } + return; + case 0x04000400 : + if(proc==ARMCPU_ARM9) + { + OGLRender::glCallList(val); + } + return; + case 0x04000450 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glRestore(); + } + return; + case 0x04000580 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glViewPort(val); + } + return; + case 0x04000350 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glClearColor(val); + } + return; + case 0x04000440 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glMatrixMode(val); + } + return; + case 0x04000458 : + if(proc == ARMCPU_ARM9) + { + OGLRender::ML4x4ajouter(val); + } + return; + case 0x0400044C : + if(proc == ARMCPU_ARM9) + { + OGLRender::glStoreMatrix(val); + } + return; + case 0x0400045C : + if(proc == ARMCPU_ARM9) + { + OGLRender::ML4x3ajouter(val); + } + return; + case 0x04000444 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glPushMatrix(); + } + return; + case 0x04000448 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glPopMatrix(val); + } + return; + case 0x04000470 : + if(proc == ARMCPU_ARM9) + { + OGLRender::addTrans(val); + } + return; + case 0x04000460 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glMultMatrix4x4(val); + } + return; + case 0x04000464 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glMultMatrix4x3(val); + } + return; + case 0x04000468 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glMultMatrix3x3(val); + } + return; + case 0x04000500 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glBegin(val); + } + return; + case 0x04000504 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glEnd(); + } + return; + case 0x04000480 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glColor3b(val); + } + return; + case 0x0400048C : + if(proc == ARMCPU_ARM9) + { + OGLRender::glVertex3(val); + } + return; + case 0x04000540 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glFlush(); + } + return; + case 0x04000454 : + if(proc == ARMCPU_ARM9) + { + OGLRender::glLoadIdentity(); + } + return; +#endif + case REG_DISPA_BG2PA : + GPU_setPAPB(MainScreen.gpu, 2, val); + return; + case REG_DISPA_BG2PC : + GPU_setPCPD(MainScreen.gpu, 2, val); + return; + + case REG_DISPB_BG2PA : + GPU_setPAPB(SubScreen.gpu, 2, val); + return; + case REG_DISPB_BG2PC : + GPU_setPCPD(SubScreen.gpu, 2, val); + return; + case REG_DISPA_BG3PA : + GPU_setPAPB(MainScreen.gpu, 3, val); + return; + case REG_DISPA_BG3PC : + GPU_setPCPD(MainScreen.gpu, 3, val); + return; + case REG_DISPB_BG3PA : + GPU_setPAPB(SubScreen.gpu, 3, val); + return; + case REG_DISPB_BG3PC : + GPU_setPCPD(SubScreen.gpu, 3, val); + return; + case REG_DISPA_BG2XL : + GPU_setX(MainScreen.gpu, 2, val); + return; + case REG_DISPA_BG2YL : + GPU_setY(MainScreen.gpu, 2, val); + return; + case REG_DISPB_BG2XL : + GPU_setX(SubScreen.gpu, 2, val); + return; + case REG_DISPB_BG2YL : + GPU_setY(SubScreen.gpu, 2, val); + return; + case REG_DISPA_BG3XL : + GPU_setX(MainScreen.gpu, 3, val); + return; + case REG_DISPA_BG3YL : + GPU_setY(MainScreen.gpu, 3, val); + return; + case REG_DISPB_BG3XL : + GPU_setX(SubScreen.gpu, 3, val); + return; + case REG_DISPB_BG3YL : + GPU_setY(SubScreen.gpu, 3, val); + return; + case REG_DISPA_BG0HOFS : + GPU_scrollXY(MainScreen.gpu, 0, val); + return; + case REG_DISPA_BG1HOFS : + GPU_scrollXY(MainScreen.gpu, 1, val); + return; + case REG_DISPA_BG2HOFS : + GPU_scrollXY(MainScreen.gpu, 2, val); + return; + case REG_DISPA_BG3HOFS : + GPU_scrollXY(MainScreen.gpu, 3, val); + return; + case REG_DISPB_BG0HOFS : + GPU_scrollXY(SubScreen.gpu, 0, val); + return; + case REG_DISPB_BG1HOFS : + GPU_scrollXY(SubScreen.gpu, 1, val); + return; + case REG_DISPB_BG2HOFS : + GPU_scrollXY(SubScreen.gpu, 2, val); + return; + case REG_DISPB_BG3HOFS : + GPU_scrollXY(SubScreen.gpu, 3, val); + return; + case REG_DISPA_DISPCNT : + GPU_setVideoProp(MainScreen.gpu, val); + + //GPULOG("MAIN INIT 32B %08X\r\n", val); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0, val); + return; + + case REG_DISPB_DISPCNT : + GPU_setVideoProp(SubScreen.gpu, val); + //GPULOG("SUB INIT 32B %08X\r\n", val); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x1000, val); + return; + + case REG_IME : + MMU.reg_IME[proc] = val & 1; + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x208, val); + return; + + case REG_IE : + MMU.reg_IE[proc] = val; + return; + + case REG_IF : + MMU.reg_IF[proc] &= (~val); + return; + case REG_TM0CNTL : + case REG_TM1CNTL : + case REG_TM2CNTL : + case REG_TM3CNTL : + MMU.timerReload[proc][(adr>>2)&0x3] = (u16)val; + if(val&0x800000) + { + if(!(val&40000)) MMU.timer[proc][(adr>>2)&0x3] = MMU.timerReload[proc][(adr>>2)&0x3]; + else MMU.timer[proc][(adr>>2)&0x3] = 0; + } + MMU.timerON[proc][(adr>>2)&0x3] = val & 0x800000; + switch((val>>16)&7) + { + case 0 : + MMU.timerMODE[proc][(adr>>2)&0x3] = 0+1;//proc; + break; + case 1 : + MMU.timerMODE[proc][(adr>>2)&0x3] = 6+1;//proc; + break; + case 2 : + MMU.timerMODE[proc][(adr>>2)&0x3] = 8+1;//proc; + break; + case 3 : + MMU.timerMODE[proc][(adr>>2)&0x3] = 10+1;//proc; + break; + default : + MMU.timerMODE[proc][(adr>>2)&0x3] = 0xFFFF; + break; + } + if(!(val & 0x800000)) + { + MMU.timerRUN[proc][(adr>>2)&0x3] = FALSE; + } + T1WriteLong(MMU.MMU_MEM[proc][0x40], adr & 0xFFF, val); + return; + case REG_DIVDENOM : + { + u16 cnt; + s64 num = 0; + s64 den = 1; + s64 res; + s64 mod; + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x298, val); + cnt = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x280); + switch(cnt&3) + { + case 0: + { + num = (s64) (s32) T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x290); + den = (s64) (s32) T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x298); + } + break; + case 1: + { + num = (s64) T1ReadQuad(MMU.MMU_MEM[proc][0x40], 0x290); + den = (s64) (s32) T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x298); + } + break; + case 2: + { + return; + } + break; + default: + break; + } + if(den==0) + { + res = 0; + mod = 0; + cnt |= 0x4000; + cnt &= 0x7FFF; + } + else + { + res = num / den; + mod = num % den; + cnt &= 0x3FFF; + } + DIVLOG("BOUT1 %08X%08X / %08X%08X = %08X%08X\r\n", (u32)(num>>32), (u32)num, + (u32)(den>>32), (u32)den, + (u32)(res>>32), (u32)res); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A0, (u32) res); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A4, (u32) (res >> 32)); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A8, (u32) mod); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2AC, (u32) (mod >> 32)); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x280, cnt); + } + return; + case REG_DIVDENOM+4 : + { + u16 cnt; + s64 num = 0; + s64 den = 1; + s64 res; + s64 mod; + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x29C, val); + cnt = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x280); + switch(cnt&3) + { + case 0: + { + return; + } + break; + case 1: + { + return; + } + break; + case 2: + { + num = (s64) T1ReadQuad(MMU.MMU_MEM[proc][0x40], 0x290); + den = (s64) T1ReadQuad(MMU.MMU_MEM[proc][0x40], 0x298); + } + break; + default: + break; + } + if(den==0) + { + res = 0; + mod = 0; + cnt |= 0x4000; + cnt &= 0x7FFF; + } + else + { + res = num / den; + mod = num % den; + cnt &= 0x3FFF; + } + DIVLOG("BOUT2 %08X%08X / %08X%08X = %08X%08X\r\n", (u32)(num>>32), (u32)num, + (u32)(den>>32), (u32)den, + (u32)(res>>32), (u32)res); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A0, (u32) res); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A4, (u32) (res >> 32)); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2A8, (u32) mod); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2AC, (u32) (mod >> 32)); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x280, cnt); + } + return; + case REG_SQRTPARAM : + { + u16 cnt; + u64 v = 1; + //execute = FALSE; + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2B8, val); + cnt = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x2B0); + switch(cnt&1) + { + case 0: + v = (u64) T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x2B8); + break; + case 1: + return; + } + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2B4, (u32) sqrt(v)); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2B0, cnt & 0x7FFF); + SQRTLOG("BOUT1 sqrt(%08X%08X) = %08X\r\n", (u32)(v>>32), (u32)v, + T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x2B4)); + } + return; + case REG_SQRTPARAM+4 : + { + u16 cnt; + u64 v = 1; + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2BC, val); + cnt = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x2B0); + switch(cnt&1) + { + case 0: + return; + //break; + case 1: + v = T1ReadQuad(MMU.MMU_MEM[proc][0x40], 0x2B8); + break; + } + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2B4, (u32) sqrt(v)); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x2B0, cnt & 0x7FFF); + SQRTLOG("BOUT2 sqrt(%08X%08X) = %08X\r\n", (u32)(v>>32), (u32)v, + T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x2B4)); + } + return; + case REG_IPCSYNC : + { + //execute=FALSE; + u32 remote = (proc+1)&1; + u32 IPCSYNC_remote = T1ReadLong(MMU.MMU_MEM[remote][0x40], 0x180); + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x180, (val&0xFFF0)|((IPCSYNC_remote>>8)&0xF)); + T1WriteLong(MMU.MMU_MEM[remote][0x40], 0x180, (IPCSYNC_remote&0xFFF0)|((val>>8)&0xF)); + MMU.reg_IF[remote] |= ((IPCSYNC_remote & (1<<14))<<2) & ((val & (1<<13))<<3);// & (MMU.reg_IME[remote] << 16);// & (MMU.reg_IE[remote] & (1<<16));// + } + return; + case REG_IPCFIFOCNT : + if(val & 0x4008) + { + FIFOInit(MMU.fifos + (IPCFIFO+((proc+1)&1))); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, (val & 0xBFF4) | 1); + T1WriteWord(MMU.MMU_MEM[(proc+1)&1][0x40], 0x184, T1ReadWord(MMU.MMU_MEM[(proc+1)&1][0x40], 0x184) | 256); + MMU.reg_IF[proc] |= ((val & 4)<<15);// & (MMU.reg_IME[proc] << 17);// & (MMU.reg_IE[proc] & 0x20000);// + return; + } + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, val & 0xBFF4); + //execute = FALSE; + return; + case REG_IPCFIFOSEND : + { + u16 IPCFIFO_CNT = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184); + if(IPCFIFO_CNT&0x8000) + { + //if(val==43) execute = FALSE; + u32 remote = (proc+1)&1; + u32 fifonum = IPCFIFO+remote; + u16 IPCFIFO_CNT_remote; + FIFOAdd(MMU.fifos + fifonum, val); + IPCFIFO_CNT = (IPCFIFO_CNT & 0xFFFC) | (MMU.fifos[fifonum].full<<1); + IPCFIFO_CNT_remote = T1ReadWord(MMU.MMU_MEM[remote][0x40], 0x184); + IPCFIFO_CNT_remote = (IPCFIFO_CNT_remote & 0xFCFF) | (MMU.fifos[fifonum].full<<10); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, IPCFIFO_CNT); + T1WriteWord(MMU.MMU_MEM[remote][0x40], 0x184, IPCFIFO_CNT_remote); + MMU.reg_IF[remote] |= ((IPCFIFO_CNT_remote & (1<<10))<<8);// & (MMU.reg_IME[remote] << 18);// & (MMU.reg_IE[remote] & 0x40000);// + //execute = FALSE; + } + } + return; + case REG_DMA0CNTL : + //LOG("32 bit dma0 %04X\r\n", val); + DMASrc[proc][0] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB0); + DMADst[proc][0] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB4); + MMU.DMAStartTime[proc][0] = (proc ? (val>>28) & 0x3 : (val>>27) & 0x7); + MMU.DMACrt[proc][0] = val; + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0xB8, val); + if(MMU.DMAStartTime[proc][0] == 0) + MMU_doDMA(proc, 0); + #ifdef LOG_DMA2 + else + { + LOG("proc %d, dma %d src %08X dst %08X start taille %d %d\r\n", proc, 0, DMASrc[proc][0], DMADst[proc][0], 0, ((MMU.DMACrt[proc][0]>>27)&7)); + } + #endif + //execute = FALSE; + return; + case REG_DMA1CNTL : + //LOG("32 bit dma1 %04X\r\n", val); + DMASrc[proc][1] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xBC); + DMADst[proc][1] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xC0); + MMU.DMAStartTime[proc][1] = (proc ? (val>>28) & 0x3 : (val>>27) & 0x7); + MMU.DMACrt[proc][1] = val; + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0xC4, val); + if(MMU.DMAStartTime[proc][1] == 0) + MMU_doDMA(proc, 1); + #ifdef LOG_DMA2 + else + { + LOG("proc %d, dma %d src %08X dst %08X start taille %d %d\r\n", proc, 1, DMASrc[proc][1], DMADst[proc][1], 0, ((MMU.DMACrt[proc][1]>>27)&7)); + } + #endif + return; + case REG_DMA2CNTL : + //LOG("32 bit dma2 %04X\r\n", val); + DMASrc[proc][2] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xC8); + DMADst[proc][2] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xCC); + MMU.DMAStartTime[proc][2] = (proc ? (val>>28) & 0x3 : (val>>27) & 0x7); + MMU.DMACrt[proc][2] = val; + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0xD0, val); + if(MMU.DMAStartTime[proc][2] == 0) + MMU_doDMA(proc, 2); + #ifdef LOG_DMA2 + else + { + LOG("proc %d, dma %d src %08X dst %08X start taille %d %d\r\n", proc, 2, DMASrc[proc][2], DMADst[proc][2], 0, ((MMU.DMACrt[proc][2]>>27)&7)); + } + #endif + return; + case 0x040000DC : + //LOG("32 bit dma3 %04X\r\n", val); + DMASrc[proc][3] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xD4); + DMADst[proc][3] = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xD8); + MMU.DMAStartTime[proc][3] = (proc ? (val>>28) & 0x3 : (val>>27) & 0x7); + MMU.DMACrt[proc][3] = val; + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0xDC, val); + if(MMU.DMAStartTime[proc][3] == 0) + MMU_doDMA(proc, 3); + #ifdef LOG_DMA2 + else + { + LOG("proc %d, dma %d src %08X dst %08X start taille %d %d\r\n", proc, 3, DMASrc[proc][3], DMADst[proc][3], 0, ((MMU.DMACrt[proc][3]>>27)&7)); + } + #endif + return; + case REG_GCROMCTRL : + { + int i; + + if(MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT) == 0xB7) + { + MMU.dscard[proc].adress = (MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT+1) << 24) | (MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT+2) << 16) | (MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT+3) << 8) | (MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT+4)); + MMU.dscard[proc].transfer_count = 0x80;// * ((val>>24)&7)); + } + else if (MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT) == 0xB8) + { + // Get ROM chip ID + val |= 0x800000; // Data-Word Status + T1WriteLong(MMU.MMU_MEM[proc][(REG_GCROMCTRL >> 20) & 0xff], REG_GCROMCTRL & 0xfff, val); + MMU.dscard[proc].adress = 0; + } + else + { + LOG("CARD command: %02X\n", MEM_8(MMU.MMU_MEM[proc], REG_GCCMDOUT)); + } + + CARDLOG("%08X : %08X %08X\r\n", adr, val, adresse[proc]); + val |= 0x00800000; + + if(MMU.dscard[proc].adress == 0) + { + val &= ~0x80000000; + T1WriteLong(MMU.MMU_MEM[proc][(REG_GCROMCTRL >> 20) & 0xff], REG_GCROMCTRL & 0xfff, val); + return; + } + T1WriteLong(MMU.MMU_MEM[proc][(REG_GCROMCTRL >> 20) & 0xff], REG_GCROMCTRL & 0xfff, val); + + /* launch DMA if start flag was set to "DS Cart" */ + if(proc == ARMCPU_ARM7) i = 2; + else i = 5; + + if(proc == ARMCPU_ARM9 && MMU.DMAStartTime[proc][0] == i) /* dma0/1 on arm7 can't start on ds cart event */ + { + MMU_doDMA(proc, 0); + return; + } + else if(proc == ARMCPU_ARM9 && MMU.DMAStartTime[proc][1] == i) + { + MMU_doDMA(proc, 1); + return; + } + else if(MMU.DMAStartTime[proc][2] == i) + { + MMU_doDMA(proc, 2); + return; + } + else if(MMU.DMAStartTime[proc][3] == i) + { + MMU_doDMA(proc, 3); + return; + } + return; + + } + return; + case REG_DISPA_BG0CNT : + GPU_setBGProp(MainScreen.gpu, 0, (val&0xFFFF)); + GPU_setBGProp(MainScreen.gpu, 1, (val>>16)); + //if((val>>16)==0x400) execute = FALSE; + T1WriteLong(ARM9Mem.ARM9_REG, 8, val); + return; + case REG_DISPA_BG2CNT : + GPU_setBGProp(MainScreen.gpu, 2, (val&0xFFFF)); + GPU_setBGProp(MainScreen.gpu, 3, (val>>16)); + T1WriteLong(ARM9Mem.ARM9_REG, 0xC, val); + return; + case REG_DISPB_BG0CNT : + GPU_setBGProp(SubScreen.gpu, 0, (val&0xFFFF)); + GPU_setBGProp(SubScreen.gpu, 1, (val>>16)); + T1WriteLong(ARM9Mem.ARM9_REG, 0x1008, val); + return; + case REG_DISPB_BG2CNT : + GPU_setBGProp(SubScreen.gpu, 2, (val&0xFFFF)); + GPU_setBGProp(SubScreen.gpu, 3, (val>>16)); + T1WriteLong(ARM9Mem.ARM9_REG, 0x100C, val); + return; + //case 0x21FDFF0 : if(val==0) execute = FALSE; + //case 0x21FDFB0 : if(val==0) execute = FALSE; + default : + T1WriteLong(MMU.MMU_MEM[proc][0x40], adr & MMU.MMU_MASK[proc][(adr>>20)&0xFF], val); + return; + } + } + T1WriteLong(MMU.MMU_MEM[proc][(adr>>20)&0xFF], adr&MMU.MMU_MASK[proc][(adr>>20)&0xFF], val); +} + + +void FASTCALL MMU_doDMA(u32 proc, u32 num) +{ + u32 src = DMASrc[proc][num]; + u32 dst = DMADst[proc][num]; + u32 taille; + + if(src==dst) + { + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0xB8 + (0xC*num), T1ReadLong(MMU.MMU_MEM[proc][0x40], 0xB8 + (0xC*num)) & 0x7FFFFFFF); + return; + } + + if((!(MMU.DMACrt[proc][num]&(1<<31)))&&(!(MMU.DMACrt[proc][num]&(1<<25)))) + { + MMU.DMAStartTime[proc][num] = 0; + MMU.DMACycle[proc][num] = 0; + //MMU.DMAing[proc][num] = FALSE; + return; + } + + taille = (MMU.DMACrt[proc][num]&0xFFFF); + + if(MMU.DMAStartTime[proc][num] == 5) taille *= 0x80; + + MMU.DMACycle[proc][num] = taille + nds.cycles; + + MMU.DMAing[proc][num] = TRUE; + + DMALOG("proc %d, dma %d src %08X dst %08X start %d taille %d repeat %s %08X\r\n", proc, num, src, dst, MMU.DMAStartTime[proc][num], taille, (MMU.DMACrt[proc][num]&(1<<25))?"on":"off",MMU.DMACrt[proc][num]); + + if(!(MMU.DMACrt[proc][num]&(1<<25))) MMU.DMAStartTime[proc][num] = 0; + + switch((MMU.DMACrt[proc][num]>>26)&1) + { + case 1 : + switch(((MMU.DMACrt[proc][num]>>21)&0xF)) + { + u32 i; + case 0 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + dst += 4; + src += 4; + } + break; + case 1 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + dst -= 4; + src += 4; + } + break; + case 2 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + src += 4; + } + break; + case 3 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + dst += 4; + src += 4; + } + break; + case 4 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + dst += 4; + src -= 4; + } + break; + case 5 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + dst -= 4; + src -= 4; + } + break; + case 6 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + src -= 4; + } + break; + case 7 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + dst += 4; + src -= 4; + } + break; + case 8 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + dst += 4; + } + break; + case 9 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + dst -= 4; + } + break; + case 10 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + } + break; + case 11 : + for(i = 0; i < taille; ++i) + { + MMU_writeWord(proc, dst, MMU_readWord(proc, src)); + dst += 4; + } + break; + default : + break; + } + break; + case 0 : + switch(((MMU.DMACrt[proc][num]>>21)&0xF)) + { + u32 i; + case 0 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + dst += 2; + src += 2; + } + break; + case 1 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + dst -= 2; + src += 2; + } + break; + case 2 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + src += 2; + } + break; + case 3 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + dst += 2; + src += 2; + } + break; + case 4 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + dst += 2; + src -= 2; + } + break; + case 5 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + dst -= 2; + src -= 2; + } + break; + case 6 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + src -= 2; + } + break; + case 7 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + dst += 2; + src -= 2; + } + break; + case 8 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + dst += 2; + } + break; + case 9 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + dst -= 2; + } + break; + case 10 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + } + break; + case 11 : + for(i = 0; i < taille; ++i) + { + MMU_write16(proc, dst, MMU_readHWord(proc, src)); + dst += 2; + } + break; + default : + break; + } + break; + } +} diff --git a/tags/release_0_5_0/desmume/src/MMU.h b/tags/release_0_5_0/desmume/src/MMU.h new file mode 100644 index 000000000..6362fe458 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/MMU.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/Makefile.am b/tags/release_0_5_0/desmume/src/Makefile.am new file mode 100644 index 000000000..18be5aaa6 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/Makefile.am @@ -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) diff --git a/tags/release_0_5_0/desmume/src/NDSSystem.c b/tags/release_0_5_0/desmume/src/NDSSystem.c new file mode 100644 index 000000000..b305799e5 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/NDSSystem.c @@ -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 +#include + +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 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; +} diff --git a/tags/release_0_5_0/desmume/src/NDSSystem.h b/tags/release_0_5_0/desmume/src/NDSSystem.h new file mode 100644 index 000000000..d698ce5db --- /dev/null +++ b/tags/release_0_5_0/desmume/src/NDSSystem.h @@ -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.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 diff --git a/tags/release_0_5_0/desmume/src/SPU.c b/tags/release_0_5_0/desmume/src/SPU.c new file mode 100644 index 000000000..2e140da83 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/SPU.c @@ -0,0 +1,1361 @@ +/* Copyright (C) 2006 Theo Berkau + + Ideas borrowed from Stephane Dallongeville's SCSP core + + 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 +#include + +#include "debug.h" +#include "ARM9.h" +#include "MMU.h" +#include "SPU.h" + +#include "armcpu.h" + +SPU_struct *SPU=NULL; + +static SoundInterface_struct *SNDCore=NULL; +extern SoundInterface_struct *SNDCoreList[]; + +#define CHANSTAT_STOPPED 0 +#define CHANSTAT_PLAY 1 + +#define ARM7_REG_8(a) (MMU.ARM7_REG[a]) + +#define ARM7_REG_16(a) (((u16 *)(MMU.ARM7_REG+addr))[0]) +#define ARM7_REG_32(a) (((u32 *)(MMU.ARM7_REG+addr))[0]) + +int indextbl[8] = +{ + -1, -1, -1, -1, 2, 4, 6, 8 +}; + +int adpcmtbl[89] = +{ + 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x0010, + 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F, 0x0022, 0x0025, + 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042, 0x0049, 0x0050, 0x0058, + 0x0061, 0x006B, 0x0076, 0x0082, 0x008F, 0x009D, 0x00AD, 0x00BE, 0x00D1, + 0x00E6, 0x00FD, 0x0117, 0x0133, 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, + 0x0220, 0x0256, 0x0292, 0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, + 0x0502, 0x0583, 0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, + 0x0BD0, 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954, + 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B, 0x3BB9, + 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF +}; + +s16 wavedutytbl[8][8] = { +{ -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF }, +{ -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF }, +{ -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, +{ -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, +{ -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, +{ -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, +{ -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, +{ -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF } +}; + +FILE *spufp=NULL; + +////////////////////////////////////////////////////////////////////////////// + +int SPU_ChangeSoundCore(int coreid, int buffersize) +{ + int i; + + if (SPU->sndbuf) + free(SPU->sndbuf); + + if (SPU->outbuf) + free(SPU->outbuf); + + // Make sure the old core is freed + if (SNDCore) + SNDCore->DeInit(); + + // Allocate memory for sound buffer + if ((SPU->sndbuf = malloc(buffersize * 4 * 2)) == NULL) + return -1; + + if ((SPU->outbuf = malloc(buffersize * 2 * 2)) == NULL) + return -1; + + memset(SPU->sndbuf, 0, buffersize * 4 * 2); + memset(SPU->outbuf, 0, buffersize * 2 * 2); + + SPU->bufsize = buffersize; + + // So which core do we want? + if (coreid == SNDCORE_DEFAULT) + coreid = 0; // Assume we want the first one + + // Go through core list and find the id + for (i = 0; SNDCoreList[i] != NULL; i++) + { + if (SNDCoreList[i]->id == coreid) + { + // Set to current core + SNDCore = SNDCoreList[i]; + break; + } + } + + if (SNDCore == NULL) + { + SNDCore = &SNDDummy; + return -1; + } + + if (SNDCore->Init(buffersize * 2) == -1) + { + // Since it failed, instead of it being fatal, we'll just use the dummy + // core instead + SNDCore = &SNDDummy; + } + + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +int SPU_Init(int coreid, int buffersize) +{ + if ((SPU = (SPU_struct *)malloc(sizeof(SPU_struct))) == NULL) + return -1; + + memset((void *)SPU, 0, sizeof(SPU_struct)); + + SPU_Reset(); + + return SPU_ChangeSoundCore(coreid, buffersize); +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_Pause(int pause) +{ + if(pause) + SNDCore->MuteAudio(); + else + SNDCore->UnMuteAudio(); +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_SetVolume(int volume) +{ + if (SNDCore) + SNDCore->SetVolume(volume); +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_Reset(void) +{ + int i; + + memset((void *)SPU->chan, 0, sizeof(channel_struct) * 16); + + // Reset Registers + for (i = 0x400; i < 0x51D; i++) + ARM7_REG_8(i) = 0; +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_DeInit(void) +{ + if (SPU->sndbuf) + free(SPU->sndbuf); + + if (SPU->outbuf) + free(SPU->outbuf); + + if (SNDCore) + SNDCore->DeInit(); + + if (SPU) + free(SPU); +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_KeyOn(int channel) +{ + channel_struct *chan = &SPU->chan[channel]; + + chan->sampinc = (16777216 / (0x10000 - (double)chan->timer)) / 44100; + +// LOG("Channel %d key on: vol = %d, datashift = %d, hold = %d, pan = %d, waveduty = %d, repeat = %d, format = %d, source address = %07X, timer = %04X, loop start = %04X, length = %06X, MMU.ARM7_REG[0x501] = %02X\n", channel, chan->vol, chan->datashift, chan->hold, chan->pan, chan->waveduty, chan->repeat, chan->format, chan->addr, chan->timer, chan->loopstart, chan->length, ARM7_REG_8(0x501)); + switch(chan->format) + { + case 0: // 8-bit + chan->buf8 = &MMU.MMU_MEM[1][(chan->addr>>20)&0xFF][(chan->addr & MMU.MMU_MASK[1][(chan->addr >> 20) & 0xFF])]; + chan->loopstart = chan->loopstart << 2; + chan->length = (chan->length << 2) + chan->loopstart; + chan->sampcnt = 0; + break; + case 1: // 16-bit + chan->buf16 = (u16 *)&MMU.MMU_MEM[1][(chan->addr>>20)&0xFF][(chan->addr & MMU.MMU_MASK[1][(chan->addr >> 20) & 0xFF])]; + chan->loopstart = chan->loopstart << 1; + chan->length = (chan->length << 1) + chan->loopstart; + chan->sampcnt = 0; + break; + case 2: // ADPCM + { + u32 temp; + + chan->buf8 = &MMU.MMU_MEM[1][(chan->addr>>20)&0xFF][(chan->addr & MMU.MMU_MASK[1][(chan->addr >> 20) & 0xFF])]; + chan->pcm16b = (s16)((chan->buf8[1] << 8) | chan->buf8[0]); + chan->index = chan->buf8[2] & 0x7F; + chan->lastsampcnt = 7; + chan->sampcnt = 8; + chan->loopstart = chan->loopstart << 3; + chan->length = (chan->length << 3) + chan->loopstart; + break; + } + case 3: // PSG + { + break; + } + default: break; + } +} + +////////////////////////////////////////////////////////////////////////////// + +u8 SPU_ReadByte(u32 addr) +{ + addr &= 0xFFF; + + if (addr < 0x500) + { + switch (addr & 0xF) + { + case 0x0: +// LOG("Sound Channel %d Volume read\n", (addr >> 4) & 0xF); + return ARM7_REG_8(addr); + case 0x1: + { +// LOG("Sound Channel %d Data Shift/Hold read\n",(addr >> 4) & 0xF); + return ARM7_REG_8(addr); + } + case 0x2: +// LOG("Sound Channel %d Panning read\n",(addr >> 4) & 0xF); + return ARM7_REG_8(addr); + case 0x3: +// LOG("Sound Channel %d Wave Duty/Repeat/Format/Start read: %02X\n", (addr >> 4) & 0xF, ARM7_REG_8(addr)); + return ARM7_REG_8(addr); + case 0x4: + case 0x5: + case 0x6: + case 0x7: +// LOG("Sound Channel %d Data Source Register read: %08X\n",(addr >> 4) & 0xF, addr); + return ARM7_REG_8(addr); + case 0x8: +// LOG("Sound Channel Timer(Low byte) read: %08X\n", addr); + return ARM7_REG_8(addr); + case 0x9: +// LOG("Sound Channel Timer(High byte) read: %08X\n", addr); + return ARM7_REG_8(addr); + case 0xA: +// LOG("Sound Channel Loop Start(Low byte) read: %08X\n", addr); + return ARM7_REG_8(addr); + case 0xB: +// LOG("Sound Channel Loop Start(High byte) read: %08X\n", addr); + return ARM7_REG_8(addr); + case 0xC: + case 0xD: + case 0xE: + case 0xF: +// LOG("Sound Channel %d Length Register read: %08X\n",(addr >> 4) & 0xF, addr); + return ARM7_REG_8(addr); + default: break; + } + } + else + { + switch (addr & 0x1F) + { + case 0x000: + case 0x001: +// LOG("Sound Control Register read: %08X\n", addr); + return ARM7_REG_8(addr); + case 0x004: + case 0x005: +// LOG("Sound Bias Register read: %08X\n", addr); + return ARM7_REG_8(addr); + case 0x008: +// LOG("Sound Capture 0 Control Register read\n"); + return ARM7_REG_8(addr); + case 0x009: +// LOG("Sound Capture 1 Control Register read\n"); + return ARM7_REG_8(addr); + default: break; + } + } + + return ARM7_REG_8(addr); +} + +////////////////////////////////////////////////////////////////////////////// + +u16 SPU_ReadWord(u32 addr) +{ + addr &= 0xFFF; + + if (addr < 0x500) + { + switch (addr & 0xF) + { + case 0x0: +// LOG("Sound Channel %d Volume/data shift/hold word read\n", (addr >> 4) & 0xF); + return ARM7_REG_16(addr); + case 0x2: + { + channel_struct *chan=&SPU->chan[(addr >> 4) & 0xF]; +// LOG("Sound Channel %d Panning/Wave Duty/Repeat Mode/Format/Start word read\n", (addr >> 4) & 0xF); + return ARM7_REG_16(addr); + } + case 0x4: + case 0x6: +// LOG("Sound Channel %d Data Source Register word read: %08X\n",(addr >> 4) & 0xF, addr); + return ARM7_REG_16(addr); + case 0x8: +// LOG("Sound Channel %d Timer Register word read\n", (addr >> 4) & 0xF); + return ARM7_REG_16(addr); + case 0xA: +// LOG("Sound Channel %d Loop start Register word read\n", (addr >> 4) & 0xF); + return ARM7_REG_16(addr); + case 0xC: + case 0xE: +// LOG("Sound Channel %d Length Register word read: %08X\n",(addr >> 4) & 0xF, addr); + return ARM7_REG_16(addr); + default: break; + } + } + else + { + switch (addr & 0x1F) + { + case 0x000: +// LOG("Sound Control Register word read\n"); + return ARM7_REG_16(addr); + case 0x004: +// LOG("Sound Bias Register word read\n"); + return ARM7_REG_16(addr); + case 0x008: +// LOG("Sound Capture 0/1 Control Register word read\n"); + return ARM7_REG_16(addr); + default: break; + } + } + + return ARM7_REG_16(addr); +} + +////////////////////////////////////////////////////////////////////////////// + +u32 SPU_ReadLong(u32 addr) +{ + addr &= 0xFFF; + + if (addr < 0x500) + { + switch (addr & 0xF) + { + case 0x0: +// LOG("Sound Channel %d Control Register long read\n", (addr >> 4) & 0xF); + return ARM7_REG_32(addr); + case 0x4: +// LOG("Sound Channel %d Data Source Register long read\n"); + return ARM7_REG_32(addr); + case 0x8: +// LOG("Sound Channel %d Timer/Loop Start Register long read\n", (addr >> 4) & 0xF); + return ARM7_REG_32(addr); + case 0xC: +// LOG("Sound Channel %d Length Register long read\n", (addr >> 4) & 0xF); + return ARM7_REG_32(addr); + default: + return ARM7_REG_32(addr); + } + } + else + { + switch (addr & 0x1F) + { + case 0x000: +// LOG("Sound Control Register long read\n"); + return ARM7_REG_32(addr); + case 0x004: +// LOG("Sound Bias Register long read\n"); + return ARM7_REG_32(addr); + case 0x008: +// LOG("Sound Capture 0/1 Control Register long read: %08X\n"); + return ARM7_REG_32(addr); + default: + return ARM7_REG_32(addr); + } + } + + return ARM7_REG_32(addr); +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_WriteByte(u32 addr, u8 val) +{ + addr &= 0xFFF; + + if (addr < 0x500) + { + switch (addr & 0xF) + { + case 0x0: + SPU->chan[(addr >> 4) & 0xF].vol = val & 0x7F; +// LOG("Sound Channel %d Volume write: %02X\n", (addr >> 4) & 0xF, val); + ARM7_REG_8(addr) = val; + return; + case 0x1: + { + channel_struct *chan=&SPU->chan[(addr >> 4) & 0xF]; + +// LOG("Sound Channel %d Data Shift/Hold write: %02X\n",(addr >> 4) & 0xF, val); + chan->datashift = val & 0x3; + if (chan->datashift == 3) + chan->datashift = 4; + chan->hold = (val >> 7) & 0x1; + ARM7_REG_8(addr) = val; + return; + } + case 0x2: +// LOG("Sound Channel %d Panning write: %02X\n",(addr >> 4) & 0xF, val); + SPU->chan[(addr >> 4) & 0xF].pan = val & 0x7F; + ARM7_REG_8(addr) = val; + return; + case 0x3: + { + channel_struct *chan=&SPU->chan[(addr >> 4) & 0xF]; +// LOG("Sound Channel %d Wave Duty/Repeat/Format/Start write: %08X - %02X. ARM7 PC = %08X\n", (addr >> 4) & 0xF, addr, val, NDS_ARM7.instruct_adr); + + chan->waveduty = val & 0x7; + chan->repeat = (val >> 3) & 0x3; + chan->format = (val >> 5) & 0x3; + chan->status = (val >> 7) & 0x1; + + if (SPU->chan[(addr >> 4) & 0xF].status) + SPU_KeyOn((addr >> 4) & 0xF); + ARM7_REG_8(addr) = val; + return; + } + case 0x4: + case 0x5: + case 0x6: + case 0x7: +// LOG("Sound Channel %d Data Source Register write: %08X %02X\n",(addr >> 4) & 0xF, addr, val); + ARM7_REG_8(addr) = val; + return; + case 0x8: +// LOG("Sound Channel Timer(Low byte) write: %08X - %02X\n", addr, val); + ARM7_REG_8(addr) = val; + return; + case 0x9: +// LOG("Sound Channel Timer(High byte) write: %08X - %02X\n", addr, val); + ARM7_REG_8(addr) = val; + return; + case 0xA: +// LOG("Sound Channel Loop Start(Low byte) write: %08X - %02X\n", addr, val); + ARM7_REG_8(addr) = val; + return; + case 0xB: +// LOG("Sound Channel Loop Start(High byte) write: %08X - %02X\n", addr, val); + ARM7_REG_8(addr) = val; + return; + case 0xC: + case 0xD: + case 0xE: + case 0xF: +// LOG("Sound Channel %d Length Register write: %08X %02X\n",(addr >> 4) & 0xF, addr, val); + ARM7_REG_8(addr) = val; + return; + default: + LOG("Unsupported Sound Register byte write: %08X %02X\n", addr, val); + ARM7_REG_8(addr) = val; + break; + } + } + else + { + switch (addr & 0x1F) + { + case 0x000: + case 0x001: +// LOG("Sound Control Register write: %08X %02X\n", addr, val); + ARM7_REG_8(addr) = val; + return; + case 0x004: + case 0x005: +// LOG("Sound Bias Register write: %08X %02X\n", addr, val); + ARM7_REG_8(addr) = val; + return; + case 0x008: +// LOG("Sound Capture 0 Control Register write: %02X\n", val); + ARM7_REG_8(addr) = val; + return; + case 0x009: +// LOG("Sound Capture 1 Control Register write: %02X\n", val); + ARM7_REG_8(addr) = val; + return; + default: break; + } + } + + ARM7_REG_8(addr) = val; +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_WriteWord(u32 addr, u16 val) +{ + addr &= 0xFFF; + + if (addr < 0x500) + { + switch (addr & 0xF) + { + case 0x0: + { + channel_struct *chan=&SPU->chan[(addr >> 4) & 0xF]; +// LOG("Sound Channel %d Volume/data shift/hold write: %04X\n", (addr >> 4) & 0xF, val); + chan->vol = val & 0x7F; + chan->datashift = (val >> 8) & 0x3; + if (chan->datashift == 3) + chan->datashift = 4; + chan->hold = (val >> 15) & 0x1; + ARM7_REG_16(addr) = val; + return; + } + case 0x2: + { + channel_struct *chan=&SPU->chan[(addr >> 4) & 0xF]; +// LOG("Sound Channel %d Panning/Wave Duty/Repeat Mode/Format/Start write: %04X\n", (addr >> 4) & 0xF, val); + + chan->pan = val & 0x7F; + chan->waveduty = (val >> 8) & 0x7; + chan->repeat = (val >> 11) & 0x3; + chan->format = (val >> 13) & 0x3; + chan->status = (val >> 15) & 0x1; + if (chan->status) + SPU_KeyOn((addr >> 4) & 0xF); + + ARM7_REG_16(addr) = val; + return; + } + case 0x4: + case 0x6: +// LOG("Sound Channel %d Data Source Register write: %08X %04X\n",(addr >> 4) & 0xF, addr, val); + ARM7_REG_16(addr) = val; + return; + case 0x8: + { + channel_struct *chan = &SPU->chan[(addr >> 4) & 0xF]; +// LOG("Sound Channel %d Timer Register write: %04X\n", (addr >> 4) & 0xF, val); + chan->timer = val & 0xFFFF; + chan->sampinc = (16777216 / (0x10000 - (double)chan->timer)) / 44100; + ARM7_REG_16(addr) = val; + return; + } + case 0xA: +// LOG("Sound Channel %d Loop start Register write: %04X\n", (addr >> 4) & 0xF, val); + SPU->chan[(addr >> 4) & 0xF].loopstart = val; + ARM7_REG_16(addr) = val; + return; + case 0xC: + case 0xE: +// LOG("Sound Channel %d Length Register write: %08X %04X\n",(addr >> 4) & 0xF, addr, val); + ARM7_REG_16(addr) = val; + return; + default: +// LOG("Unsupported Sound Register word write: %08X %02X\n", addr, val); + ARM7_REG_16(addr) = val; + break; + } + } + else + { + switch (addr & 0x1F) + { + case 0x000: +// LOG("Sound Control Register write: %04X\n", val); + ARM7_REG_16(addr) = val; + return; + case 0x004: +// LOG("Sound Bias Register write: %04X\n", val); + ARM7_REG_16(addr) = val; + return; + case 0x008: +// LOG("Sound Capture 0/1 Control Register write: %04X\n", val); + ARM7_REG_16(addr) = val; + return; + default: break; + } + } + + ARM7_REG_16(addr) = val; +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_WriteLong(u32 addr, u32 val) +{ + addr &= 0xFFF; + + if (addr < 0x500) + { + switch (addr & 0xF) + { + case 0x0: + { + channel_struct *chan=&SPU->chan[(addr >> 4) & 0xF]; +// LOG("Sound Channel %d long write: %08X\n", (addr >> 4) & 0xF, val); + chan->vol = val & 0x7F; + chan->datashift = (val >> 8) & 0x3; + if (chan->datashift == 3) + chan->datashift = 4; + chan->hold = (val >> 15) & 0x1; + chan->pan = (val >> 16) & 0x7F; + chan->waveduty = (val >> 24) & 0x7; + chan->repeat = (val >> 27) & 0x3; + chan->format = (val >> 29) & 0x3; + chan->status = (val >> 31) & 0x1; + if (SPU->chan[(addr >> 4) & 0xF].status) + SPU_KeyOn((addr >> 4) & 0xF); + ARM7_REG_32(addr) = val; + return; + } + case 0x4: +// LOG("Sound Channel %d Data Source Register long write: %08X\n", (addr >> 4) & 0xF, val); + SPU->chan[(addr >> 4) & 0xF].addr = val & 0x7FFFFFF; + ARM7_REG_32(addr) = val; + return; + case 0x8: + { + channel_struct *chan = &SPU->chan[(addr >> 4) & 0xF]; + +// LOG("Sound Channel %d Timer/Loop Start Register write: - %08X\n", (addr >> 4) & 0xF, val); + chan->timer = val & 0xFFFF; + chan->loopstart = val >> 16; + chan->sampinc = (16777216 / (0x10000 - (double)chan->timer)) / 44100; + ARM7_REG_32(addr) = val; + return; + } + case 0xC: +// LOG("Sound Channel %d Length Register long write: %08X\n", (addr >> 4) & 0xF, val); + SPU->chan[(addr >> 4) & 0xF].length = val & 0x3FFFFF; + ARM7_REG_32(addr) = val; + return; + default: break; + } + } + else + { + switch (addr & 0x1F) + { + case 0x000: +// LOG("Sound Control Register write: %08X\n", val); + ARM7_REG_32(addr) = val; + return; + case 0x004: +// LOG("Sound Bias Register write: %08X\n", val); + ARM7_REG_32(addr) = val; + return; + case 0x008: +// LOG("Sound Capture 0/1 Control Register write: %08X\n", val); + ARM7_REG_32(addr) = val; + return; + default: break; + } + } + + ARM7_REG_32(addr) = val; +} + +////////////////////////////////////////////////////////////////////////////// + +static INLINE void Fetch8BitData(channel_struct *chan, s32 *data) +{ + *data = (s32)chan->buf8[(int)chan->sampcnt] << 8; +} + +////////////////////////////////////////////////////////////////////////////// + +static INLINE void Fetch16BitData(channel_struct *chan, s32 *data) +{ + *data = (s32)chan->buf16[(int)chan->sampcnt]; +} + +////////////////////////////////////////////////////////////////////////////// + +static INLINE int MinMax(int val, int min, int max) +{ + if (val < min) + return min; + else if (val > max) + return max; + + return val; +} + +////////////////////////////////////////////////////////////////////////////// + +static INLINE void FetchADPCMData(channel_struct *chan, s32 *data) +{ + u8 data4bit; + int diff; + int i; + + if (chan->lastsampcnt == (int)chan->sampcnt) + { + // No sense decoding, just return the last sample + *data = (s32)chan->pcm16b; + return; + } + + for (i = chan->lastsampcnt+1; i < (int)chan->sampcnt+1; i++) + { + if (i & 0x1) + data4bit = (chan->buf8[i >> 1] >> 4) & 0xF; + else + data4bit = chan->buf8[i >> 1] & 0xF; + + diff = ((data4bit & 0x7) * 2 + 1) * adpcmtbl[chan->index] / 8; + if (data4bit & 0x8) + diff = -diff; + + chan->pcm16b = (s16)MinMax(chan->pcm16b+diff, -0x8000, 0x7FFF); + chan->index = MinMax(chan->index+indextbl[data4bit & 0x7], 0, 88); + } + + chan->lastsampcnt = chan->sampcnt; + *data = (s32)chan->pcm16b; +} + +////////////////////////////////////////////////////////////////////////////// + +static INLINE void FetchPSGData(channel_struct *chan, s32 *data) +{ + *data = (s32)wavedutytbl[chan->waveduty][((int)chan->sampcnt) & 0x7]; +} + +////////////////////////////////////////////////////////////////////////////// + +static INLINE void MixL(channel_struct *chan, s32 data) +{ + if (data) + { + data = (data * chan->vol / 127) >> chan->datashift; + SPU->sndbuf[SPU->bufpos<<1] += data; + } +} + +////////////////////////////////////////////////////////////////////////////// + +static INLINE void MixR(channel_struct *chan, s32 data) +{ + if (data) + { + data = (data * chan->vol / 127) >> chan->datashift; + SPU->sndbuf[(SPU->bufpos<<1)+1] += data; + } +} + +////////////////////////////////////////////////////////////////////////////// + +static INLINE void MixLR(channel_struct *chan, s32 data) +{ + if (data) + { + data = ((data * chan->vol) / 127) >> chan->datashift; + SPU->sndbuf[SPU->bufpos<<1] += data * (127 - chan->pan) / 127; + SPU->sndbuf[(SPU->bufpos<<1)+1] += data * chan->pan / 127; + } +} + +////////////////////////////////////////////////////////////////////////////// + +static INLINE void TestForLoop(channel_struct *chan) +{ + chan->sampcnt += chan->sampinc; + + if (chan->sampcnt > (double)chan->length) + { + // Do we loop? Or are we done? + if (chan->repeat == 1) + chan->sampcnt = (double)chan->loopstart; // Is this correct? + else + { + chan->status = CHANSTAT_STOPPED; + MMU.ARM7_REG[0x403 + ((((u32)chan-(u32)SPU->chan) / sizeof(channel_struct)) * 0x10)] &= 0x7F; + SPU->bufpos = SPU->buflength; + } + } +} + +////////////////////////////////////////////////////////////////////////////// + +static INLINE void TestForLoop2(channel_struct *chan) +{ + chan->sampcnt += chan->sampinc; + + if (chan->sampcnt > (double)chan->length) + { + // Do we loop? Or are we done? + if (chan->repeat == 1) + { + chan->sampcnt = (double)chan->loopstart; // Is this correct? + chan->pcm16b = (s16)((chan->buf8[1] << 8) | chan->buf8[0]); + chan->index = chan->buf8[2] & 0x7F; + chan->lastsampcnt = 7; + } + else + { + chan->status = CHANSTAT_STOPPED; + MMU.ARM7_REG[0x403 + ((((u32)chan-(u32)SPU->chan) / sizeof(channel_struct)) * 0x10)] &= 0x7F; + SPU->bufpos = SPU->buflength; + } + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdateNothing(channel_struct *chan) +{ +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdate8LR(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + Fetch8BitData(chan, &data); + + MixLR(chan, data); + + // check to see if we're passed the length and need to loop, etc. + TestForLoop(chan); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdate8L(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + Fetch8BitData(chan, &data); + + MixL(chan, data); + + // check to see if we're passed the length and need to loop, etc. + TestForLoop(chan); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdate8R(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + Fetch8BitData(chan, &data); + + MixR(chan, data); + + // check to see if we're passed the length and need to loop, etc. + TestForLoop(chan); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdate16LR(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + Fetch16BitData(chan, &data); + + MixLR(chan, data); + + // check to see if we're passed the length and need to loop, etc. + TestForLoop(chan); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdate16L(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + Fetch16BitData(chan, &data); + + MixL(chan, data); + + // check to see if we're passed the length and need to loop, etc. + TestForLoop(chan); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdate16R(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + Fetch16BitData(chan, &data); + + MixR(chan, data); + + // check to see if we're passed the length and need to loop, etc. + TestForLoop(chan); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdateADPCMLR(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + FetchADPCMData(chan, &data); + + MixLR(chan, data); + + // check to see if we're passed the length and need to loop, etc. + TestForLoop2(chan); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdateADPCML(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + FetchADPCMData(chan, &data); + + MixL(chan, data); + + // check to see if we're passed the length and need to loop, etc. + TestForLoop2(chan); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdateADPCMR(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + FetchADPCMData(chan, &data); + + MixR(chan, data); + + // check to see if we're passed the length and need to loop, etc. + TestForLoop2(chan); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdatePSGLR(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + FetchPSGData(chan, &data); + + MixLR(chan, data); + + chan->sampcnt += chan->sampinc; + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdatePSGL(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + FetchPSGData(chan, &data); + + MixL(chan, data); + + chan->sampcnt += chan->sampinc; + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_ChanUpdatePSGR(channel_struct *chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + s32 data; + + // fetch data from source address + FetchPSGData(chan, &data); + + MixR(chan, data); + + chan->sampcnt += chan->sampinc; + } +} + +////////////////////////////////////////////////////////////////////////////// + +void (*SPU_ChanUpdate[4][3])(channel_struct *chan) = { + { // 8-bit PCM + SPU_ChanUpdate8L, + SPU_ChanUpdate8LR, + SPU_ChanUpdate8R + }, + { // 16-bit PCM + SPU_ChanUpdate16L, + SPU_ChanUpdate16LR, + SPU_ChanUpdate16R + }, + { // IMA-ADPCM + SPU_ChanUpdateADPCML, + SPU_ChanUpdateADPCMLR, + SPU_ChanUpdateADPCMR + }, + { // PSG/White Noise + SPU_ChanUpdatePSGL, + SPU_ChanUpdatePSGLR, + SPU_ChanUpdatePSGR + } +}; + +////////////////////////////////////////////////////////////////////////////// + +void SPU_MixAudio(int length) +{ + channel_struct *chan; + u8 vol; + int i; + + memset(SPU->sndbuf, 0, length*4*2); + + // If Master Enable isn't set, don't output audio + if (!(MMU.ARM7_REG[0x501] & 0x80)) + return; + + vol = MMU.ARM7_REG[0x500] & 0x7F; + + for(chan = &(SPU->chan[0]); chan < &(SPU->chan[16]); chan++) + { + if (chan->status != CHANSTAT_PLAY) + continue; + + SPU->bufpos = 0; + SPU->buflength = length; + + // Mix audio + if (chan->pan == 0) + SPU_ChanUpdate[chan->format][0](chan); + else if (chan->pan == 127) + SPU_ChanUpdate[chan->format][2](chan); + else + SPU_ChanUpdate[chan->format][1](chan); + } + + // convert from 32-bit->16-bit + for (i = 0; i < length*2; i++) + { + // Apply Master Volume + SPU->sndbuf[i] = SPU->sndbuf[i] * vol / 127; + + if (SPU->sndbuf[i] > 0x7FFF) + SPU->outbuf[i] = 0x7FFF; + else if (SPU->sndbuf[i] < -0x8000) + SPU->outbuf[i] = -0x8000; + else + SPU->outbuf[i] = (s16)SPU->sndbuf[i]; + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_Emulate(void) +{ + u32 audiosize; + + // Check to see how much free space there is + // If there is some, fill up the buffer + audiosize = SNDCore->GetAudioSpace(); + + if (audiosize > 0) + { + if (audiosize > SPU->bufsize) + audiosize = SPU->bufsize; + SPU_MixAudio(audiosize); + SNDCore->UpdateAudio(SPU->outbuf, audiosize); + } +} + +////////////////////////////////////////////////////////////////////////////// +// Dummy Sound Interface +////////////////////////////////////////////////////////////////////////////// + +int SNDDummyInit(int buffersize); +void SNDDummyDeInit(); +void SNDDummyUpdateAudio(s16 *buffer, u32 num_samples); +u32 SNDDummyGetAudioSpace(); +void SNDDummyMuteAudio(); +void SNDDummyUnMuteAudio(); +void SNDDummySetVolume(int volume); + +SoundInterface_struct SNDDummy = { +SNDCORE_DUMMY, +"Dummy Sound Interface", +SNDDummyInit, +SNDDummyDeInit, +SNDDummyUpdateAudio, +SNDDummyGetAudioSpace, +SNDDummyMuteAudio, +SNDDummyUnMuteAudio, +SNDDummySetVolume +}; + +////////////////////////////////////////////////////////////////////////////// + +int SNDDummyInit(int buffersize) +{ + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDummyDeInit() +{ +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDummyUpdateAudio(s16 *buffer, u32 num_samples) +{ +} + +////////////////////////////////////////////////////////////////////////////// + +u32 SNDDummyGetAudioSpace() +{ + return 735; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDummyMuteAudio() +{ +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDummyUnMuteAudio() +{ +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDummySetVolume(int volume) +{ +} + +////////////////////////////////////////////////////////////////////////////// +// WAV Write Interface +////////////////////////////////////////////////////////////////////////////// + +int SNDFileInit(int buffersize); +void SNDFileDeInit(); +void SNDFileUpdateAudio(s16 *buffer, u32 num_samples); +u32 SNDFileGetAudioSpace(); +void SNDFileMuteAudio(); +void SNDFileUnMuteAudio(); +void SNDFileSetVolume(int volume); + +SoundInterface_struct SNDFile = { +SNDCORE_FILEWRITE, +"WAV Write Sound Interface", +SNDFileInit, +SNDFileDeInit, +SNDFileUpdateAudio, +SNDFileGetAudioSpace, +SNDFileMuteAudio, +SNDFileUnMuteAudio, +SNDFileSetVolume +}; + +////////////////////////////////////////////////////////////////////////////// + +typedef struct { + char id[4]; + u32 size; +} chunk_struct; + +typedef struct { + chunk_struct riff; + char rifftype[4]; +} waveheader_struct; + +typedef struct { + chunk_struct chunk; + u16 compress; + u16 numchan; + u32 rate; + u32 bytespersec; + u16 blockalign; + u16 bitspersample; +} fmt_struct; + +////////////////////////////////////////////////////////////////////////////// + +int SNDFileInit(int buffersize) +{ + waveheader_struct waveheader; + fmt_struct fmt; + chunk_struct data; + + if ((spufp = fopen("ndsaudio.wav", "wb")) == NULL) + return -1; + + // Do wave header + memcpy(waveheader.riff.id, "RIFF", 4); + waveheader.riff.size = 0; // we'll fix this after the file is closed + memcpy(waveheader.rifftype, "WAVE", 4); + fwrite((void *)&waveheader, 1, sizeof(waveheader_struct), spufp); + + // fmt chunk + memcpy(fmt.chunk.id, "fmt ", 4); + fmt.chunk.size = 16; // we'll fix this at the end + fmt.compress = 1; // PCM + fmt.numchan = 2; // Stereo + fmt.rate = 44100; + fmt.bitspersample = 16; + fmt.blockalign = fmt.bitspersample / 8 * fmt.numchan; + fmt.bytespersec = fmt.rate * fmt.blockalign; + fwrite((void *)&fmt, 1, sizeof(fmt_struct), spufp); + + // data chunk + memcpy(data.id, "data", 4); + data.size = 0; // we'll fix this at the end + fwrite((void *)&data, 1, sizeof(chunk_struct), spufp); + + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDFileDeInit() +{ + if (spufp) + { + long length = ftell(spufp); + + // Let's fix the riff chunk size and the data chunk size + fseek(spufp, sizeof(waveheader_struct)-0x8, SEEK_SET); + length -= 0x4; + fwrite((void *)&length, 1, 4, spufp); + + fseek(spufp, sizeof(waveheader_struct)+sizeof(fmt_struct)+0x4, SEEK_SET); + length -= sizeof(waveheader_struct)+sizeof(fmt_struct); + fwrite((void *)&length, 1, 4, spufp); + fclose(spufp); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDFileUpdateAudio(s16 *buffer, u32 num_samples) +{ + if (spufp) + fwrite((void *)buffer, num_samples*2, 2, spufp); +} + +////////////////////////////////////////////////////////////////////////////// + +u32 SNDFileGetAudioSpace() +{ + return 735; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDFileMuteAudio() +{ +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDFileUnMuteAudio() +{ +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDFileSetVolume(int volume) +{ +} + +////////////////////////////////////////////////////////////////////////////// + diff --git a/tags/release_0_5_0/desmume/src/SPU.h b/tags/release_0_5_0/desmume/src/SPU.h new file mode 100644 index 000000000..de551a24c --- /dev/null +++ b/tags/release_0_5_0/desmume/src/SPU.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/arm_instructions.c b/tags/release_0_5_0/desmume/src/arm_instructions.c new file mode 100644 index 000000000..aec1c4624 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/arm_instructions.c @@ -0,0 +1,7818 @@ +/* Copyright (C) 2006 yopyop + Copyright (C) 2006 shash + 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 "cp15.h" +#include "debug.h" +#include "MMU.h" + +//#define ASM_CORE +//#define C_CORE + +s8 CFlag; +s8 ZFlag; +s8 NFlag; +s8 OFlag; + +#define LSL_IMM shift_op = cpu->R[REG_POS(i,0)]<<((i>>7)&0x1F); + +#define S_LSL_IMM u32 shift_op = ((i>>7)&0x1F);\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], 32-shift_op);\ + shift_op = cpu->R[REG_POS(i,0)]<<((i>>7)&0x1F);\ + } + +#define LSL_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + if(shift_op>=32)\ + shift_op=0;\ + else\ + shift_op=cpu->R[REG_POS(i,0)]<R[REG_POS(i,8)])&0xFF;\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + if(shift_op<32)\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], 32-shift_op);\ + shift_op = cpu->R[REG_POS(i,0)]<R[REG_POS(i,0)]);\ + }\ + else\ + {\ + shift_op = 0;\ + c = 0;\ + } + +#define LSR_IMM shift_op = ((i>>7)&0x1F);\ + if(shift_op!=0)\ + shift_op = cpu->R[REG_POS(i,0)]>>shift_op; + +#define S_LSR_IMM u32 shift_op = ((i>>7)&0x1F);\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + {\ + c = BIT31(cpu->R[REG_POS(i,0)]);\ + }\ + else\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = cpu->R[REG_POS(i,0)]>>shift_op;\ + } + +#define LSR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + if(shift_op>=32)\ + shift_op = 0;\ + else\ + shift_op = cpu->R[REG_POS(i,0)]>>shift_op; + +#define S_LSR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + {\ + shift_op = cpu->R[REG_POS(i,0)];\ + }\ + else\ + if(shift_op<32)\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = cpu->R[REG_POS(i,0)]>>shift_op;\ + }\ + else\ + if(shift_op==32)\ + {\ + c = BIT31(cpu->R[REG_POS(i,0)]);\ + shift_op = 0;\ + }\ + else\ + {\ + c = 0;\ + shift_op = 0;\ + } + +#define ASR_IMM shift_op = ((i>>7)&0x1F);\ + if(shift_op==0)\ + shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ + else\ + shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op); + +#define S_ASR_IMM u32 shift_op = ((i>>7)&0x1F);\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + {\ + shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ + c = BIT31(cpu->R[REG_POS(i,0)]);\ + }\ + else\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ + } + +#define ASR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + if(shift_op==0)\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + if(shift_op<32)\ + shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ + else\ + shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF; + +#define S_ASR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + if(shift_op<32)\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ + }\ + else\ + {\ + c = BIT31(cpu->R[REG_POS(i,0)]);\ + shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ + } + +#define ROR_IMM shift_op = ((i>>7)&0x1F);\ + if(shift_op==0)\ + {\ + u32 tmp = cpu->CPSR.bits.C;\ + shift_op = (tmp<<31)|(cpu->R[REG_POS(i,0)]>>1);\ + }\ + else\ + shift_op = ROR(cpu->R[REG_POS(i,0)],shift_op); + +#define S_ROR_IMM u32 shift_op = ((i>>7)&0x1F);\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + {\ + u32 tmp = cpu->CPSR.bits.C;\ + shift_op = (tmp<<31)|(cpu->R[REG_POS(i,0)]>>1);\ + c = BIT0(cpu->R[REG_POS(i,0)]);\ + }\ + else\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = ROR(cpu->R[REG_POS(i,0)],shift_op);\ + } + +#define ROR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + if((shift_op==0)||((shift_op&0xF)==0))\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + shift_op = ROR(cpu->R[REG_POS(i,0)],(shift_op&0xF)); + +#define S_ROR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + {\ + shift_op&=0xF;\ + if(shift_op==0)\ + {\ + shift_op=cpu->R[REG_POS(i,0)];\ + c = BIT31(cpu->R[REG_POS(i,0)]);\ + }\ + else\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = ROR(cpu->R[REG_POS(i,0)],(shift_op&0xF));\ + }\ + } + +#define IMM_VALUE u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E); + +#define S_IMM_VALUE u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E);\ + u32 c = cpu->CPSR.bits.C;\ + if((i>>8)&0xF)\ + c = BIT31(shift_op); + +#define IMM_OFF (((i>>4)&0xF0)+(i&0xF)) + +#define IMM_OFF_12 ((i)&0xFFF) + +extern BOOL execute; + +static u32 FASTCALL OP_UND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LOG("Undefined instruction: %08X\n", i); + execute = FALSE; + return 1; +} + +//-----------------------AND------------------------------------ + +#define OP_AND(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OP_ANDS(a, b)\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR;\ + cpu->R[15] = cpu->R[REG_POS(i,16)] & shift_op;\ + SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & shift_op;\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + return a; + +static u32 FASTCALL OP_AND_LSL_IMM(register armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_AND(1, 3); +} + +static u32 FASTCALL OP_AND_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_AND(2, 4); +} + +static u32 FASTCALL OP_AND_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_AND(1, 3); +} + +static u32 FASTCALL OP_AND_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_AND(2, 4); +} + +static u32 FASTCALL OP_AND_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_AND(1, 3); +} + +static u32 FASTCALL OP_AND_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_AND(2, 4); +} + +static u32 FASTCALL OP_AND_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_AND(1, 3); +} + +static u32 FASTCALL OP_AND_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_AND(2, 4); +} + +static u32 FASTCALL OP_AND_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_AND(1, 3); +} + +static u32 FASTCALL OP_AND_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_IMM; + OP_ANDS(2, 4); +} + +static u32 FASTCALL OP_AND_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_REG; + OP_ANDS(3, 5); +} + +static u32 FASTCALL OP_AND_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_IMM; + OP_ANDS(2, 4); +} + +static u32 FASTCALL OP_AND_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_REG; + OP_ANDS(3, 5); +} + +static u32 FASTCALL OP_AND_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_IMM; + OP_ANDS(2, 4); +} + +static u32 FASTCALL OP_AND_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_REG; + OP_ANDS(3, 5); +} + +static u32 FASTCALL OP_AND_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_IMM; + OP_ANDS(2, 4); +} + +static u32 FASTCALL OP_AND_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_REG; + OP_ANDS(3, 5); +} + +static u32 FASTCALL OP_AND_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_IMM_VALUE; + OP_ANDS(2, 4); +} + +//--------------EOR------------------------------ + +#define OP_EOR(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] ^ shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OP_EORS(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] ^ shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + return a; + +static u32 FASTCALL OP_EOR_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_EOR(1, 3); +} + +static u32 FASTCALL OP_EOR_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_EOR(2, 4); +} + +static u32 FASTCALL OP_EOR_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_EOR(1, 3); +} + +static u32 FASTCALL OP_EOR_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_EOR(2, 4); +} + +static u32 FASTCALL OP_EOR_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_EOR(1, 3); +} + +static u32 FASTCALL OP_EOR_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_EOR(2, 4); +} + +static u32 FASTCALL OP_EOR_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_EOR(1, 3); +} + +static u32 FASTCALL OP_EOR_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_EOR(2, 4); +} + +static u32 FASTCALL OP_EOR_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_EOR(1, 3); +} + +static u32 FASTCALL OP_EOR_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_IMM; + OP_EORS(2, 4); +} + +static u32 FASTCALL OP_EOR_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_REG; + OP_EORS(3, 5); +} + +static u32 FASTCALL OP_EOR_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_IMM; + OP_EORS(2, 4); +} + +static u32 FASTCALL OP_EOR_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_REG; + OP_EORS(3, 5); +} + +static u32 FASTCALL OP_EOR_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_IMM; + OP_EORS(2, 4); +} + +static u32 FASTCALL OP_EOR_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_REG; + OP_EORS(3, 5); +} + +static u32 FASTCALL OP_EOR_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_IMM; + OP_EORS(2, 4); +} + +static u32 FASTCALL OP_EOR_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_REG; + OP_EORS(3, 5); +} + +static u32 FASTCALL OP_EOR_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_IMM_VALUE; + OP_EORS(2, 4); +} + +//-------------SUB------------------------------------- + +#define OP_SUB(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] - shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OPSUBS(a, b) cpu->R[REG_POS(i,12)] = v - shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ + return a; + +static u32 FASTCALL OP_SUB_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_SUB(1, 3); +} + +static u32 FASTCALL OP_SUB_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_SUB(2, 4); +} + +static u32 FASTCALL OP_SUB_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_SUB(1, 3); +} + +static u32 FASTCALL OP_SUB_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_SUB(2, 4); +} + +static u32 FASTCALL OP_SUB_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_SUB(1, 3); +} + +static u32 FASTCALL OP_SUB_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_SUB(2, 4); +} + +static u32 FASTCALL OP_SUB_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_SUB(1, 3); +} + +static u32 FASTCALL OP_SUB_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_SUB(2, 4); +} + +static u32 FASTCALL OP_SUB_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_SUB(1, 3); +} + +static u32 FASTCALL OP_SUB_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OPSUBS(2, 4); +} + +static u32 FASTCALL OP_SUB_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OPSUBS(3, 5); +} + +static u32 FASTCALL OP_SUB_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OPSUBS(2, 4); +} + +static u32 FASTCALL OP_SUB_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OPSUBS(3, 5); +} + +static u32 FASTCALL OP_SUB_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OPSUBS(2, 4); +} + +static u32 FASTCALL OP_SUB_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OPSUBS(3, 5); +} + +static u32 FASTCALL OP_SUB_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OPSUBS(2, 4); +} + +static u32 FASTCALL OP_SUB_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OPSUBS(3, 5); +} + +static u32 FASTCALL OP_SUB_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OPSUBS(2, 4); +} + +//------------------RSB------------------------ + +#define OP_RSB(a, b) cpu->R[REG_POS(i,12)] = shift_op - cpu->R[REG_POS(i,16)];\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OP_RSBS(a, b) cpu->R[REG_POS(i,12)] = shift_op - v;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(shift_op, v, cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(shift_op, v, cpu->R[REG_POS(i,12)]);\ + return a; + +static u32 FASTCALL OP_RSB_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_RSB(1, 3); +} + +static u32 FASTCALL OP_RSB_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_RSB(2, 4); +} + +static u32 FASTCALL OP_RSB_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_RSB(1, 3); +} + +static u32 FASTCALL OP_RSB_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_RSB(2, 4); +} + +static u32 FASTCALL OP_RSB_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_RSB(1, 3); +} + +static u32 FASTCALL OP_RSB_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_RSB(2, 4); +} + +static u32 FASTCALL OP_RSB_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_RSB(1, 3); +} + +static u32 FASTCALL OP_RSB_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_RSB(2, 4); +} + +static u32 FASTCALL OP_RSB_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_RSB(1, 3); +} + +static u32 FASTCALL OP_RSB_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OP_RSBS(2, 4); +} + +static u32 FASTCALL OP_RSB_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OP_RSBS(3, 5); +} + +static u32 FASTCALL OP_RSB_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OP_RSBS(2, 4); +} + +static u32 FASTCALL OP_RSB_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OP_RSBS(3, 5); +} + +static u32 FASTCALL OP_RSB_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OP_RSBS(2, 4); +} + +static u32 FASTCALL OP_RSB_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OP_RSBS(3, 5); +} + +static u32 FASTCALL OP_RSB_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OP_RSBS(2, 4); +} + +static u32 FASTCALL OP_RSB_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OP_RSBS(3, 5); +} + +static u32 FASTCALL OP_RSB_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OP_RSBS(2, 4); +} + +//------------------ADD----------------------------------- + +#define OP_ADD(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] + shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +static u32 FASTCALL OP_ADD_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_ADD(1, 3); +} + +static u32 FASTCALL OP_ADD_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_ADD(2, 4); +} + +static u32 FASTCALL OP_ADD_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_ADD(1, 3); +} + +static u32 FASTCALL OP_ADD_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_ADD(2, 4); +} + +static u32 FASTCALL OP_ADD_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_ADD(1, 3); +} + +static u32 FASTCALL OP_ADD_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_ADD(2, 4); +} + +static u32 FASTCALL OP_ADD_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_ADD(1, 3); +} + +static u32 FASTCALL OP_ADD_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_ADD(2, 4); +} + +static u32 FASTCALL OP_ADD_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_ADD(1, 3); +} + +#define OP_ADDS(a, b) cpu->R[REG_POS(i,12)] = v + shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.V = SIGNED_OVERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ + return a; + +static u32 FASTCALL OP_ADD_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OP_ADDS(2, 4); +} + +static u32 FASTCALL OP_ADD_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OP_ADDS(3, 5); +} + +static u32 FASTCALL OP_ADD_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OP_ADDS(2, 4); +} + +static u32 FASTCALL OP_ADD_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OP_ADDS(3, 5); +} + +static u32 FASTCALL OP_ADD_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OP_ADDS(2, 4); +} + +static u32 FASTCALL OP_ADD_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OP_ADDS(3, 5); +} + +static u32 FASTCALL OP_ADD_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OP_ADDS(2, 4); +} + +static u32 FASTCALL OP_ADD_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OP_ADDS(3, 5); +} + +static u32 FASTCALL OP_ADD_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OP_ADDS(2, 4); +} + +//------------------ADC----------------------------------- + +#define OP_ADC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] + shift_op + cpu->CPSR.bits.C;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +static u32 FASTCALL OP_ADC_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_ADC(1, 3); +} + +static u32 FASTCALL OP_ADC_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_ADC(2, 4); +} + +static u32 FASTCALL OP_ADC_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_ADC(1, 3); +} + +static u32 FASTCALL OP_ADC_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_ADC(2, 4); +} + +static u32 FASTCALL OP_ADC_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_ADC(1, 3); +} + +static u32 FASTCALL OP_ADC_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_ADC(2, 4); +} + +static u32 FASTCALL OP_ADC_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_ADC(1, 3); +} + +static u32 FASTCALL OP_ADC_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_ADC(2, 4); +} + +static u32 FASTCALL OP_ADC_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_ADC(1, 3); +} + +#define OP_ADCS(a, b) \ + { \ + u32 tmp = shift_op + cpu->CPSR.bits.C;\ + cpu->R[REG_POS(i,12)] = v + tmp;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(shift_op, cpu->CPSR.bits.C, tmp) | UNSIGNED_OVERFLOW(v, tmp, cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.V = SIGNED_OVERFLOW(shift_op, cpu->CPSR.bits.C, tmp) | SIGNED_OVERFLOW(v, tmp, cpu->R[REG_POS(i,12)]);\ + return a; \ + } + +static u32 FASTCALL OP_ADC_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OP_ADCS(2, 4); +} + +static u32 FASTCALL OP_ADC_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OP_ADCS(3, 5); +} + +static u32 FASTCALL OP_ADC_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OP_ADCS(2, 4); +} + +static u32 FASTCALL OP_ADC_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OP_ADCS(3, 5); +} + +static u32 FASTCALL OP_ADC_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OP_ADCS(2, 4); +} + +static u32 FASTCALL OP_ADC_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OP_ADCS(3, 5); +} + +static u32 FASTCALL OP_ADC_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OP_ADCS(2, 4); +} + +static u32 FASTCALL OP_ADC_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OP_ADCS(3, 5); +} + +static u32 FASTCALL OP_ADC_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OP_ADCS(2, 4); +} + +//-------------SBC------------------------------------- + +#define OP_SBC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] - shift_op - (!cpu->CPSR.bits.C);\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +static u32 FASTCALL OP_SBC_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_SBC(1, 3); +} + +static u32 FASTCALL OP_SBC_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_SBC(2, 4); +} + +static u32 FASTCALL OP_SBC_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_SBC(1, 3); +} + +static u32 FASTCALL OP_SBC_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_SBC(2, 4); +} + +static u32 FASTCALL OP_SBC_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_SBC(1, 3); +} + +static u32 FASTCALL OP_SBC_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_SBC(2, 4); +} + +static u32 FASTCALL OP_SBC_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_SBC(1, 3); +} + +static u32 FASTCALL OP_SBC_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_SBC(2, 4); +} + +static u32 FASTCALL OP_SBC_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_SBC(1, 3); +} + +#define OP_SBCS(a, b) \ + { \ + u32 tmp = v - (!cpu->CPSR.bits.C);\ + cpu->R[REG_POS(i,12)] = tmp - shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = (!UNSIGNED_UNDERFLOW(v, (!cpu->CPSR.bits.C), tmp)) & (!UNSIGNED_UNDERFLOW(tmp, shift_op, cpu->R[REG_POS(i,12)]));\ + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(v, (!cpu->CPSR.bits.C), tmp) | SIGNED_UNDERFLOW(tmp, shift_op, cpu->R[REG_POS(i,12)]);\ + return a; \ + } + +static u32 FASTCALL OP_SBC_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OP_SBCS(2, 4); +} + +static u32 FASTCALL OP_SBC_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OP_SBCS(3, 5); +} + +static u32 FASTCALL OP_SBC_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OP_SBCS(2, 4); +} + +static u32 FASTCALL OP_SBC_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OP_SBCS(3, 5); +} + +static u32 FASTCALL OP_SBC_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OP_SBCS(2, 4); +} + +static u32 FASTCALL OP_SBC_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OP_SBCS(3, 5); +} + +static u32 FASTCALL OP_SBC_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OP_SBCS(2, 4); +} + +static u32 FASTCALL OP_SBC_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OP_SBCS(3, 5); +} + +static u32 FASTCALL OP_SBC_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OP_SBCS(2, 4); +} + +//---------------RSC---------------------------------- + +#define OP_RSC(a, b) cpu->R[REG_POS(i,12)] = shift_op - cpu->R[REG_POS(i,16)] - (!cpu->CPSR.bits.C);\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +static u32 FASTCALL OP_RSC_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_RSC(1, 3); +} + +static u32 FASTCALL OP_RSC_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_RSC(2, 4); +} + +static u32 FASTCALL OP_RSC_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_RSC(1, 3); +} + +static u32 FASTCALL OP_RSC_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_RSC(2, 4); +} + +static u32 FASTCALL OP_RSC_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_RSC(1, 3); +} + +static u32 FASTCALL OP_RSC_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_RSC(2, 4); +} + +static u32 FASTCALL OP_RSC_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_RSC(1, 3); +} + +static u32 FASTCALL OP_RSC_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_RSC(2, 4); +} + +static u32 FASTCALL OP_RSC_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_RSC(1, 3); +} + +#define OP_RSCS(a,b) \ + { \ + u32 tmp = shift_op - (!cpu->CPSR.bits.C);\ + cpu->R[REG_POS(i,12)] = tmp - v;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = (!UNSIGNED_UNDERFLOW(shift_op, (!cpu->CPSR.bits.C), tmp)) & (!UNSIGNED_UNDERFLOW(tmp, v, cpu->R[REG_POS(i,12)]));\ + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(shift_op, (!cpu->CPSR.bits.C), tmp) | SIGNED_UNDERFLOW(tmp, v, cpu->R[REG_POS(i,12)]);\ + return a; \ + } + +static u32 FASTCALL OP_RSC_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OP_RSCS(2,4); +} + +static u32 FASTCALL OP_RSC_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OP_RSCS(3,5); +} + +static u32 FASTCALL OP_RSC_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OP_RSCS(2,4); +} + +static u32 FASTCALL OP_RSC_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OP_RSCS(3,5); +} + +static u32 FASTCALL OP_RSC_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OP_RSCS(2,4); +} + +static u32 FASTCALL OP_RSC_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OP_RSCS(3,5); +} + +static u32 FASTCALL OP_RSC_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OP_RSCS(2,4); +} + +static u32 FASTCALL OP_RSC_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OP_RSCS(3,5); +} + +static u32 FASTCALL OP_RSC_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OP_RSCS(2,4); +} + +//-------------------TST---------------------------- + +#define OP_TST(a) \ + { \ + unsigned tmp = cpu->R[REG_POS(i,16)] & shift_op;\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(tmp);\ + cpu->CPSR.bits.Z = (tmp==0);\ + return a; \ + } + +static u32 FASTCALL OP_TST_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_IMM; + OP_TST(1); +} + +static u32 FASTCALL OP_TST_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_REG; + OP_TST(2); +} + +static u32 FASTCALL OP_TST_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_IMM; + OP_TST(1); +} + +static u32 FASTCALL OP_TST_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_REG; + OP_TST(2); +} + +static u32 FASTCALL OP_TST_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_IMM; + OP_TST(1); +} + +static u32 FASTCALL OP_TST_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_REG; + OP_TST(2); +} + +static u32 FASTCALL OP_TST_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_IMM; + OP_TST(1); +} + +static u32 FASTCALL OP_TST_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_REG; + OP_TST(2); +} + +static u32 FASTCALL OP_TST_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_IMM_VALUE; + OP_TST(1); +} + +//-------------------TEQ---------------------------- + +#define OP_TEQ(a) \ + { \ + unsigned tmp = cpu->R[REG_POS(i,16)] ^ shift_op;\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(tmp);\ + cpu->CPSR.bits.Z = (tmp==0);\ + return a; \ + } + +static u32 FASTCALL OP_TEQ_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_IMM; + OP_TEQ(1); +} + +static u32 FASTCALL OP_TEQ_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_REG; + OP_TEQ(2); +} + +static u32 FASTCALL OP_TEQ_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_IMM; + OP_TEQ(1); +} + +static u32 FASTCALL OP_TEQ_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_REG; + OP_TEQ(2); +} + +static u32 FASTCALL OP_TEQ_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_IMM; + OP_TEQ(1); +} + +static u32 FASTCALL OP_TEQ_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_REG; + OP_TEQ(2); +} + +static u32 FASTCALL OP_TEQ_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_IMM; + OP_TEQ(1); +} + +static u32 FASTCALL OP_TEQ_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_REG; + OP_TEQ(2); +} + +static u32 FASTCALL OP_TEQ_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_IMM_VALUE; + OP_TEQ(1); +} + +//-------------CMP------------------------------------- + +#define OP_CMP(a) \ + { \ + u32 tmp = cpu->R[REG_POS(i,16)] - shift_op;\ + cpu->CPSR.bits.N = BIT31(tmp);\ + cpu->CPSR.bits.Z = (tmp==0);\ + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ + return a; \ + } + +static u32 FASTCALL OP_CMP_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_CMP(1); +} + +static u32 FASTCALL OP_CMP_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_CMP(2); +} + +static u32 FASTCALL OP_CMP_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_CMP(1); +} + +static u32 FASTCALL OP_CMP_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_CMP(2); +} + +static u32 FASTCALL OP_CMP_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_CMP(1); +} + +static u32 FASTCALL OP_CMP_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_CMP(2); +} + +static u32 FASTCALL OP_CMP_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_CMP(1); +} + +static u32 FASTCALL OP_CMP_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_CMP(2); +} + +static u32 FASTCALL OP_CMP_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_CMP(1); +} + +//---------------CMN--------------------------- + +#define OP_CMN(a) \ + { \ + u32 tmp = cpu->R[REG_POS(i,16)] + shift_op;\ + cpu->CPSR.bits.N = BIT31(tmp);\ + cpu->CPSR.bits.Z = (tmp==0);\ + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ + cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ + return a; \ + } + +static u32 FASTCALL OP_CMN_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_CMN(1); +} + +static u32 FASTCALL OP_CMN_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_CMN(2); +} + +static u32 FASTCALL OP_CMN_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_CMN(1); +} + +static u32 FASTCALL OP_CMN_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_CMN(2); +} + +static u32 FASTCALL OP_CMN_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_CMN(1); +} + +static u32 FASTCALL OP_CMN_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_CMN(2); +} + +static u32 FASTCALL OP_CMN_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_CMN(1); +} + +static u32 FASTCALL OP_CMN_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_CMN(2); +} + +static u32 FASTCALL OP_CMN_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_CMN(1); +} + +//------------------ORR------------------- + +#define OP_ORR(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +static u32 FASTCALL OP_ORR_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_ORR(1, 3); +} + +static u32 FASTCALL OP_ORR_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_ORR(2, 4); +} + +static u32 FASTCALL OP_ORR_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_ORR(1, 3); +} + +static u32 FASTCALL OP_ORR_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_ORR(2, 4); +} + +static u32 FASTCALL OP_ORR_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_ORR(1, 3); +} + +static u32 FASTCALL OP_ORR_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_ORR(2, 4); +} + +static u32 FASTCALL OP_ORR_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_ORR(1, 3); +} + +static u32 FASTCALL OP_ORR_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_ORR(2, 4); +} + +static u32 FASTCALL OP_ORR_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_ORR(1, 3); +} + +static u32 FASTCALL OP_ORR_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_IMM; + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; + if(REG_POS(i,12)==15) + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1)); + cpu->next_instruction = cpu->R[15]; + return 4; + } + cpu->CPSR.bits.C = c; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); + return 2; +} + +static u32 FASTCALL OP_ORR_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_REG; + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; + if(REG_POS(i,12)==15) + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1)); + cpu->next_instruction = cpu->R[15]; + return 5; + } + cpu->CPSR.bits.C = c; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); + return 3; +} + +static u32 FASTCALL OP_ORR_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_IMM; + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; + if(REG_POS(i,12)==15) + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1)); + cpu->next_instruction = cpu->R[15]; + return 4; + } + cpu->CPSR.bits.C = c; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); + return 2; +} + +static u32 FASTCALL OP_ORR_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_REG; + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; + if(REG_POS(i,12)==15) + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1)); + cpu->next_instruction = cpu->R[15]; + return 5; + } + cpu->CPSR.bits.C = c; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); + return 3; +} + +static u32 FASTCALL OP_ORR_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_IMM; + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; + if(REG_POS(i,12)==15) + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1)); + cpu->next_instruction = cpu->R[15]; + return 4; + } + cpu->CPSR.bits.C = c; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); + return 2; +} + +static u32 FASTCALL OP_ORR_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_REG; + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; + if(REG_POS(i,12)==15) + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1)); + cpu->next_instruction = cpu->R[15]; + return 5; + } + cpu->CPSR.bits.C = c; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); + return 3; +} + +static u32 FASTCALL OP_ORR_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_IMM; + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; + if(REG_POS(i,12)==15) + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1)); + cpu->next_instruction = cpu->R[15]; + return 4; + } + cpu->CPSR.bits.C = c; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); + return 2; +} + +static u32 FASTCALL OP_ORR_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_REG; + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; + if(REG_POS(i,12)==15) + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1)); + cpu->next_instruction = cpu->R[15]; + return 5; + } + cpu->CPSR.bits.C = c; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); + return 3; +} + +static u32 FASTCALL OP_ORR_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_IMM_VALUE; + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; + if(REG_POS(i,12)==15) + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1)); + cpu->next_instruction = cpu->R[15]; + return 4; + } + cpu->CPSR.bits.C = c; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); + return 2; +} + +//------------------MOV------------------- + +#define OP_MOV(a, b) cpu->R[REG_POS(i,12)] = shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = shift_op;\ + return b;\ + }\ + return a; + +#define OP_MOV_S(a, b) cpu->R[REG_POS(i,12)] = shift_op;\ + if(BIT20(i) && REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + return a;\ + +static u32 FASTCALL OP_MOV_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_MOV(1,3); +} + +static u32 FASTCALL OP_MOV_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OP_MOV(2,4); +} + +static u32 FASTCALL OP_MOV_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_MOV(1,3); +} + +static u32 FASTCALL OP_MOV_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OP_MOV(2,4); +} + +static u32 FASTCALL OP_MOV_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_MOV(1,3); +} + +static u32 FASTCALL OP_MOV_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OP_MOV(2,4); +} + +static u32 FASTCALL OP_MOV_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_MOV(2,4); +} + +static u32 FASTCALL OP_MOV_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OP_MOV(2,4); +} + +static u32 FASTCALL OP_MOV_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OP_MOV(1,3); +} + +static u32 FASTCALL OP_MOV_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_IMM; + OP_MOV_S(2,4); +} + +static u32 FASTCALL OP_MOV_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_REG; + OP_MOV_S(3,5); +} + +static u32 FASTCALL OP_MOV_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_IMM; + OP_MOV_S(2,4); +} + +static u32 FASTCALL OP_MOV_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_REG; + OP_MOV_S(3,5); +} + +static u32 FASTCALL OP_MOV_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_IMM; + OP_MOV_S(2,4); +} + +static u32 FASTCALL OP_MOV_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_REG; + OP_MOV_S(3,5); +} + +static u32 FASTCALL OP_MOV_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_IMM; + OP_MOV_S(2,4); +} + +static u32 FASTCALL OP_MOV_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_REG; + OP_MOV_S(3,5); +} + +static u32 FASTCALL OP_MOV_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_IMM_VALUE; + OP_MOV_S(2,4); +} + +//------------------BIC------------------- +#define OPP_BIC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & (~shift_op);\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OPP_BIC_S(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & (~shift_op);\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + return a; + +static u32 FASTCALL OP_BIC_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OPP_BIC(1,3); +} + +static u32 FASTCALL OP_BIC_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OPP_BIC(2,4); +} + +static u32 FASTCALL OP_BIC_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OPP_BIC(1,3); +} + +static u32 FASTCALL OP_BIC_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OPP_BIC(2,4); +} + +static u32 FASTCALL OP_BIC_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OPP_BIC(1,3); +} + +static u32 FASTCALL OP_BIC_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OPP_BIC(2,4); +} + +static u32 FASTCALL OP_BIC_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OPP_BIC(1,3); +} + +static u32 FASTCALL OP_BIC_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OPP_BIC(2,4); +} + +static u32 FASTCALL OP_BIC_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OPP_BIC(1,3); +} + +static u32 FASTCALL OP_BIC_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_IMM; + OPP_BIC_S(2,4); +} + +static u32 FASTCALL OP_BIC_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_REG; + OPP_BIC_S(3,5); +} + +static u32 FASTCALL OP_BIC_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_IMM; + OPP_BIC_S(2,4); +} + +static u32 FASTCALL OP_BIC_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_REG; + OPP_BIC_S(3,5); +} + +static u32 FASTCALL OP_BIC_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_IMM; + OPP_BIC_S(2,4); +} + +static u32 FASTCALL OP_BIC_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_REG; + OPP_BIC_S(3,5); +} + +static u32 FASTCALL OP_BIC_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_IMM; + OPP_BIC_S(2,4); +} + +static u32 FASTCALL OP_BIC_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_REG; + OPP_BIC_S(3,5); +} + +static u32 FASTCALL OP_BIC_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_IMM_VALUE; + OPP_BIC_S(2,4); +} + +//------------------MVN------------------- +#define OPP_MVN(a, b) cpu->R[REG_POS(i,12)] = ~shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OPP_MVN_S(a, b) cpu->R[REG_POS(i,12)] = ~shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0X0FFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + return a; + +static u32 FASTCALL OP_MVN_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OPP_MVN(1,3); +} + +static u32 FASTCALL OP_MVN_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSL_REG; + OPP_MVN(2,4); +} + +static u32 FASTCALL OP_MVN_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OPP_MVN(1,3); +} + +static u32 FASTCALL OP_MVN_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + LSR_REG; + OPP_MVN(2,4); +} + +static u32 FASTCALL OP_MVN_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OPP_MVN(1,3); +} + +static u32 FASTCALL OP_MVN_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ASR_REG; + OPP_MVN(2,4); +} + +static u32 FASTCALL OP_MVN_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OPP_MVN(1,3); +} + +static u32 FASTCALL OP_MVN_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + ROR_REG; + OPP_MVN(2,4); +} + +static u32 FASTCALL OP_MVN_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + OPP_MVN(1,3); +} + +static u32 FASTCALL OP_MVN_S_LSL_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_IMM; + OPP_MVN_S(2,4); +} + +static u32 FASTCALL OP_MVN_S_LSL_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSL_REG; + OPP_MVN_S(3,5); +} + +static u32 FASTCALL OP_MVN_S_LSR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_IMM; + OPP_MVN_S(2,4); +} + +static u32 FASTCALL OP_MVN_S_LSR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_LSR_REG; + OPP_MVN_S(3,5); +} + +static u32 FASTCALL OP_MVN_S_ASR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_IMM; + OPP_MVN_S(2,4); +} + +static u32 FASTCALL OP_MVN_S_ASR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ASR_REG; + OPP_MVN_S(3,5); +} + +static u32 FASTCALL OP_MVN_S_ROR_IMM(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_IMM; + OPP_MVN_S(2,4); +} + +static u32 FASTCALL OP_MVN_S_ROR_REG(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_ROR_REG; + OPP_MVN_S(3,5); +} + +static u32 FASTCALL OP_MVN_S_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + S_IMM_VALUE; + OPP_MVN_S(2,4); +} + +//-------------MUL------------------------ +#define OPP_M(a,b) v >>= 8;\ + if((v==0)||(v==0xFFFFFF))\ + return b;\ + v >>= 8;\ + if((v==0)||(v==0xFFFF))\ + return b+1;\ + v >>= 8;\ + if((v==0)||(v==0xFF))\ + return b+2;\ + return a;\ + +static u32 FASTCALL OP_MUL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v; + OPP_M(5,2); +} + +static u32 FASTCALL OP_MLA(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + u32 a = cpu->R[REG_POS(i,8)]; + u32 b = cpu->R[REG_POS(i,12)]; + cpu->R[REG_POS(i,16)] = a * v + b; + + OPP_M(6,3); +} + +static u32 FASTCALL OP_MUL_S(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v; + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0); + + OPP_M(6,3); +} + +static u32 FASTCALL OP_MLA_S(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v + cpu->R[REG_POS(i,12)]; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0); + OPP_M(7,4); +} + +//----------UMUL-------------------------- + +static u32 FASTCALL OP_UMULL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)]; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] = (u32)(res>>32); + + OPP_M(6,3); +} + +static u32 FASTCALL OP_UMLAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)] + (u64)cpu->R[REG_POS(i,12)]; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] += (u32)(res>>32); + + OPP_M(7,4); +} + +static u32 FASTCALL OP_UMULL_S(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)]; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] = (u32)(res>>32); + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); + + OPP_M(7,4); +} + +static u32 FASTCALL OP_UMLAL_S(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)] + (u64)cpu->R[REG_POS(i,12)]; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] += (u32)(res>>32); + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); + + OPP_M(8,5); +} + +//----------SMUL-------------------------- + +static u32 FASTCALL OP_SMULL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 v = (s32)cpu->R[REG_POS(i,0)]; + s64 b = (s32)cpu->R[REG_POS(i,8)]; + s64 res = v * b; + + cpu->R[REG_POS(i,12)] = (u32)(res&0xFFFFFFFF); + cpu->R[REG_POS(i,16)] = (u32)(res>>32); + + v &= 0xFFFFFFFF; + + OPP_M(6,3); +} + +static u32 FASTCALL OP_SMLAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + + s64 v = (s32)cpu->R[REG_POS(i,0)]; + s64 b = (s32)cpu->R[REG_POS(i,8)]; + s64 res = v * b + (u64)cpu->R[REG_POS(i,12)]; + + //LOG("%08X * %08X + %08X%08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], cpu->R[REG_POS(i,16)], cpu->R[REG_POS(i,12)]); + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] += (u32)(res>>32); + + //LOG("= %08X%08X %08X%08X\r\n", cpu->R[REG_POS(i,16)], cpu->R[REG_POS(i,12)], res); + + v &= 0xFFFFFFFF; + + OPP_M(7,4); +} + +static u32 FASTCALL OP_SMULL_S(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 v = (s32)cpu->R[REG_POS(i,0)]; + s64 b = (s32)cpu->R[REG_POS(i,8)]; + s64 res = v * b; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] = (u32)(res>>32); + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); + + v &= 0xFFFFFFFF; + + OPP_M(7,4); +} + +static u32 FASTCALL OP_SMLAL_S(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 v = (s32)cpu->R[REG_POS(i,0)]; + s64 b = (s32)cpu->R[REG_POS(i,8)]; + s64 res = v * b + (u64)cpu->R[REG_POS(i,12)]; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] += (u32)(res>>32); + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); + + v &= 0xFFFFFFFF; + + OPP_M(8,5); +} + +//---------------SWP------------------------------ + +static u32 FASTCALL OP_SWP(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u32 tmp = ROR(MMU_readWord(cpu->proc_ID, adr), ((cpu->R[REG_POS(i,16)]&3)<<3)); + + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,0)]); + cpu->R[REG_POS(i,12)] = tmp; + + return 4 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]*2; +} + +static u32 FASTCALL OP_SWPB(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u8 tmp = MMU_readByte(cpu->proc_ID, adr); + MMU_writeByte(cpu->proc_ID, adr, (u8)(cpu->R[REG_POS(i,0)]&0xFF)); + cpu->R[REG_POS(i,12)] = tmp; + + return 4 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]*2; +} + +//------------LDRH----------------------------- + +static u32 FASTCALL OP_LDRH_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_PRE_INDE_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_PRE_INDE_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_PRE_INDE_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_PRE_INDE_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_POS_INDE_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] += IMM_OFF; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_POS_INDE_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] -= IMM_OFF; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_POS_INDE_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRH_POS_INDE_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (u32)MMU_readHWord(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +//------------STRH----------------------------- + +static u32 FASTCALL OP_STRH_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_PRE_INDE_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,16)] = adr; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_PRE_INDE_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_PRE_INDE_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_PRE_INDE_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_POS_INDE_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] += IMM_OFF; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_POS_INDE_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] -= IMM_OFF; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_POS_INDE_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRH_POS_INDE_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + MMU_writeHWord(cpu->proc_ID, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +//----------------LDRSH-------------------------- + +static u32 FASTCALL OP_LDRSH_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_PRE_INDE_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_PRE_INDE_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_PRE_INDE_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_PRE_INDE_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_POS_INDE_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] += IMM_OFF; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_POS_INDE_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] -= IMM_OFF; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_POS_INDE_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSH_POS_INDE_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)MMU_readHWord(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +//----------------------LDRSB---------------------- + +static u32 FASTCALL OP_LDRSB_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_PRE_INDE_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_PRE_INDE_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_PRE_INDE_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_PRE_INDE_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_POS_INDE_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] += IMM_OFF; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_POS_INDE_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] -= IMM_OFF; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_POS_INDE_P_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRSB_POS_INDE_M_REG_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)MMU_readByte(cpu->proc_ID, adr)); + cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +//--------------MRS-------------------------------- + +static u32 FASTCALL OP_MRS_CPSR(armcpu_t *cpu) +{ + cpu->R[REG_POS(cpu->instruction,12)] = cpu->CPSR.val; + + return 1; +} + +static u32 FASTCALL OP_MRS_SPSR(armcpu_t *cpu) +{ + cpu->R[REG_POS(cpu->instruction,12)] = cpu->SPSR.val; + + return 1; +} + +//--------------MSR-------------------------------- + +static u32 FASTCALL OP_MSR_CPSR(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 operand = cpu->R[REG_POS(i,0)]; + + if(cpu->CPSR.bits.mode!=USR) + { + if(BIT16(i)) + { + armcpu_switchMode(cpu, operand & 0x1F); + cpu->CPSR.val = (cpu->CPSR.val & 0xFFFFFF00) | (operand & 0xFF); + } + if(BIT17(i)) + cpu->CPSR.val = (cpu->CPSR.val & 0xFFFF00FF) | (operand & 0xFF00); + if(BIT18(i)) + cpu->CPSR.val = (cpu->CPSR.val & 0xFF00FFFF) | (operand & 0xFF0000); + } + if(BIT19(i)) + cpu->CPSR.val = (cpu->CPSR.val & 0x00FFFFFF) | (operand & 0xFF000000); + + return 1; +} + +static u32 FASTCALL OP_MSR_SPSR(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 operand = cpu->R[REG_POS(i,0)]; + + if(cpu->CPSR.bits.mode!=USR) + { + if(BIT16(i)) + { + cpu->SPSR.val = (cpu->SPSR.val & 0xFFFFFF00) | (operand & 0XFF); + } + if(BIT17(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0xFFFF00FF) | (operand & 0XFF00); + if(BIT18(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0xFF00FFFF) | (operand & 0XFF0000); + } + if(BIT19(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0x00FFFFFF) | (operand & 0XFF000000); + + return 1; +} + +static u32 FASTCALL OP_MSR_CPSR_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + + if(cpu->CPSR.bits.mode!=USR) + { + if(BIT16(i)) + { + armcpu_switchMode(cpu, shift_op & 0x1F); + cpu->CPSR.val = (cpu->CPSR.val & 0xFFFFFF00) | (shift_op & 0XFF); + } + if(BIT17(i)) + cpu->CPSR.val = (cpu->CPSR.val & 0xFFFF00FF) | (shift_op & 0XFF00); + if(BIT18(i)) + cpu->CPSR.val = (cpu->CPSR.val & 0xFF00FFFF) | (shift_op & 0XFF0000); + } + if(BIT19(i)) + { + //cpu->CPSR.val = (cpu->CPSR.val & 0xFF000000) | (shift_op & 0XFF000000); + cpu->CPSR.val = (cpu->CPSR.val & 0x00FFFFFF) | (shift_op & 0xFF000000); + } + + return 1; +} + +static u32 FASTCALL OP_MSR_SPSR_IMM_VAL(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + IMM_VALUE; + + if(cpu->CPSR.bits.mode!=USR) + { + if(BIT16(i)) + { + cpu->SPSR.val = (cpu->SPSR.val & 0xFFFFFF00) | (shift_op & 0XFF); + } + if(BIT17(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0xFFFF00FF) | (shift_op & 0XFF00); + if(BIT18(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0xFF00FFFF) | (shift_op & 0XFF0000); + } + if(BIT19(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0xFF000000) | (shift_op & 0XFF000000); + + return 1; +} + +//-----------------BRANCH-------------------------- + +static u32 FASTCALL OP_BX(armcpu_t *cpu) +{ + u32 tmp = cpu->R[REG_POS(cpu->instruction, 0)]; + + cpu->CPSR.bits.T = BIT0(tmp); + cpu->R[15] = tmp & 0x0FFFFFFE; + cpu->next_instruction = cpu->R[15]; + return 3; +} + +static u32 FASTCALL OP_BLX_REG(armcpu_t *cpu) +{ + u32 tmp = cpu->R[REG_POS(cpu->instruction, 0)]; + + cpu->R[14] = cpu->next_instruction; + cpu->CPSR.bits.T = BIT0(tmp); + cpu->R[15] = tmp & 0x0FFFFFFE; + cpu->next_instruction = cpu->R[15]; + return 3; +} + +#define SIGNEXTEND_24(i) (((s32)((i)<<8))>>8) + +static u32 FASTCALL OP_B(armcpu_t *cpu) +{ + u32 off = SIGNEXTEND_24(cpu->instruction); + if(CONDITION(cpu->instruction)==0xF) + { + cpu->R[14] = cpu->next_instruction; + cpu->CPSR.bits.T = 1; + } + cpu->R[15] += (off<<2); + cpu->next_instruction = cpu->R[15]; + + return 3; +} + +static u32 FASTCALL OP_BL(armcpu_t *cpu) +{ + u32 off = SIGNEXTEND_24(cpu->instruction); + if(CONDITION(cpu->instruction)==0xF) + { + cpu->CPSR.bits.T = 1; + cpu->R[15] += 2; + } + cpu->R[14] = cpu->next_instruction; + cpu->R[15] += (off<<2); + cpu->next_instruction = cpu->R[15]; + + return 3; +} + +//----------------CLZ------------------------------- + +u8 CLZ_TAB[16]= +{ + 0, // 0000 + 1, // 0001 + 2, 2, // 001X + 3, 3, 3, 3, // 01XX + 4, 4, 4, 4, 4, 4, 4, 4 // 1XXX +}; + +static u32 FASTCALL OP_CLZ(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 Rm = cpu->R[REG_POS(i,0)]; + u32 pos; + + if(Rm==0) + { + cpu->R[REG_POS(i,12)]=32; + return 2; + } + + Rm |= (Rm >>1); + Rm |= (Rm >>2); + Rm |= (Rm >>4); + Rm |= (Rm >>8); + Rm |= (Rm >>16); + + pos = + CLZ_TAB[Rm&0xF] + + CLZ_TAB[(Rm>>4)&0xF] + + CLZ_TAB[(Rm>>8)&0xF] + + CLZ_TAB[(Rm>>12)&0xF] + + CLZ_TAB[(Rm>>16)&0xF] + + CLZ_TAB[(Rm>>20)&0xF] + + CLZ_TAB[(Rm>>24)&0xF] + + CLZ_TAB[(Rm>>28)&0xF]; + + cpu->R[REG_POS(i,12)]=32 - pos; + + return 2; +} + +//--------------------QADD--QSUB------------------------------ + +static u32 FASTCALL OP_QADD(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 res = cpu->R[REG_POS(i,16)]+cpu->R[REG_POS(i,0)]; + + LOG("spe add\r\n"); + if(SIGNED_OVERFLOW(cpu->R[REG_POS(i,16)],cpu->R[REG_POS(i,0)], res)) + { + cpu->CPSR.bits.Q=1; + cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); + return 2; + } + cpu->R[REG_POS(i,12)]=res; + if(REG_POS(i,12)==15) + { + cpu->R[15] &= 0X0FFFFFFC; + cpu->next_instruction = cpu->R[15]; + return 3; + } + return 2; +} + +static u32 FASTCALL OP_QSUB(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 res = cpu->R[REG_POS(i,0)]-cpu->R[REG_POS(i,16)]; + + LOG("spe add\r\n"); + if(SIGNED_UNDERFLOW(cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,16)], res)) + { + cpu->CPSR.bits.Q=1; + cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); + return 2; + } + cpu->R[REG_POS(i,12)]=res; + if(REG_POS(i,12)==15) + { + cpu->R[15] &= 0X0FFFFFFC; + cpu->next_instruction = cpu->R[15]; + return 3; + } + return 2; +} + +static u32 FASTCALL OP_QDADD(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 mul = cpu->R[REG_POS(i,16)]<<1; + u32 res; + + + LOG("spe add\r\n"); + if(BIT31(cpu->R[REG_POS(i,16)])!=BIT31(mul)) + { + cpu->CPSR.bits.Q=1; + mul = 0x80000000-BIT31(mul); + } + + res = mul + cpu->R[REG_POS(i,0)]; + if(SIGNED_OVERFLOW(cpu->R[REG_POS(i,0)],mul, res)) + { + cpu->CPSR.bits.Q=1; + cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); + return 2; + } + cpu->R[REG_POS(i,12)]=res; + if(REG_POS(i,12)==15) + { + cpu->R[15] &= 0X0FFFFFFC; + cpu->next_instruction = cpu->R[15]; + return 3; + } + return 2; +} + +static u32 FASTCALL OP_QDSUB(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 mul = cpu->R[REG_POS(i,16)]<<1; + u32 res; + + + LOG("spe add\r\n"); + if(BIT31(cpu->R[REG_POS(i,16)])!=BIT31(mul)) + { + cpu->CPSR.bits.Q=1; + mul = 0x80000000-BIT31(mul); + } + + res = cpu->R[REG_POS(i,0)] - mul; + if(SIGNED_UNDERFLOW(cpu->R[REG_POS(i,0)], mul, res)) + { + cpu->CPSR.bits.Q=1; + cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); + return 2; + } + cpu->R[REG_POS(i,12)]=res; + if(REG_POS(i,12)==15) + { + cpu->R[15] &= 0X0FFFFFFC; + cpu->next_instruction = cpu->R[15]; + return 3; + } + return 2; +} + +//-----------------SMUL------------------------------- + +#define HWORD(i) ((s32)(((s32)(i))>>16)) +#define LWORD(i) (s32)(((s32)((i)<<16))>>16) + +static u32 FASTCALL OP_SMUL_B_B(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + + cpu->R[REG_POS(i,16)] = (u32)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); + + return 2; +} + +static u32 FASTCALL OP_SMUL_B_T(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + + cpu->R[REG_POS(i,16)] = (u32)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + + return 2; +} + +static u32 FASTCALL OP_SMUL_T_B(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + + cpu->R[REG_POS(i,16)] = (u32)(HWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); + + return 2; +} + +static u32 FASTCALL OP_SMUL_T_T(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + + cpu->R[REG_POS(i,16)] = (u32)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + + return 2; +} + +//-----------SMLA---------------------------- + +static u32 FASTCALL OP_SMLA_B_B(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 tmp = (u32)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLABB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +static u32 FASTCALL OP_SMLA_B_T(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 tmp = (u32)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLABT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +static u32 FASTCALL OP_SMLA_T_B(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 tmp = (u32)(HWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLATB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +static u32 FASTCALL OP_SMLA_T_T(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 tmp = (u32)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLATT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +//--------------SMLAL--------------------------------------- + +static u32 FASTCALL OP_SMLAL_B_B(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 tmp = (s64)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); + u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; + + LOG("SMLALBB %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + (res + ((tmp<0)*0xFFFFFFFF))), (int)(u32) res); + + cpu->R[REG_POS(i,12)] = (u32) res; + cpu->R[REG_POS(i,16)] += (res + ((tmp<0)*0xFFFFFFFF)); + + return 2; +} + +static u32 FASTCALL OP_SMLAL_B_T(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 tmp = (s64)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; + + LOG("SMLALBT %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); + + cpu->R[REG_POS(i,12)] = (u32) res; + cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); + + return 2; +} + +static u32 FASTCALL OP_SMLAL_T_B(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 tmp = (s64)(HWORD(cpu->R[REG_POS(i,0)])* (s64)LWORD(cpu->R[REG_POS(i,8)])); + u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; + + LOG("SMLALTB %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); + + cpu->R[REG_POS(i,12)] = (u32) res; + cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); + + return 2; +} + +static u32 FASTCALL OP_SMLAL_T_T(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 tmp = (s64)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; + + LOG("SMLALTT %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); + + cpu->R[REG_POS(i,12)] = (u32) res; + cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); + + return 2; +} + +//--------------SMULW-------------------- + +static u32 FASTCALL OP_SMULW_B(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 tmp = (s64)LWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); + + //LOG("SMULWB %08X * %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], ((tmp>>16)&0xFFFFFFFF); + + cpu->R[REG_POS(i,16)] = ((tmp>>16)&0xFFFFFFFF); + + return 2; +} + +static u32 FASTCALL OP_SMULW_T(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 tmp = (s64)HWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); + + //LOG("SMULWT %08X * %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], ((tmp>>16)&0xFFFFFFFF)); + + cpu->R[REG_POS(i,16)] = ((tmp>>16)&0xFFFFFFFF); + + return 2; +} + +//--------------SMLAW------------------- +static u32 FASTCALL OP_SMLAW_B(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 tmp = (s64)LWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLAWB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, (tmp>>16) + a); + + tmp = (tmp>>16); + + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +static u32 FASTCALL OP_SMLAW_T(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + s64 tmp = (s64)HWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLAWT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, ((tmp>>16)&0xFFFFFFFF) + a); + + tmp = ((tmp>>16)&0xFFFFFFFF); + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +//------------LDR--------------------------- + +static u32 FASTCALL OP_LDR_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + u32 val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + u32 val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + u32 val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + u32 val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u32 val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +//------------------------------------------------------------ +static u32 FASTCALL OP_LDR_P_IMM_OFF_POSTIND2(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + + u32 adr = cpu->R[REG_POS(i,16)]; + u32 val = MMU_readWord(cpu->proc_ID, adr); + u32 old; + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + old = armcpu_switchMode(cpu, USR); + cpu->R[REG_POS(i,12)] = val; + armcpu_switchMode(cpu, old); + + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +//------------------------------------------------------------ + +static u32 FASTCALL OP_LDR_M_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u32 val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + shift_op; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr - shift_op; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + shift_op; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr - shift_op; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + shift_op; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr - shift_op; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + shift_op; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readWord(cpu->proc_ID, adr); + + if(adr&3) + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0X0FFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr - shift_op; + return 5 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +//-----------------LDRB------------------------------------------- + +static u32 FASTCALL OP_LDRB_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + u32 val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + u32 val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + u32 val = MMU_readByte(cpu->proc_ID, adr); + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + u32 val = MMU_readByte(cpu->proc_ID, adr); + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u32 val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u32 val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +//----------------------STR-------------------------------- + +static u32 FASTCALL OP_STR_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + +// execute = false; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_LSL_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_LSL_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_LSR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_LSR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_ASR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_ASR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_ROR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_ROR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_LSL_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_LSL_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_LSR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_LSR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_ASR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_ASR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_ROR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_ROR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STR_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeWord(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT32[cpu->proc_ID][(adr>>24)&0xF]; +} + +//-----------------------STRB------------------------------------- + +static u32 FASTCALL OP_STRB_P_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + MMU_writeByte(cpu->proc_ID, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF_PREIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +//-----------------------LDRBT------------------------------------- + +static u32 FASTCALL OP_LDRBT_P_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRBT_M_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRBT_P_REG_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + cpu->R[REG_POS(i,0)]; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRBT_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + + i = cpu->instruction; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRBT_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + + i = cpu->instruction; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRBT_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + + i = cpu->instruction; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRBT_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + + i = cpu->instruction; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRBT_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + + i = cpu->instruction; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRBT_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + + i = cpu->instruction; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRBT_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + + i = cpu->instruction; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_LDRBT_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + + i = cpu->instruction; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = MMU_readByte(cpu->proc_ID, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +//----------------------STRBT---------------------------- + +static u32 FASTCALL OP_STRBT_P_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_M_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_P_REG_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + cpu->R[REG_POS(i,0)]; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_M_REG_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - cpu->R[REG_POS(i,0)]; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_P_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_M_LSL_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_M_LSR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_P_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_M_ASR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_P_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +static u32 FASTCALL OP_STRBT_M_ROR_IMM_OFF_POSTIND(armcpu_t *cpu) +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + MMU_writeByte(cpu->proc_ID, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF]; +} + +//---------------------LDM----------------------------- + +#define OP_L_IA(reg, adr) if(BIT##reg(i))\ + {\ + registres[reg] = MMU_readWord(cpu->proc_ID, start);\ + c += waitState[(start>>24)&0xF];\ + adr += 4;\ + } + +#define OP_L_IB(reg, adr) if(BIT##reg(i))\ + {\ + adr += 4;\ + registres[reg] = MMU_readWord(cpu->proc_ID, start);\ + c += waitState[(start>>24)&0xF];\ + } + +#define OP_L_DA(reg, adr) if(BIT##reg(i))\ + {\ + registres[reg] = MMU_readWord(cpu->proc_ID, start);\ + c += waitState[(start>>24)&0xF];\ + adr -= 4;\ + } + +#define OP_L_DB(reg, adr) if(BIT##reg(i))\ + {\ + adr -= 4;\ + registres[reg] = MMU_readWord(cpu->proc_ID, start);\ + c += waitState[(start>>24)&0xF];\ + } + +static u32 FASTCALL OP_LDMIA(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + + u32 * registres = cpu->R; + u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + OP_L_IA(0, start); + OP_L_IA(1, start); + OP_L_IA(2, start); + OP_L_IA(3, start); + OP_L_IA(4, start); + OP_L_IA(5, start); + OP_L_IA(6, start); + OP_L_IA(7, start); + OP_L_IA(8, start); + OP_L_IA(9, start); + OP_L_IA(10, start); + OP_L_IA(11, start); + OP_L_IA(12, start); + OP_L_IA(13, start); + OP_L_IA(14, start); + + if(BIT15(i)) + { + u32 tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + //start += 4; + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + } + + return c + 2; +} + +static u32 FASTCALL OP_LDMIB(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + + u32 * registres = cpu->R; + u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + OP_L_IB(0, start); + OP_L_IB(1, start); + OP_L_IB(2, start); + OP_L_IB(3, start); + OP_L_IB(4, start); + OP_L_IB(5, start); + OP_L_IB(6, start); + OP_L_IB(7, start); + OP_L_IB(8, start); + OP_L_IB(9, start); + OP_L_IB(10, start); + OP_L_IB(11, start); + OP_L_IB(12, start); + OP_L_IB(13, start); + OP_L_IB(14, start); + + if(BIT15(i)) + { + u32 tmp; + start += 4; + c += waitState[(start>>24)&0xF]; + tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + cpu->next_instruction = registres[15]; + c += 2 + (c==0); + } + + return c + 2; +} + +static u32 FASTCALL OP_LDMDA(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + + u32 * registres = cpu->R; + u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + if(BIT15(i)) + { + u32 tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + c += waitState[(start>>24)&0xF]; + start -= 4; + cpu->next_instruction = registres[15]; + } + + OP_L_DA(14, start); + OP_L_DA(13, start); + OP_L_DA(12, start); + OP_L_DA(11, start); + OP_L_DA(10, start); + OP_L_DA(9, start); + OP_L_DA(8, start); + OP_L_DA(7, start); + OP_L_DA(6, start); + OP_L_DA(5, start); + OP_L_DA(4, start); + OP_L_DA(3, start); + OP_L_DA(2, start); + OP_L_DA(1, start); + OP_L_DA(0, start); + + return c + 2; +} + +static u32 FASTCALL OP_LDMDB(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + + u32 * registres = cpu->R; + u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + if(BIT15(i)) + { + u32 tmp; + start -= 4; + tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + } + + OP_L_DB(14, start); + OP_L_DB(13, start); + OP_L_DB(12, start); + OP_L_DB(11, start); + OP_L_DB(10, start); + OP_L_DB(9, start); + OP_L_DB(8, start); + OP_L_DB(7, start); + OP_L_DB(6, start); + OP_L_DB(5, start); + OP_L_DB(4, start); + OP_L_DB(3, start); + OP_L_DB(2, start); + OP_L_DB(1, start); + OP_L_DB(0, start); + + return c + 2; +} + +static u32 FASTCALL OP_LDMIA_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, count; + u32 start = cpu->R[REG_POS(i,16)]; + u32 bitList = i&0xFFFF; + + u32 * registres = cpu->R; + u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + for (count = 1; count < 65536; count <<= 1) + { + if (count&bitList) + cpu->R[REG_POS(i,16)] += 4; + } + + OP_L_IA(0, start); + OP_L_IA(1, start); + OP_L_IA(2, start); + OP_L_IA(3, start); + OP_L_IA(4, start); + OP_L_IA(5, start); + OP_L_IA(6, start); + OP_L_IA(7, start); + OP_L_IA(8, start); + OP_L_IA(9, start); + OP_L_IA(10, start); + OP_L_IA(11, start); + OP_L_IA(12, start); + OP_L_IA(13, start); + OP_L_IA(14, start); + + if(BIT15(i)) + { + u32 tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + c += waitState[(start>>24)&0xF]; + start += 4; + cpu->next_instruction = registres[15]; + } + + /* + if (!BIT24(i)) + { + cpu->R[REG_POS(i,16)] = start; + } + */ + + return c + 2; +} + +static u32 FASTCALL OP_LDMIB_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, count; + u32 start = cpu->R[REG_POS(i,16)]; + u32 bitList = i&0xFFFF; + + u32 * registres = cpu->R; + u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + for (count = 1; count < 65536; count <<= 1) + { + if (count&bitList) + cpu->R[REG_POS(i,16)] += 4; + } + + OP_L_IB(0, start); + OP_L_IB(1, start); + OP_L_IB(2, start); + OP_L_IB(3, start); + OP_L_IB(4, start); + OP_L_IB(5, start); + OP_L_IB(6, start); + OP_L_IB(7, start); + OP_L_IB(8, start); + OP_L_IB(9, start); + OP_L_IB(10, start); + OP_L_IB(11, start); + OP_L_IB(12, start); + OP_L_IB(13, start); + OP_L_IB(14, start); + + if(BIT15(i)) + { + u32 tmp; + start += 4; + c += waitState[(start>>24)&0xF]; + tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + cpu->next_instruction = registres[15]; + c += 2 + (c==0); + } + + /* + if (!BIT24(i)) + { + cpu->R[REG_POS(i,16)] = start; + } + */ + + return c + 2; +} + +static u32 FASTCALL OP_LDMDA_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, count; + u32 start = cpu->R[REG_POS(i,16)]; + + u32 * registres = cpu->R; + u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + u32 bitList = i&0xFFFF; + for (count = 1; count < 65536; count <<= 1) + { + if (count&bitList) + cpu->R[REG_POS(i,16)] -= 4; + } + + if(BIT15(i)) + { + u32 tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + c += waitState[(start>>24)&0xF]; + start -= 4; + cpu->next_instruction = registres[15]; + } + + OP_L_DA(14, start); + OP_L_DA(13, start); + OP_L_DA(12, start); + OP_L_DA(11, start); + OP_L_DA(10, start); + OP_L_DA(9, start); + OP_L_DA(8, start); + OP_L_DA(7, start); + OP_L_DA(6, start); + OP_L_DA(5, start); + OP_L_DA(4, start); + OP_L_DA(3, start); + OP_L_DA(2, start); + OP_L_DA(1, start); + OP_L_DA(0, start); + + //cpu->R[REG_POS(i,16)] = start; + return c + 2; +} + +static u32 FASTCALL OP_LDMDB_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, count; + u32 start = cpu->R[REG_POS(i,16)]; + + u32 * registres = cpu->R; + u32 * waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + u32 bitList = i&0xFFFF; + for (count = 1; count < 65536; count <<= 1) + { + if (count&bitList) + cpu->R[REG_POS(i,16)] -= 4; + } + + if(BIT15(i)) + { + u32 tmp; + start -= 4; + tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + } + + OP_L_DB(14, start); + OP_L_DB(13, start); + OP_L_DB(12, start); + OP_L_DB(11, start); + OP_L_DB(10, start); + OP_L_DB(9, start); + OP_L_DB(8, start); + OP_L_DB(7, start); + OP_L_DB(6, start); + OP_L_DB(5, start); + OP_L_DB(4, start); + OP_L_DB(3, start); + OP_L_DB(2, start); + OP_L_DB(1, start); + OP_L_DB(0, start); + +// cpu->R[REG_POS(i,16)] = start; + return c + 2; +} + +static u32 FASTCALL OP_LDMIA2(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 oldmode; + + u32 c = 0; + + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + u32 * waitState; + + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 1; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + OP_L_IA(0, start); + OP_L_IA(1, start); + OP_L_IA(2, start); + OP_L_IA(3, start); + OP_L_IA(4, start); + OP_L_IA(5, start); + OP_L_IA(6, start); + OP_L_IA(7, start); + OP_L_IA(8, start); + OP_L_IA(9, start); + OP_L_IA(10, start); + OP_L_IA(11, start); + OP_L_IA(12, start); + OP_L_IA(13, start); + OP_L_IA(14, start); + + if(BIT15(i)) + { + u32 tmp = MMU_readWord(cpu->proc_ID, start); + Status_Reg SPSR; + cpu->R[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + //start += 4; + cpu->next_instruction = cpu->R[15]; + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + } + else + { + armcpu_switchMode(cpu, oldmode); + } + return c + 2; +} + +static u32 FASTCALL OP_LDMIB2(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 oldmode; + u32 c = 0; + + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + u32 * waitState; + execute = FALSE; + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + OP_L_IB(0, start); + OP_L_IB(1, start); + OP_L_IB(2, start); + OP_L_IB(3, start); + OP_L_IB(4, start); + OP_L_IB(5, start); + OP_L_IB(6, start); + OP_L_IB(7, start); + OP_L_IB(8, start); + OP_L_IB(9, start); + OP_L_IB(10, start); + OP_L_IB(11, start); + OP_L_IB(12, start); + OP_L_IB(13, start); + OP_L_IB(14, start); + + if(BIT15(i)) + { + u32 tmp; + Status_Reg SPSR; + start += 4; + tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + } + else + { + armcpu_switchMode(cpu, oldmode); + } + return c + 2; +} + +static u32 FASTCALL OP_LDMDA2(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + + u32 oldmode; + u32 c = 0; + u32 * registres; + u32 * waitState; + + u32 start = cpu->R[REG_POS(i,16)]; + execute = FALSE; + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + if(BIT15(i)) + { + u32 tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR = cpu->SPSR; + c += waitState[(start>>24)&0xF]; + start -= 4; + cpu->next_instruction = registres[15]; + } + + OP_L_DA(14, start); + OP_L_DA(13, start); + OP_L_DA(12, start); + OP_L_DA(11, start); + OP_L_DA(10, start); + OP_L_DA(9, start); + OP_L_DA(8, start); + OP_L_DA(7, start); + OP_L_DA(6, start); + OP_L_DA(5, start); + OP_L_DA(4, start); + OP_L_DA(3, start); + OP_L_DA(2, start); + OP_L_DA(1, start); + OP_L_DA(0, start); + + if(BIT15(i)==0) + { + armcpu_switchMode(cpu, oldmode); + } + else + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + } + + return c + 2; +} + +static u32 FASTCALL OP_LDMDB2(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + + u32 oldmode; + u32 c = 0; + u32 * registres; + u32 * waitState; + + u32 start = cpu->R[REG_POS(i,16)]; + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + if(BIT15(i)) + { + u32 tmp; + start -= 4; + tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR = cpu->SPSR; + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + } + + OP_L_DB(14, start); + OP_L_DB(13, start); + OP_L_DB(12, start); + OP_L_DB(11, start); + OP_L_DB(10, start); + OP_L_DB(9, start); + OP_L_DB(8, start); + OP_L_DB(7, start); + OP_L_DB(6, start); + OP_L_DB(5, start); + OP_L_DB(4, start); + OP_L_DB(3, start); + OP_L_DB(2, start); + OP_L_DB(1, start); + OP_L_DB(0, start); + + if(BIT15(i)==0) + { + armcpu_switchMode(cpu, oldmode); + } + else + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + } + + return 2 + c; +} + +static u32 FASTCALL OP_LDMIA2_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 c = 0; + + u32 oldmode; + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + u32 * waitState; + u32 tmp; + Status_Reg SPSR; +// execute = FALSE; + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + OP_L_IA(0, start); + OP_L_IA(1, start); + OP_L_IA(2, start); + OP_L_IA(3, start); + OP_L_IA(4, start); + OP_L_IA(5, start); + OP_L_IA(6, start); + OP_L_IA(7, start); + OP_L_IA(8, start); + OP_L_IA(9, start); + OP_L_IA(10, start); + OP_L_IA(11, start); + OP_L_IA(12, start); + OP_L_IA(13, start); + OP_L_IA(14, start); + + if(BIT15(i)==0) + { + registres[REG_POS(i,16)] = start; + armcpu_switchMode(cpu, oldmode); + return c + 2; + } + + registres[REG_POS(i,16)] = start + 4; + tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + + return c + 2; +} + +static u32 FASTCALL OP_LDMIB2_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 c = 0; + + u32 oldmode; + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + u32 * waitState; + u32 tmp; + Status_Reg SPSR; + + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + OP_L_IB(0, start); + OP_L_IB(1, start); + OP_L_IB(2, start); + OP_L_IB(3, start); + OP_L_IB(4, start); + OP_L_IB(5, start); + OP_L_IB(6, start); + OP_L_IB(7, start); + OP_L_IB(8, start); + OP_L_IB(9, start); + OP_L_IB(10, start); + OP_L_IB(11, start); + OP_L_IB(12, start); + OP_L_IB(13, start); + OP_L_IB(14, start); + + if(BIT15(i)==0) + { + armcpu_switchMode(cpu, oldmode); + registres[REG_POS(i,16)] = start; + + return c + 2; + } + + registres[REG_POS(i,16)] = start + 4; + tmp = MMU_readWord(cpu->proc_ID, start + 4); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR = cpu->SPSR; + cpu->next_instruction = registres[15]; + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + c += waitState[(start>>24)&0xF]; + + return c + 2; +} + +static u32 FASTCALL OP_LDMDA2_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 c = 0; + + u32 oldmode; + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + u32 * waitState; + Status_Reg SPSR; +// execute = FALSE; + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + if(BIT15(i)) + { + u32 tmp = MMU_readWord(cpu->proc_ID, start); + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + c += waitState[(start>>24)&0xF]; + start -= 4; + cpu->next_instruction = registres[15]; + } + + OP_L_DA(14, start); + OP_L_DA(13, start); + OP_L_DA(12, start); + OP_L_DA(11, start); + OP_L_DA(10, start); + OP_L_DA(9, start); + OP_L_DA(8, start); + OP_L_DA(7, start); + OP_L_DA(6, start); + OP_L_DA(5, start); + OP_L_DA(4, start); + OP_L_DA(3, start); + OP_L_DA(2, start); + OP_L_DA(1, start); + OP_L_DA(0, start); + + registres[REG_POS(i,16)] = start; + + if(BIT15(i)==0) + { + armcpu_switchMode(cpu, oldmode); + return c + 2; + } + + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + return c + 2; +} + +static u32 FASTCALL OP_LDMDB2_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 c = 0; + + u32 oldmode; + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + u32 * waitState; + Status_Reg SPSR; +// execute = FALSE; + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[cpu->proc_ID]; + + if(BIT15(i)) + { + u32 tmp; + start -= 4; + tmp = MMU_readWord(cpu->proc_ID, start); + c += waitState[(start>>24)&0xF]; + registres[15] = tmp & (0X0FFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR = cpu->SPSR; + cpu->next_instruction = registres[15]; + } + + OP_L_DB(14, start); + OP_L_DB(13, start); + OP_L_DB(12, start); + OP_L_DB(11, start); + OP_L_DB(10, start); + OP_L_DB(9, start); + OP_L_DB(8, start); + OP_L_DB(7, start); + OP_L_DB(6, start); + OP_L_DB(5, start); + OP_L_DB(4, start); + OP_L_DB(3, start); + OP_L_DB(2, start); + OP_L_DB(1, start); + OP_L_DB(0, start); + + registres[REG_POS(i,16)] = start; + + if(BIT15(i)==0) + { + armcpu_switchMode(cpu, oldmode); + return c + 2; + } + + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + return c + 2; +} + +//------------------------------STM---------------------------------- + +static u32 FASTCALL OP_STMIA(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + MMU_writeWord(cpu->proc_ID, start, cpu->R[b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + start += 4; + } + } + return c + 1; +} + +static u32 FASTCALL OP_STMIB(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + start += 4; + MMU_writeWord(cpu->proc_ID, start, cpu->R[b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + } + } + return c + 1; +} + +static u32 FASTCALL OP_STMDA(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + MMU_writeWord(cpu->proc_ID, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + start -= 4; + } + } + return c + 1; +} + +static u32 FASTCALL OP_STMDB(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + start -= 4; + MMU_writeWord(cpu->proc_ID, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + } + } + return c + 1; +} + +static u32 FASTCALL OP_STMIA_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + MMU_writeWord(cpu->proc_ID, start, cpu->R[b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + start += 4; + } + } + + cpu->R[REG_POS(i,16)] = start; + return c + 1; +} + +static u32 FASTCALL OP_STMIB_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + start += 4; + MMU_writeWord(cpu->proc_ID, start, cpu->R[b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + } + } + cpu->R[REG_POS(i,16)] = start; + return c + 1; +} + +static u32 FASTCALL OP_STMDA_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + MMU_writeWord(cpu->proc_ID, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + start -= 4; + } + } + + cpu->R[REG_POS(i,16)] = start; + return c + 1; +} + +static u32 FASTCALL OP_STMDB_W(armcpu_t *cpu) +{ + u32 i = cpu->instruction, c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + start -= 4; + MMU_writeWord(cpu->proc_ID, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + } + } + + cpu->R[REG_POS(i,16)] = start; + return c + 1; +} + +static u32 FASTCALL OP_STMIA2(armcpu_t *cpu) +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + i = cpu->instruction; + c = 0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + execute = FALSE; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + MMU_writeWord(cpu->proc_ID, start, cpu->R[b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + start += 4; + } + } + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +static u32 FASTCALL OP_STMIB2(armcpu_t *cpu) +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + i = cpu->instruction; + c = 0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + execute = FALSE; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + start += 4; + MMU_writeWord(cpu->proc_ID, start, cpu->R[b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + } + } + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +static u32 FASTCALL OP_STMDA2(armcpu_t *cpu) +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + i = cpu->instruction; + c = 0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + execute = FALSE; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + MMU_writeWord(cpu->proc_ID, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + start -= 4; + } + } + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +static u32 FASTCALL OP_STMDB2(armcpu_t *cpu) +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + i = cpu->instruction; + c=0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + start -= 4; + MMU_writeWord(cpu->proc_ID, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + } + } + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +static u32 FASTCALL OP_STMIA2_W(armcpu_t *cpu) +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + i = cpu->instruction; + c=0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + execute = FALSE; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + MMU_writeWord(cpu->proc_ID, start, cpu->R[b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + start += 4; + } + } + + cpu->R[REG_POS(i,16)] = start; + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +static u32 FASTCALL OP_STMIB2_W(armcpu_t *cpu) +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + i = cpu->instruction; + c=0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + start += 4; + MMU_writeWord(cpu->proc_ID, start, cpu->R[b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + } + } + armcpu_switchMode(cpu, oldmode); + cpu->R[REG_POS(i,16)] = start; + + return c + 1; +} + +static u32 FASTCALL OP_STMDA2_W(armcpu_t *cpu) +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + i = cpu->instruction; + c = 0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + execute = FALSE; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + MMU_writeWord(cpu->proc_ID, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + start -= 4; + } + } + + cpu->R[REG_POS(i,16)] = start; + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +static u32 FASTCALL OP_STMDB2_W(armcpu_t *cpu) +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + i = cpu->instruction; + c = 0; + + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + execute = FALSE; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + start -= 4; + MMU_writeWord(cpu->proc_ID, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[cpu->proc_ID][(start>>24)&0xF]; + } + } + + cpu->R[REG_POS(i,16)] = start; + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +//---------------------STC---------------------------------- + +static u32 FASTCALL OP_STC_P_IMM_OFF(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_STC_M_IMM_OFF(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_STC_P_PREIND(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_STC_M_PREIND(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_STC_P_POSTIND(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_STC_M_POSTIND(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_STC_OPTION(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +//---------------------LDC---------------------------------- + +static u32 FASTCALL OP_LDC_P_IMM_OFF(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_LDC_M_IMM_OFF(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_LDC_P_PREIND(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_LDC_M_PREIND(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_LDC_P_POSTIND(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_LDC_M_POSTIND(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +static u32 FASTCALL OP_LDC_OPTION(armcpu_t *cpu) +{ + { + execute = FALSE; + return 2; + } +} + +//----------------MCR----------------------- + +static u32 FASTCALL OP_MCR(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 cpnum = REG_POS(i, 8); + + if(!cpu->coproc[cpnum]) + { + execute = FALSE; + return 2; + } + + armcp15_moveARM2CP((armcp15_t*)cpu->coproc[cpnum], cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); + //cpu->coproc[cpnum]->moveARM2CP(cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); + return 2; +} + +//----------------MRC----------------------- + +static u32 FASTCALL OP_MRC(armcpu_t *cpu) +{ + u32 i = cpu->instruction; + u32 cpnum = REG_POS(i, 8); + + if(!cpu->coproc[cpnum]) + { + execute = FALSE; + return 2; + } + + armcp15_moveCP2ARM((armcp15_t*)cpu->coproc[cpnum], &cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); + //cpu->coproc[cpnum]->moveCP2ARM(&cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); + return 4; +} + +//--------------SWI------------------------------- +static u32 FASTCALL OP_SWI(armcpu_t *cpu) +{ + if (((cpu->intVector != 0) ^ (cpu->proc_ID == ARMCPU_ARM9))) + { + /* TODO (#1#): translocated SWI vectors */ + /* 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 4; + } + else + { + u32 swinum = (cpu->instruction>>16)&0x1F; + return cpu->swi_tab[swinum](cpu) + 3; + } +} + +//----------------BKPT------------------------- +static u32 FASTCALL OP_BKPT(armcpu_t *cpu) +{ + execute = FALSE; + return 4; +} + +//----------------CDP----------------------- + +static u32 FASTCALL OP_CDP(armcpu_t *cpu) +{ + execute = FALSE; + return 4; +} + +#define TYPE_RETOUR u32 +#define PARAMETRES armcpu_t *cpu +#define CALLTYPE FASTCALL +#define NOM_TAB arm_instructions_set + +#include "instruction_tabdef.inc" diff --git a/tags/release_0_5_0/desmume/src/arm_instructions.h b/tags/release_0_5_0/desmume/src/arm_instructions.h new file mode 100644 index 000000000..cc56e40c6 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/arm_instructions.h @@ -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 + diff --git a/tags/release_0_5_0/desmume/src/armcpu.c b/tags/release_0_5_0/desmume/src/armcpu.c new file mode 100644 index 000000000..764b6ca7b --- /dev/null +++ b/tags/release_0_5_0/desmume/src/armcpu.c @@ -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 +#include + +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; +} + diff --git a/tags/release_0_5_0/desmume/src/armcpu.h b/tags/release_0_5_0/desmume/src/armcpu.h new file mode 100644 index 000000000..a1556cb7d --- /dev/null +++ b/tags/release_0_5_0/desmume/src/armcpu.h @@ -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< +#include "MMU.h" +#include "debug.h" + +extern BOOL execute; + +static u16 getsinetbl[] = { +0x0000, 0x0324, 0x0648, 0x096A, 0x0C8C, 0x0FAB, 0x12C8, 0x15E2, +0x18F9, 0x1C0B, 0x1F1A, 0x2223, 0x2528, 0x2826, 0x2B1F, 0x2E11, +0x30FB, 0x33DF, 0x36BA, 0x398C, 0x3C56, 0x3F17, 0x41CE, 0x447A, +0x471C, 0x49B4, 0x4C3F, 0x4EBF, 0x5133, 0x539B, 0x55F5, 0x5842, +0x5A82, 0x5CB3, 0x5ED7, 0x60EB, 0x62F1, 0x64E8, 0x66CF, 0x68A6, +0x6A6D, 0x6C23, 0x6DC9, 0x6F5E, 0x70E2, 0x7254, 0x73B5, 0x7504, +0x7641, 0x776B, 0x7884, 0x7989, 0x7A7C, 0x7B5C, 0x7C29, 0x7CE3, +0x7D89, 0x7E1D, 0x7E9C, 0x7F09, 0x7F61, 0x7FA6, 0x7FD8, 0x7FF5 +}; + +static u16 getpitchtbl[] = { +0x0000, 0x003B, 0x0076, 0x00B2, 0x00ED, 0x0128, 0x0164, 0x019F, +0x01DB, 0x0217, 0x0252, 0x028E, 0x02CA, 0x0305, 0x0341, 0x037D, +0x03B9, 0x03F5, 0x0431, 0x046E, 0x04AA, 0x04E6, 0x0522, 0x055F, +0x059B, 0x05D8, 0x0614, 0x0651, 0x068D, 0x06CA, 0x0707, 0x0743, +0x0780, 0x07BD, 0x07FA, 0x0837, 0x0874, 0x08B1, 0x08EF, 0x092C, +0x0969, 0x09A7, 0x09E4, 0x0A21, 0x0A5F, 0x0A9C, 0x0ADA, 0x0B18, +0x0B56, 0x0B93, 0x0BD1, 0x0C0F, 0x0C4D, 0x0C8B, 0x0CC9, 0x0D07, +0x0D45, 0x0D84, 0x0DC2, 0x0E00, 0x0E3F, 0x0E7D, 0x0EBC, 0x0EFA, +0x0F39, 0x0F78, 0x0FB6, 0x0FF5, 0x1034, 0x1073, 0x10B2, 0x10F1, +0x1130, 0x116F, 0x11AE, 0x11EE, 0x122D, 0x126C, 0x12AC, 0x12EB, +0x132B, 0x136B, 0x13AA, 0x13EA, 0x142A, 0x146A, 0x14A9, 0x14E9, +0x1529, 0x1569, 0x15AA, 0x15EA, 0x162A, 0x166A, 0x16AB, 0x16EB, +0x172C, 0x176C, 0x17AD, 0x17ED, 0x182E, 0x186F, 0x18B0, 0x18F0, +0x1931, 0x1972, 0x19B3, 0x19F5, 0x1A36, 0x1A77, 0x1AB8, 0x1AFA, +0x1B3B, 0x1B7D, 0x1BBE, 0x1C00, 0x1C41, 0x1C83, 0x1CC5, 0x1D07, +0x1D48, 0x1D8A, 0x1DCC, 0x1E0E, 0x1E51, 0x1E93, 0x1ED5, 0x1F17, +0x1F5A, 0x1F9C, 0x1FDF, 0x2021, 0x2064, 0x20A6, 0x20E9, 0x212C, +0x216F, 0x21B2, 0x21F5, 0x2238, 0x227B, 0x22BE, 0x2301, 0x2344, +0x2388, 0x23CB, 0x240E, 0x2452, 0x2496, 0x24D9, 0x251D, 0x2561, +0x25A4, 0x25E8, 0x262C, 0x2670, 0x26B4, 0x26F8, 0x273D, 0x2781, +0x27C5, 0x280A, 0x284E, 0x2892, 0x28D7, 0x291C, 0x2960, 0x29A5, +0x29EA, 0x2A2F, 0x2A74, 0x2AB9, 0x2AFE, 0x2B43, 0x2B88, 0x2BCD, +0x2C13, 0x2C58, 0x2C9D, 0x2CE3, 0x2D28, 0x2D6E, 0x2DB4, 0x2DF9, +0x2E3F, 0x2E85, 0x2ECB, 0x2F11, 0x2F57, 0x2F9D, 0x2FE3, 0x302A, +0x3070, 0x30B6, 0x30FD, 0x3143, 0x318A, 0x31D0, 0x3217, 0x325E, +0x32A5, 0x32EC, 0x3332, 0x3379, 0x33C1, 0x3408, 0x344F, 0x3496, +0x34DD, 0x3525, 0x356C, 0x35B4, 0x35FB, 0x3643, 0x368B, 0x36D3, +0x371A, 0x3762, 0x37AA, 0x37F2, 0x383A, 0x3883, 0x38CB, 0x3913, +0x395C, 0x39A4, 0x39ED, 0x3A35, 0x3A7E, 0x3AC6, 0x3B0F, 0x3B58, +0x3BA1, 0x3BEA, 0x3C33, 0x3C7C, 0x3CC5, 0x3D0E, 0x3D58, 0x3DA1, +0x3DEA, 0x3E34, 0x3E7D, 0x3EC7, 0x3F11, 0x3F5A, 0x3FA4, 0x3FEE, +0x4038, 0x4082, 0x40CC, 0x4116, 0x4161, 0x41AB, 0x41F5, 0x4240, +0x428A, 0x42D5, 0x431F, 0x436A, 0x43B5, 0x4400, 0x444B, 0x4495, +0x44E1, 0x452C, 0x4577, 0x45C2, 0x460D, 0x4659, 0x46A4, 0x46F0, +0x473B, 0x4787, 0x47D3, 0x481E, 0x486A, 0x48B6, 0x4902, 0x494E, +0x499A, 0x49E6, 0x4A33, 0x4A7F, 0x4ACB, 0x4B18, 0x4B64, 0x4BB1, +0x4BFE, 0x4C4A, 0x4C97, 0x4CE4, 0x4D31, 0x4D7E, 0x4DCB, 0x4E18, +0x4E66, 0x4EB3, 0x4F00, 0x4F4E, 0x4F9B, 0x4FE9, 0x5036, 0x5084, +0x50D2, 0x5120, 0x516E, 0x51BC, 0x520A, 0x5258, 0x52A6, 0x52F4, +0x5343, 0x5391, 0x53E0, 0x542E, 0x547D, 0x54CC, 0x551A, 0x5569, +0x55B8, 0x5607, 0x5656, 0x56A5, 0x56F4, 0x5744, 0x5793, 0x57E2, +0x5832, 0x5882, 0x58D1, 0x5921, 0x5971, 0x59C1, 0x5A10, 0x5A60, +0x5AB0, 0x5B01, 0x5B51, 0x5BA1, 0x5BF1, 0x5C42, 0x5C92, 0x5CE3, +0x5D34, 0x5D84, 0x5DD5, 0x5E26, 0x5E77, 0x5EC8, 0x5F19, 0x5F6A, +0x5FBB, 0x600D, 0x605E, 0x60B0, 0x6101, 0x6153, 0x61A4, 0x61F6, +0x6248, 0x629A, 0x62EC, 0x633E, 0x6390, 0x63E2, 0x6434, 0x6487, +0x64D9, 0x652C, 0x657E, 0x65D1, 0x6624, 0x6676, 0x66C9, 0x671C, +0x676F, 0x67C2, 0x6815, 0x6869, 0x68BC, 0x690F, 0x6963, 0x69B6, +0x6A0A, 0x6A5E, 0x6AB1, 0x6B05, 0x6B59, 0x6BAD, 0x6C01, 0x6C55, +0x6CAA, 0x6CFE, 0x6D52, 0x6DA7, 0x6DFB, 0x6E50, 0x6EA4, 0x6EF9, +0x6F4E, 0x6FA3, 0x6FF8, 0x704D, 0x70A2, 0x70F7, 0x714D, 0x71A2, +0x71F7, 0x724D, 0x72A2, 0x72F8, 0x734E, 0x73A4, 0x73FA, 0x7450, +0x74A6, 0x74FC, 0x7552, 0x75A8, 0x75FF, 0x7655, 0x76AC, 0x7702, +0x7759, 0x77B0, 0x7807, 0x785E, 0x78B4, 0x790C, 0x7963, 0x79BA, +0x7A11, 0x7A69, 0x7AC0, 0x7B18, 0x7B6F, 0x7BC7, 0x7C1F, 0x7C77, +0x7CCF, 0x7D27, 0x7D7F, 0x7DD7, 0x7E2F, 0x7E88, 0x7EE0, 0x7F38, +0x7F91, 0x7FEA, 0x8042, 0x809B, 0x80F4, 0x814D, 0x81A6, 0x81FF, +0x8259, 0x82B2, 0x830B, 0x8365, 0x83BE, 0x8418, 0x8472, 0x84CB, +0x8525, 0x857F, 0x85D9, 0x8633, 0x868E, 0x86E8, 0x8742, 0x879D, +0x87F7, 0x8852, 0x88AC, 0x8907, 0x8962, 0x89BD, 0x8A18, 0x8A73, +0x8ACE, 0x8B2A, 0x8B85, 0x8BE0, 0x8C3C, 0x8C97, 0x8CF3, 0x8D4F, +0x8DAB, 0x8E07, 0x8E63, 0x8EBF, 0x8F1B, 0x8F77, 0x8FD4, 0x9030, +0x908C, 0x90E9, 0x9146, 0x91A2, 0x91FF, 0x925C, 0x92B9, 0x9316, +0x9373, 0x93D1, 0x942E, 0x948C, 0x94E9, 0x9547, 0x95A4, 0x9602, +0x9660, 0x96BE, 0x971C, 0x977A, 0x97D8, 0x9836, 0x9895, 0x98F3, +0x9952, 0x99B0, 0x9A0F, 0x9A6E, 0x9ACD, 0x9B2C, 0x9B8B, 0x9BEA, +0x9C49, 0x9CA8, 0x9D08, 0x9D67, 0x9DC7, 0x9E26, 0x9E86, 0x9EE6, +0x9F46, 0x9FA6, 0xA006, 0xA066, 0xA0C6, 0xA127, 0xA187, 0xA1E8, +0xA248, 0xA2A9, 0xA30A, 0xA36B, 0xA3CC, 0xA42D, 0xA48E, 0xA4EF, +0xA550, 0xA5B2, 0xA613, 0xA675, 0xA6D6, 0xA738, 0xA79A, 0xA7FC, +0xA85E, 0xA8C0, 0xA922, 0xA984, 0xA9E7, 0xAA49, 0xAAAC, 0xAB0E, +0xAB71, 0xABD4, 0xAC37, 0xAC9A, 0xACFD, 0xAD60, 0xADC3, 0xAE27, +0xAE8A, 0xAEED, 0xAF51, 0xAFB5, 0xB019, 0xB07C, 0xB0E0, 0xB145, +0xB1A9, 0xB20D, 0xB271, 0xB2D6, 0xB33A, 0xB39F, 0xB403, 0xB468, +0xB4CD, 0xB532, 0xB597, 0xB5FC, 0xB662, 0xB6C7, 0xB72C, 0xB792, +0xB7F7, 0xB85D, 0xB8C3, 0xB929, 0xB98F, 0xB9F5, 0xBA5B, 0xBAC1, +0xBB28, 0xBB8E, 0xBBF5, 0xBC5B, 0xBCC2, 0xBD29, 0xBD90, 0xBDF7, +0xBE5E, 0xBEC5, 0xBF2C, 0xBF94, 0xBFFB, 0xC063, 0xC0CA, 0xC132, +0xC19A, 0xC202, 0xC26A, 0xC2D2, 0xC33A, 0xC3A2, 0xC40B, 0xC473, +0xC4DC, 0xC544, 0xC5AD, 0xC616, 0xC67F, 0xC6E8, 0xC751, 0xC7BB, +0xC824, 0xC88D, 0xC8F7, 0xC960, 0xC9CA, 0xCA34, 0xCA9E, 0xCB08, +0xCB72, 0xCBDC, 0xCC47, 0xCCB1, 0xCD1B, 0xCD86, 0xCDF1, 0xCE5B, +0xCEC6, 0xCF31, 0xCF9C, 0xD008, 0xD073, 0xD0DE, 0xD14A, 0xD1B5, +0xD221, 0xD28D, 0xD2F8, 0xD364, 0xD3D0, 0xD43D, 0xD4A9, 0xD515, +0xD582, 0xD5EE, 0xD65B, 0xD6C7, 0xD734, 0xD7A1, 0xD80E, 0xD87B, +0xD8E9, 0xD956, 0xD9C3, 0xDA31, 0xDA9E, 0xDB0C, 0xDB7A, 0xDBE8, +0xDC56, 0xDCC4, 0xDD32, 0xDDA0, 0xDE0F, 0xDE7D, 0xDEEC, 0xDF5B, +0xDFC9, 0xE038, 0xE0A7, 0xE116, 0xE186, 0xE1F5, 0xE264, 0xE2D4, +0xE343, 0xE3B3, 0xE423, 0xE493, 0xE503, 0xE573, 0xE5E3, 0xE654, +0xE6C4, 0xE735, 0xE7A5, 0xE816, 0xE887, 0xE8F8, 0xE969, 0xE9DA, +0xEA4B, 0xEABC, 0xEB2E, 0xEB9F, 0xEC11, 0xEC83, 0xECF5, 0xED66, +0xEDD9, 0xEE4B, 0xEEBD, 0xEF2F, 0xEFA2, 0xF014, 0xF087, 0xF0FA, +0xF16D, 0xF1E0, 0xF253, 0xF2C6, 0xF339, 0xF3AD, 0xF420, 0xF494, +0xF507, 0xF57B, 0xF5EF, 0xF663, 0xF6D7, 0xF74C, 0xF7C0, 0xF834, +0xF8A9, 0xF91E, 0xF992, 0xFA07, 0xFA7C, 0xFAF1, 0xFB66, 0xFBDC, +0xFC51, 0xFCC7, 0xFD3C, 0xFDB2, 0xFE28, 0xFE9E, 0xFF14, 0xFF8A +}; + +static u8 getvoltbl[] = { +0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, +0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, +0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, +0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, +0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, +0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, +0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, +0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, +0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, +0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, +0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, +0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x14, +0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x18, +0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, +0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, +0x22, 0x23, 0x23, 0x24, 0x24, 0x24, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x27, 0x28, 0x28, 0x29, +0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x31, 0x31, +0x32, 0x32, 0x33, 0x33, 0x34, 0x35, 0x35, 0x36, 0x36, 0x37, 0x38, 0x38, 0x39, 0x3A, 0x3A, 0x3B, +0x3C, 0x3C, 0x3D, 0x3E, 0x3F, 0x3F, 0x40, 0x41, 0x42, 0x42, 0x43, 0x44, 0x45, 0x45, 0x46, 0x47, +0x48, 0x49, 0x4A, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x52, 0x53, 0x54, 0x55, +0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x67, +0x68, 0x69, 0x6A, 0x6B, 0x6D, 0x6E, 0x6F, 0x71, 0x72, 0x73, 0x75, 0x76, 0x77, 0x79, 0x7A, 0x7B, +0x7D, 0x7E, 0x7F, 0x20, 0x21, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25, +0x26, 0x26, 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, +0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x30, 0x31, 0x31, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x36, +0x36, 0x37, 0x37, 0x38, 0x39, 0x39, 0x3A, 0x3B, 0x3B, 0x3C, 0x3D, 0x3E, 0x3E, 0x3F, 0x40, 0x40, +0x41, 0x42, 0x43, 0x43, 0x44, 0x45, 0x46, 0x47, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4D, +0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, +0x5E, 0x5F, 0x60, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6F, 0x70, +0x71, 0x73, 0x74, 0x75, 0x77, 0x78, 0x79, 0x7B, 0x7C, 0x7E, 0x7E, 0x40, 0x41, 0x42, 0x43, 0x43, +0x44, 0x45, 0x46, 0x47, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, +0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, +0x62, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6B, 0x6C, 0x6D, 0x6E, 0x70, 0x71, 0x72, 0x74, 0x75, +0x76, 0x78, 0x79, 0x7B, 0x7C, 0x7D, 0x7E, 0x40, 0x41, 0x42, 0x42, 0x43, 0x44, 0x45, 0x46, 0x46, +0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, +0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x65, 0x66, +0x67, 0x68, 0x69, 0x6A, 0x6C, 0x6D, 0x6E, 0x6F, 0x71, 0x72, 0x73, 0x75, 0x76, 0x77, 0x79, 0x7A, +0x7C, 0x7D, 0x7E, 0x7F +}; + +u32 bios_nop(armcpu_t * cpu) +{ + if (cpu->proc_ID == ARMCPU_ARM9) + { + LOG("Unimplemented bios function %02X(ARM9) was used. R0:%08X\n", (cpu->instruction)&0x1F, cpu->R[0]); + } + else + { + LOG("Unimplemented bios function %02X(ARM7) was used. R0:%08X\n", (cpu->instruction)&0x1F, cpu->R[0]); + } + return 3; +} + +u32 delayLoop(armcpu_t * cpu) +{ + return cpu->R[0] * 4; +} + +//u32 oldmode[2]; + +u32 intrWaitARM(armcpu_t * cpu) +{ + u32 intrFlagAdr;// = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; + u32 intr; + u32 intrFlag = 0; + + //execute = FALSE; + if(cpu->proc_ID) + { + intrFlagAdr = 0x380FFF8; + } else { + intrFlagAdr = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; + } + intr = MMU_readWord(cpu->proc_ID, intrFlagAdr); + intrFlag = cpu->R[1] & intr; + + if(intrFlag) + { + // si une(ou plusieurs) des interruptions que l'on attend s'est(se sont) produite(s) + // on efface son(les) occurence(s). + intr ^= intrFlag; + MMU_writeWord(cpu->proc_ID, intrFlagAdr, intr); + //cpu->switchMode(oldmode[cpu->proc_ID]); + return 1; + } + + cpu->R[15] = cpu->instruct_adr; + cpu->next_instruction = cpu->R[15]; + cpu->waitIRQ = 1; + //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); + + return 1; +} + +u32 waitVBlankARM(armcpu_t * cpu) +{ + u32 intrFlagAdr;// = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; + u32 intr; + u32 intrFlag = 0; + + //execute = FALSE; + if(cpu->proc_ID) + { + intrFlagAdr = 0x380FFF8; + } else { + intrFlagAdr = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; + } + intr = MMU_readWord(cpu->proc_ID, intrFlagAdr); + intrFlag = 1 & intr; + + if(intrFlag) + { + // si une(ou plusieurs) des interruptions que l'on attend s'est(se sont) produite(s) + // on efface son(les) occurence(s). + intr ^= intrFlag; + MMU_writeWord(cpu->proc_ID, intrFlagAdr, intr); + //cpu->switchMode(oldmode[cpu->proc_ID]); + return 1; + } + + cpu->R[15] = cpu->instruct_adr; + cpu->next_instruction = cpu->R[15]; + cpu->waitIRQ = 1; + //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); + + return 1; +} + +u32 wait4IRQ(armcpu_t* cpu) +{ + //execute= FALSE; + 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]; + //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); + return 1; +} + +u32 devide(armcpu_t* cpu) +{ + s32 num = (s32)cpu->R[0]; + s32 dnum = (s32)cpu->R[1]; + + if(dnum==0) return 0; + + cpu->R[0] = (u32)(num / dnum); + cpu->R[1] = (u32)(num % dnum); + cpu->R[3] = (u32) (((s32)cpu->R[0])<0 ? -cpu->R[0] : cpu->R[0]); + + return 6; +} + +u32 copy(armcpu_t* cpu) +{ + u32 src = cpu->R[0]; + u32 dst = cpu->R[1]; + u32 cnt = cpu->R[2]; + + switch(BIT26(cnt)) + { + case 0: + src &= 0xFFFFFFFE; + dst &= 0xFFFFFFFE; + switch(BIT24(cnt)) + { + case 0: + cnt &= 0x1FFFFF; + while(cnt) + { + MMU_writeHWord(cpu->proc_ID, dst, MMU_readHWord(cpu->proc_ID, src)); + cnt--; + dst+=2; + src+=2; + } + break; + case 1: + { + u32 val = MMU_readHWord(cpu->proc_ID, src); + cnt &= 0x1FFFFF; + while(cnt) + { + MMU_writeHWord(cpu->proc_ID, dst, val); + cnt--; + dst+=2; + } + } + break; + } + break; + case 1: + src &= 0xFFFFFFFC; + dst &= 0xFFFFFFFC; + switch(BIT24(cnt)) + { + case 0: + cnt &= 0x1FFFFF; + while(cnt) + { + MMU_writeWord(cpu->proc_ID, dst, MMU_readWord(cpu->proc_ID, src)); + cnt--; + dst+=4; + src+=4; + } + break; + case 1: + { + u32 val = MMU_readWord(cpu->proc_ID, src); + cnt &= 0x1FFFFF; + while(cnt) + { + MMU_writeWord(cpu->proc_ID, dst, val); + cnt--; + dst+=4; + } + } + break; + } + break; + } + return 1; +} + +u32 fastCopy(armcpu_t* cpu) +{ + u32 src = cpu->R[0] & 0xFFFFFFFC; + u32 dst = cpu->R[1] & 0xFFFFFFFC; + u32 cnt = cpu->R[2]; + + switch(BIT24(cnt)) + { + case 0: + cnt &= 0x1FFFFF; + while(cnt) + { + MMU_writeWord(cpu->proc_ID, dst, MMU_readWord(cpu->proc_ID, src)); + cnt--; + dst+=4; + src+=4; + } + break; + case 1: + { + u32 val = MMU_readWord(cpu->proc_ID, src); + cnt &= 0x1FFFFF; + while(cnt) + { + MMU_writeWord(cpu->proc_ID, dst, val); + cnt--; + dst+=4; + } + } + break; + } + return 1; +} + +u32 LZ77UnCompVram(armcpu_t* cpu) +{ + int i1, i2; + int byteCount; + int byteShift; + u32 writeValue; + int len; + u32 source = cpu->R[0]; + u32 dest = cpu->R[1]; + u32 header = MMU_readWord(cpu->proc_ID, source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + byteCount = 0; + byteShift = 0; + writeValue = 0; + + len = header >> 8; + + while(len > 0) { + u8 d = MMU_readByte(cpu->proc_ID, source++); + + if(d) { + for(i1 = 0; i1 < 8; i1++) { + if(d & 0x80) { + int length; + int offset; + u32 windowOffset; + u16 data = MMU_readByte(cpu->proc_ID, source++) << 8; + data |= MMU_readByte(cpu->proc_ID, source++); + length = (data >> 12) + 3; + offset = (data & 0x0FFF); + windowOffset = dest + byteCount - offset - 1; + for(i2 = 0; i2 < length; i2++) { + writeValue |= (MMU_readByte(cpu->proc_ID, windowOffset++) << byteShift); + byteShift += 8; + byteCount++; + + if(byteCount == 2) { + MMU_writeHWord(cpu->proc_ID, dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return 0; + } + } else { + writeValue |= (MMU_readByte(cpu->proc_ID, source++) << byteShift); + byteShift += 8; + byteCount++; + if(byteCount == 2) { + MMU_writeHWord(cpu->proc_ID, dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return 0; + } + d <<= 1; + } + } else { + for(i1 = 0; i1 < 8; i1++) { + writeValue |= (MMU_readByte(cpu->proc_ID, source++) << byteShift); + byteShift += 8; + byteCount++; + if(byteCount == 2) { + MMU_writeHWord(cpu->proc_ID, dest, writeValue); + dest += 2; + byteShift = 0; + byteCount = 0; + writeValue = 0; + } + len--; + if(len == 0) + return 0; + } + } + } + return 1; +} + +u32 LZ77UnCompWram(armcpu_t* cpu) +{ + int i1, i2; + int len; + u32 source = cpu->R[0]; + u32 dest = cpu->R[1]; + + u32 header = MMU_readWord(cpu->proc_ID, source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + len = header >> 8; + + while(len > 0) { + u8 d = MMU_readByte(cpu->proc_ID, source++); + + if(d) { + for(i1 = 0; i1 < 8; i1++) { + if(d & 0x80) { + int length; + int offset; + u32 windowOffset; + u16 data = MMU_readByte(cpu->proc_ID, source++) << 8; + data |= MMU_readByte(cpu->proc_ID, source++); + length = (data >> 12) + 3; + offset = (data & 0x0FFF); + windowOffset = dest - offset - 1; + for(i2 = 0; i2 < length; i2++) { + MMU_writeByte(cpu->proc_ID, dest++, MMU_readByte(cpu->proc_ID, windowOffset++)); + len--; + if(len == 0) + return 0; + } + } else { + MMU_writeByte(cpu->proc_ID, dest++, MMU_readByte(cpu->proc_ID, source++)); + len--; + if(len == 0) + return 0; + } + d <<= 1; + } + } else { + for(i1 = 0; i1 < 8; i1++) { + MMU_writeByte(cpu->proc_ID, dest++, MMU_readByte(cpu->proc_ID, source++)); + len--; + if(len == 0) + return 0; + } + } + } + return 1; +} + +u32 RLUnCompVram(armcpu_t* cpu) +{ + int i; + int len; + int byteCount; + int byteShift; + u32 writeValue; + u32 source = cpu->R[0]; + u32 dest = cpu->R[1]; + + u32 header = MMU_readWord(cpu->proc_ID, source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + len = header >> 8; + byteCount = 0; + byteShift = 0; + writeValue = 0; + + while(len > 0) { + u8 d = MMU_readByte(cpu->proc_ID, source++); + int l = d & 0x7F; + if(d & 0x80) { + u8 data = MMU_readByte(cpu->proc_ID, source++); + l += 3; + for(i = 0;i < l; i++) { + writeValue |= (data << byteShift); + byteShift += 8; + byteCount++; + + if(byteCount == 2) { + MMU_writeHWord(cpu->proc_ID, dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return 0; + } + } else { + l++; + for(i = 0; i < l; i++) { + writeValue |= (MMU_readByte(cpu->proc_ID, source++) << byteShift); + byteShift += 8; + byteCount++; + if(byteCount == 2) { + MMU_writeHWord(cpu->proc_ID, dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return 0; + } + } + } + return 1; +} + +u32 RLUnCompWram(armcpu_t* cpu) +{ + int i; + int len; + u32 source = cpu->R[0]; + u32 dest = cpu->R[1]; + + u32 header = MMU_readWord(cpu->proc_ID, source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + len = header >> 8; + + while(len > 0) { + u8 d = MMU_readByte(cpu->proc_ID, source++); + int l = d & 0x7F; + if(d & 0x80) { + u8 data = MMU_readByte(cpu->proc_ID, source++); + l += 3; + for(i = 0;i < l; i++) { + MMU_writeByte(cpu->proc_ID, dest++, data); + len--; + if(len == 0) + return 0; + } + } else { + l++; + for(i = 0; i < l; i++) { + MMU_writeByte(cpu->proc_ID, dest++, MMU_readByte(cpu->proc_ID, source++)); + len--; + if(len == 0) + return 0; + } + } + } + return 1; +} + +u32 UnCompHuffman(armcpu_t* cpu) +{ + u32 source, dest, writeValue, header, treeStart, mask; + u32 data; + u8 treeSize, currentNode, rootNode; + int byteCount, byteShift, len, pos; + int writeData; + + source = cpu->R[0]; + dest = cpu->R[1]; + + header = MMU_readByte(cpu->proc_ID, source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + treeSize = MMU_readByte(cpu->proc_ID, source++); + + treeStart = source; + + source += ((treeSize+1)<<1)-1; // minus because we already skipped one byte + + len = header >> 8; + + mask = 0x80000000; + data = MMU_readByte(cpu->proc_ID, source); + source += 4; + + pos = 0; + rootNode = MMU_readByte(cpu->proc_ID, treeStart); + currentNode = rootNode; + writeData = 0; + byteShift = 0; + byteCount = 0; + writeValue = 0; + + if((header & 0x0F) == 8) { + while(len > 0) { + // take left + if(pos == 0) + pos++; + else + pos += (((currentNode & 0x3F)+1)<<1); + + if(data & mask) { + // right + if(currentNode & 0x40) + writeData = 1; + currentNode = MMU_readByte(cpu->proc_ID, treeStart+pos+1); + } else { + // left + if(currentNode & 0x80) + writeData = 1; + currentNode = MMU_readByte(cpu->proc_ID, treeStart+pos); + } + + if(writeData) { + writeValue |= (currentNode << byteShift); + byteCount++; + byteShift += 8; + + pos = 0; + currentNode = rootNode; + writeData = 0; + + if(byteCount == 4) { + byteCount = 0; + byteShift = 0; + MMU_writeByte(cpu->proc_ID, dest, writeValue); + writeValue = 0; + dest += 4; + len -= 4; + } + } + mask >>= 1; + if(mask == 0) { + mask = 0x80000000; + data = MMU_readByte(cpu->proc_ID, source); + source += 4; + } + } + } else { + int halfLen = 0; + int value = 0; + while(len > 0) { + // take left + if(pos == 0) + pos++; + else + pos += (((currentNode & 0x3F)+1)<<1); + + if((data & mask)) { + // right + if(currentNode & 0x40) + writeData = 1; + currentNode = MMU_readByte(cpu->proc_ID, treeStart+pos+1); + } else { + // left + if(currentNode & 0x80) + writeData = 1; + currentNode = MMU_readByte(cpu->proc_ID, treeStart+pos); + } + + if(writeData) { + if(halfLen == 0) + value |= currentNode; + else + value |= (currentNode<<4); + + halfLen += 4; + if(halfLen == 8) { + writeValue |= (value << byteShift); + byteCount++; + byteShift += 8; + + halfLen = 0; + value = 0; + + if(byteCount == 4) { + byteCount = 0; + byteShift = 0; + MMU_writeByte(cpu->proc_ID, dest, writeValue); + dest += 4; + writeValue = 0; + len -= 4; + } + } + pos = 0; + currentNode = rootNode; + writeData = 0; + } + mask >>= 1; + if(mask == 0) { + mask = 0x80000000; + data = MMU_readByte(cpu->proc_ID, source); + source += 4; + } + } + } + return 1; +} + +u32 BitUnPack(armcpu_t* cpu) +{ + u32 source,dest,header,base,d,temp; + int len,bits,revbits,dataSize,data,bitwritecount,mask,bitcount,addBase; + u8 b; + + source = cpu->R[0]; + dest = cpu->R[1]; + header = cpu->R[2]; + + len = MMU_readHWord(cpu->proc_ID, header); + // check address + bits = MMU_readByte(cpu->proc_ID, header+2); + revbits = 8 - bits; + // u32 value = 0; + base = MMU_readByte(cpu->proc_ID, header+4); + addBase = (base & 0x80000000) ? 1 : 0; + base &= 0x7fffffff; + dataSize = MMU_readByte(cpu->proc_ID, header+3); + + data = 0; + bitwritecount = 0; + while(1) { + len -= 1; + if(len < 0) + break; + mask = 0xff >> revbits; + b = MMU_readByte(cpu->proc_ID, source); + source++; + bitcount = 0; + while(1) { + if(bitcount >= 8) + break; + d = b & mask; + temp = d >> bitcount; + if(!temp && addBase) { + temp += base; + } + data |= temp << bitwritecount; + bitwritecount += dataSize; + if(bitwritecount >= 32) { + MMU_writeByte(cpu->proc_ID, dest, data); + dest += 4; + data = 0; + bitwritecount = 0; + } + mask <<= bits; + bitcount += bits; + } + } + return 1; +} + +u32 Diff8bitUnFilterWram(armcpu_t* cpu) +{ + u32 source,dest,header; + u8 data,diff; + int len; + + source = cpu->R[0]; + dest = cpu->R[1]; + + header = MMU_readByte(cpu->proc_ID, source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff) & 0xe000000) == 0)) + return 0; + + len = header >> 8; + + data = MMU_readByte(cpu->proc_ID, source++); + MMU_writeByte(cpu->proc_ID, dest++, data); + len--; + + while(len > 0) { + diff = MMU_readByte(cpu->proc_ID, source++); + data += diff; + MMU_writeByte(cpu->proc_ID, dest++, data); + len--; + } + return 1; +} + +u32 Diff16bitUnFilter(armcpu_t* cpu) +{ + u32 source,dest,header; + u16 data; + int len; + + source = cpu->R[0]; + dest = cpu->R[1]; + + header = MMU_readByte(cpu->proc_ID, source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + len = header >> 8; + + data = MMU_readHWord(cpu->proc_ID, source); + source += 2; + MMU_writeHWord(cpu->proc_ID, dest, data); + dest += 2; + len -= 2; + + while(len >= 2) { + u16 diff = MMU_readHWord(cpu->proc_ID, source); + source += 2; + data += diff; + MMU_writeHWord(cpu->proc_ID, dest, data); + dest += 2; + len -= 2; + } + return 1; +} + +u32 bios_sqrt(armcpu_t* cpu) +{ + cpu->R[0] = (u32)sqrt((double)(cpu->R[0])); + return 1; +} + +u32 setHaltCR(armcpu_t* cpu) +{ + MMU_writeByte(cpu->proc_ID, 0x4000300+cpu->proc_ID, cpu->R[0]); + return 1; +} + +u32 getSineTab(armcpu_t* cpu) +{ + cpu->R[0] = getsinetbl[cpu->R[0]]; + return 1; +} + +u32 getPitchTab(armcpu_t* cpu) +{ + cpu->R[0] = getpitchtbl[cpu->R[0]]; + return 1; +} + +u32 getVolumeTab(armcpu_t* cpu) +{ + cpu->R[0] = getvoltbl[cpu->R[0]]; + return 1; +} + +u32 getCRC16(armcpu_t* cpu) +{ + int i,j; + u32 crc; + + u16 start = cpu->R[0]; + u16 datap = cpu->R[1]; + u32 size = cpu->R[2]; + + static u16 val[] = { 0xC0C1,0xC181,0xC301,0xC601,0xCC01,0xD801,0xF001,0xA001 }; + for(i=datap; i<(datap+size); i++) + { + crc=crc ^ MMU_readHWord(cpu->proc_ID,datap+i); + for(j=0; j<7; j++) crc=crc >> 1; if(crc) crc=crc ^ (val[j] << (7-j)); + } + cpu->R[0] = crc; + return 1; +} + +u32 SoundBias(armcpu_t* cpu) +{ + u32 current = SPU_ReadLong(0x4000504); + if (cpu->R[0] > current) + SPU_WriteLong(0x4000504, current + 0x1); + else + SPU_WriteLong(0x4000504, current - 0x1); + return cpu->R[1]; +} + +u32 (* ARM9_swi_tab[32])(armcpu_t* cpu)={ + bios_nop, // 0x00 + bios_nop, // 0x01 + bios_nop, // 0x02 + delayLoop, // 0x03 + intrWaitARM, // 0x04 + waitVBlankARM, // 0x05 + wait4IRQ, // 0x06 + bios_nop, // 0x07 + bios_nop, // 0x08 + devide, // 0x09 + bios_nop, // 0x0A + copy, // 0x0B + fastCopy, // 0x0C + bios_sqrt, // 0x0D + getCRC16, // 0x0E + bios_nop, // 0x0F + BitUnPack, // 0x10 + LZ77UnCompWram, // 0x11 + LZ77UnCompVram, // 0x12 + UnCompHuffman, // 0x13 + RLUnCompWram, // 0x14 + RLUnCompVram, // 0x15 + Diff8bitUnFilterWram, // 0x16 + bios_nop, // 0x17 + Diff16bitUnFilter, // 0x18 + bios_nop, // 0x19 + bios_nop, // 0x1A + bios_nop, // 0x1B + bios_nop, // 0x1C + bios_nop, // 0x1D + bios_nop, // 0x1E + setHaltCR, // 0x1F +}; + +u32 (* ARM7_swi_tab[32])(armcpu_t* cpu)={ + bios_nop, // 0x00 + bios_nop, // 0x01 + bios_nop, // 0x02 + delayLoop, // 0x03 + intrWaitARM, // 0x04 + waitVBlankARM, // 0x05 + wait4IRQ, // 0x06 + wait4IRQ, // 0x07 + SoundBias, // 0x08 + devide, // 0x09 + bios_nop, // 0x0A + copy, // 0x0B + fastCopy, // 0x0C + bios_sqrt, // 0x0D + getCRC16, // 0x0E + bios_nop, // 0x0F + BitUnPack, // 0x10 + LZ77UnCompWram, // 0x11 + LZ77UnCompVram, // 0x12 + UnCompHuffman, // 0x13 + RLUnCompWram, // 0x14 + RLUnCompVram, // 0x15 + Diff8bitUnFilterWram, // 0x16 + bios_nop, // 0x17 + bios_nop, // 0x18 + bios_nop, // 0x19 + getSineTab, // 0x1A + getPitchTab, // 0x1B + getVolumeTab, // 0x1C + bios_nop, // 0x1D + bios_nop, // 0x1E + setHaltCR, // 0x1F +}; diff --git a/tags/release_0_5_0/desmume/src/bios.h b/tags/release_0_5_0/desmume/src/bios.h new file mode 100644 index 000000000..7f717cb8c --- /dev/null +++ b/tags/release_0_5_0/desmume/src/bios.h @@ -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 + diff --git a/tags/release_0_5_0/desmume/src/bits.h b/tags/release_0_5_0/desmume/src/bits.h new file mode 100644 index 000000000..be64f65d7 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/bits.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/build.bat b/tags/release_0_5_0/desmume/src/build.bat new file mode 100644 index 000000000..8bb85bd14 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/build.bat @@ -0,0 +1,4 @@ +configure +make clean +make +pause \ No newline at end of file diff --git a/tags/release_0_5_0/desmume/src/cflash.c b/tags/release_0_5_0/desmume/src/cflash.c new file mode 100644 index 000000000..75192faed --- /dev/null +++ b/tags/release_0_5_0/desmume/src/cflash.c @@ -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 +#include +#include + + +#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=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; icFileName); 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=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>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 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 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); iname[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= 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 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=(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 +#include +#include + +#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; +} diff --git a/tags/release_0_5_0/desmume/src/config.h b/tags/release_0_5_0/desmume/src/config.h new file mode 100644 index 000000000..4e98d421d --- /dev/null +++ b/tags/release_0_5_0/desmume/src/config.h @@ -0,0 +1,9 @@ +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + +#include + +#include "debug.h" + +#endif /*__CONFIG_H__*/ + diff --git a/tags/release_0_5_0/desmume/src/cp15.c b/tags/release_0_5_0/desmume/src/cp15.c new file mode 100644 index 000000000..75dbe8dfe --- /dev/null +++ b/tags/release_0_5_0/desmume/src/cp15.c @@ -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 + +#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; + } +} + + + diff --git a/tags/release_0_5_0/desmume/src/cp15.h b/tags/release_0_5_0/desmume/src/cp15.h new file mode 100644 index 000000000..6877096dc --- /dev/null +++ b/tags/release_0_5_0/desmume/src/cp15.h @@ -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__*/ diff --git a/tags/release_0_5_0/desmume/src/debug.c b/tags/release_0_5_0/desmume/src/debug.c new file mode 100644 index 000000000..6359802b5 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/debug.c @@ -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 +#include +#include + +////////////////////////////////////////////////////////////////////////////// + +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); +} + +////////////////////////////////////////////////////////////////////////////// + diff --git a/tags/release_0_5_0/desmume/src/debug.h b/tags/release_0_5_0/desmume/src/debug.h new file mode 100644 index 000000000..9f9224615 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/debug.h @@ -0,0 +1,74 @@ +#ifndef DEBUG_H +#define DEBUG_H + +#include "types.h" +#include + +#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 diff --git a/tags/release_0_5_0/desmume/src/dscard.h b/tags/release_0_5_0/desmume/src/dscard.h new file mode 100644 index 000000000..be95604aa --- /dev/null +++ b/tags/release_0_5_0/desmume/src/dscard.h @@ -0,0 +1,15 @@ +#ifndef __DSCARD_H__ +#define __DSCARD_H__ + +typedef struct +{ + + u32 adress; + u32 transfer_count; + +} nds_dscard; + +#endif /*__DSCARD_H__*/ + + + diff --git a/tags/release_0_5_0/desmume/src/fat.h b/tags/release_0_5_0/desmume/src/fat.h new file mode 100644 index 000000000..65696d375 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/fat.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 diff --git a/tags/release_0_5_0/desmume/src/fs-linux.c b/tags/release_0_5_0/desmume/src/fs-linux.c new file mode 100644 index 000000000..494e48fec --- /dev/null +++ b/tags/release_0_5_0/desmume/src/fs-linux.c @@ -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 +#include +#include +#include +#include + +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; +} diff --git a/tags/release_0_5_0/desmume/src/fs-windows.c b/tags/release_0_5_0/desmume/src/fs-windows.c new file mode 100644 index 000000000..5de81a116 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/fs-windows.c @@ -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 +#include +#include +#include + +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; +} diff --git a/tags/release_0_5_0/desmume/src/fs.h b/tags/release_0_5_0/desmume/src/fs.h new file mode 100644 index 000000000..a1f25b8fb --- /dev/null +++ b/tags/release_0_5_0/desmume/src/fs.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/gtk/DeSmuME.xpm b/tags/release_0_5_0/desmume/src/gtk/DeSmuME.xpm new file mode 100644 index 000000000..d1ce27621 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/DeSmuME.xpm @@ -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", +" .................... ", +" .................... ", +".....++..+++++..+++++.. ", +".....++..++.....++..... ", +"..@@@@@..@@@@@..@@@@@.. ", +"..@@.@@..@@........@@.. ", +"..##.##..##.##..##.##.. ", +"..##.##..##.##..##.##.. ", +"..$$.$$..$$.$$..$$.$$.. ", +"..$$.$$..$$.$$..$$.$$.. ", +"..%%.%%..%%.%%..%%.%%.. ", +"..%%.%%..%%.%%..%%.%%.. ", +"..&&&&&..&&&&&..&&&&&.. ", +"....................... ", +".......********.**.**.. ", +" ..==.==.==.==.==.. ", +" ..==.==.==.==.==.. ", +" ..--.--.--.--.--.. ", +" ..--.--.--.--.--.. ", +" ..;;.;;.;;.;;;;;.. ", +" ..................... ", +" ..................... ", +" ..>>>>>>>>.>>>>>.. ", +" ..>>.>>.>>.>>..... ", +" ..,,.,,.,,.,,,,,.. ", +" ..,,.,,.,,.,,..... ", +" ..''.''.''.''.''.. ", +" ..''.''.''.''.''.. ", +" ..''.''.''.''.''.. ", +" ..''.''.''.'''''.. ", +" .................. ", +" .................. "}; diff --git a/tags/release_0_5_0/desmume/src/gtk/Makefile.am b/tags/release_0_5_0/desmume/src/gtk/Makefile.am new file mode 100644 index 000000000..8e06efaa7 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/Makefile.am @@ -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) diff --git a/tags/release_0_5_0/desmume/src/gtk/dTool.h b/tags/release_0_5_0/desmume/src/gtk/dTool.h new file mode 100644 index 000000000..2d8ca4e85 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/dTool.h @@ -0,0 +1,25 @@ +#ifndef __DTOOL_H__ +#define __DTOOL_H__ + +#include +#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__*/ diff --git a/tags/release_0_5_0/desmume/src/gtk/dToolsList.c b/tags/release_0_5_0/desmume/src/gtk/dToolsList.c new file mode 100644 index 000000000..9ea10071a --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/dToolsList.c @@ -0,0 +1,10 @@ +#include "dTool.h" +#include "tools/ioregsView.h" + +dTool_t *dTools_list[] = +{ + &dTool_ioregsView +}; + +int dTools_list_size = 1; + diff --git a/tags/release_0_5_0/desmume/src/gtk/desmume.c b/tags/release_0_5_0/desmume/src/gtk/desmume.c new file mode 100644 index 000000000..4d22fe66a --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/desmume.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include + +#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; +} + diff --git a/tags/release_0_5_0/desmume/src/gtk/desmume.h b/tags/release_0_5_0/desmume/src/gtk/desmume.h new file mode 100644 index 000000000..4725db951 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/desmume.h @@ -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__*/ + diff --git a/tags/release_0_5_0/desmume/src/gtk/dev-cpp/Makefile.win b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/Makefile.win new file mode 100644 index 000000000..035d94731 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/Makefile.win @@ -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) diff --git a/tags/release_0_5_0/desmume/src/gtk/dev-cpp/desmume.dev b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/desmume.dev new file mode 100644 index 000000000..b8c7a478b --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/desmume.dev @@ -0,0 +1,309 @@ +[Project] +FileName=desmume.dev +Name=desmume +UnitCount=26 +Type=0 +Ver=1 +ObjFiles= +Includes= +Libs= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Compiler=-I"\gtk-2.0" -I"\gtk-2.0\include" -I"\atk-1.0" -I"\pango-1.0" -I"\glib-2.0" -I"\glib-2.0\glib" -I"\glib-2.0" -I"\glib-2.0\include" -mno-cygwin -mms-bitfields_@@_ +CppCompiler=-I"\gtk-2.0" -I"\gtk-2.0\include" -I"\atk-1.0" -I"\pango-1.0" -I"\glib-2.0" -I"\glib-2.0\glib" -I"\glib-2.0" -I"\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= + diff --git a/tags/release_0_5_0/desmume/src/gtk/dev-cpp/desmume.layout b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/desmume.layout new file mode 100644 index 000000000..50c9e5cc3 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/desmume.layout @@ -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 diff --git a/tags/release_0_5_0/desmume/src/gtk/dev-cpp/pthread.h b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/pthread.h new file mode 100644 index 000000000..1525b63bb --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/pthread.h @@ -0,0 +1,1368 @@ +/* This is an implementation of the threads API of POSIX 1003.1-2001. + * + * -------------------------------------------------------------------------- + * + * 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( PTHREAD_H ) +#define PTHREAD_H + +/* + * See the README file for an explanation of the pthreads-win32 version + * numbering scheme and how the DLL is named etc. + */ +#define PTW32_VERSION 2,7,0,0 +#define PTW32_VERSION_STRING "2, 7, 0, 0\0" + +/* There are three implementations of cancel cleanup. + * Note that pthread.h is included in both application + * compilation units and also internally for the library. + * The code here and within the library aims to work + * for all reasonable combinations of environments. + * + * The three implementations are: + * + * WIN32 SEH + * C + * C++ + * + * Please note that exiting a push/pop block via + * "return", "exit", "break", or "continue" will + * lead to different behaviour amongst applications + * depending upon whether the library was built + * using SEH, C++, or C. For example, a library built + * with SEH will call the cleanup routine, while both + * C++ and C built versions will not. + */ + +/* + * Define defaults for cleanup code. + * Note: Unless the build explicitly defines one of the following, then + * we default to standard C style cleanup. This style uses setjmp/longjmp + * in the cancelation and thread exit implementations and therefore won't + * do stack unwinding if linked to applications that have it (e.g. + * C++ apps). This is currently consistent with most/all commercial Unix + * POSIX threads implementations. + */ +#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C ) +# define __CLEANUP_C +#endif + +#if defined( __CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined(PTW32_RC_MSC)) +#error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler. +#endif + +/* + * Stop here if we are being included by the resource compiler. + */ +#ifndef RC_INVOKED + +#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 + +#ifdef _UWIN +# define HAVE_STRUCT_TIMESPEC 1 +# define HAVE_SIGNAL_H 1 +# undef HAVE_CONFIG_H +# pragma comment(lib, "pthread") +#endif + +/* + * ------------------------------------------------------------- + * + * + * Module: pthread.h + * + * Purpose: + * Provides an implementation of PThreads based upon the + * standard: + * + * POSIX 1003.1-2001 + * and + * The Single Unix Specification version 3 + * + * (these two are equivalent) + * + * in order to enhance code portability between Windows, + * various commercial Unix implementations, and Linux. + * + * See the ANNOUNCE file for a full list of conforming + * routines and defined constants, and a list of missing + * routines and constants not defined in this implementation. + * + * Authors: + * There have been many contributors to this library. + * The initial implementation was contributed by + * John Bossom, and several others have provided major + * sections or revisions of parts of the implementation. + * Often significant effort has been contributed to + * find and fix important bugs and other problems to + * improve the reliability of the library, which sometimes + * is not reflected in the amount of code which changed as + * result. + * As much as possible, the contributors are acknowledged + * in the ChangeLog file in the source code distribution + * where their changes are noted in detail. + * + * Contributors are listed in the CONTRIBUTORS file. + * + * As usual, all bouquets go to the contributors, and all + * brickbats go to the project maintainer. + * + * Maintainer: + * The code base for this project is coordinated and + * eventually pre-tested, packaged, and made available by + * + * Ross Johnson + * + * QA Testers: + * Ultimately, the library is tested in the real world by + * a host of competent and demanding scientists and + * engineers who report bugs and/or provide solutions + * which are then fixed or incorporated into subsequent + * versions of the library. Each time a bug is fixed, a + * test case is written to prove the fix and ensure + * that later changes to the code don't reintroduce the + * same error. The number of test cases is slowly growing + * and therefore so is the code reliability. + * + * Compliance: + * See the file ANNOUNCE for the list of implemented + * and not-implemented routines and defined options. + * Of course, these are all defined is this file as well. + * + * Web site: + * The source code and other information about this library + * are available from + * + * http://sources.redhat.com/pthreads-win32/ + * + * ------------------------------------------------------------- + */ + +/* Try to avoid including windows.h */ +#if defined(__MINGW32__) && defined(__cplusplus) +#define PTW32_INCLUDE_WINDOWS_H +#endif + +#ifdef PTW32_INCLUDE_WINDOWS_H +#include +#endif + +#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__) +/* + * VC++6.0 or early compiler's header has no DWORD_PTR type. + */ +typedef unsigned long DWORD_PTR; +#endif +/* + * ----------------- + * autoconf switches + * ----------------- + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#ifndef NEED_FTIME +#include +#else /* NEED_FTIME */ +/* use native WIN32 time API */ +#endif /* NEED_FTIME */ + +#if HAVE_SIGNAL_H +#include +#endif /* HAVE_SIGNAL_H */ + +#include +#include + +/* + * Boolean values to make us independent of system includes. + */ +enum { + PTW32_FALSE = 0, + PTW32_TRUE = (! PTW32_FALSE) +}; + +/* + * 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 +#endif +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +/* + * Several systems don't define some error numbers. + */ +#ifndef ENOTSUP +# define ENOTSUP 48 /* This is the value in Solaris. */ +#endif + +#ifndef ETIMEDOUT +# define ETIMEDOUT 10060 /* This is the value in winsock.h. */ +#endif + +#ifndef ENOSYS +# define ENOSYS 140 /* Semi-arbitrary value */ +#endif + +#ifndef EDEADLK +# ifdef EDEADLOCK +# define EDEADLK EDEADLOCK +# else +# define EDEADLK 36 /* This is the value in MSVC. */ +# endif +#endif + +#include "sched.h" + +/* + * To avoid including windows.h we define only those things that we + * actually need from it. + */ +#ifndef PTW32_INCLUDE_WINDOWS_H +#ifndef HANDLE +# define PTW32__HANDLE_DEF +# define HANDLE void * +#endif +#ifndef DWORD +# define PTW32__DWORD_DEF +# define DWORD unsigned long +#endif +#endif + +#ifndef HAVE_STRUCT_TIMESPEC +#define HAVE_STRUCT_TIMESPEC 1 +struct timespec { + long tv_sec; + long tv_nsec; +}; +#endif /* HAVE_STRUCT_TIMESPEC */ + +#ifndef SIG_BLOCK +#define SIG_BLOCK 0 +#endif /* SIG_BLOCK */ + +#ifndef SIG_UNBLOCK +#define SIG_UNBLOCK 1 +#endif /* SIG_UNBLOCK */ + +#ifndef SIG_SETMASK +#define SIG_SETMASK 2 +#endif /* SIG_SETMASK */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* + * ------------------------------------------------------------- + * + * POSIX 1003.1-2001 Options + * ========================= + * + * Options are normally set in , which is not provided + * with pthreads-win32. + * + * For conformance with the Single Unix Specification (version 3), all of the + * options below are defined, and have a value of either -1 (not supported) + * or 200112L (supported). + * + * These options can neither be left undefined nor have a value of 0, because + * either indicates that sysconf(), which is not implemented, may be used at + * runtime to check the status of the option. + * + * _POSIX_THREADS (== 200112L) + * If == 200112L, you can use threads + * + * _POSIX_THREAD_ATTR_STACKSIZE (== 200112L) + * If == 200112L, you can control the size of a thread's + * stack + * pthread_attr_getstacksize + * pthread_attr_setstacksize + * + * _POSIX_THREAD_ATTR_STACKADDR (== -1) + * If == 200112L, you can allocate and control a thread's + * stack. If not supported, the following functions + * will return ENOSYS, indicating they are not + * supported: + * pthread_attr_getstackaddr + * pthread_attr_setstackaddr + * + * _POSIX_THREAD_PRIORITY_SCHEDULING (== -1) + * If == 200112L, you can use realtime scheduling. + * This option indicates that the behaviour of some + * implemented functions conforms to the additional TPS + * requirements in the standard. E.g. rwlocks favour + * writers over readers when threads have equal priority. + * + * _POSIX_THREAD_PRIO_INHERIT (== -1) + * If == 200112L, you can create priority inheritance + * mutexes. + * pthread_mutexattr_getprotocol + + * pthread_mutexattr_setprotocol + + * + * _POSIX_THREAD_PRIO_PROTECT (== -1) + * If == 200112L, you can create priority ceiling mutexes + * Indicates the availability of: + * pthread_mutex_getprioceiling + * pthread_mutex_setprioceiling + * pthread_mutexattr_getprioceiling + * pthread_mutexattr_getprotocol + + * pthread_mutexattr_setprioceiling + * pthread_mutexattr_setprotocol + + * + * _POSIX_THREAD_PROCESS_SHARED (== -1) + * If set, you can create mutexes and condition + * variables that can be shared with another + * process.If set, indicates the availability + * of: + * pthread_mutexattr_getpshared + * pthread_mutexattr_setpshared + * pthread_condattr_getpshared + * pthread_condattr_setpshared + * + * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L) + * If == 200112L you can use the special *_r library + * functions that provide thread-safe behaviour + * + * _POSIX_READER_WRITER_LOCKS (== 200112L) + * If == 200112L, you can use read/write locks + * + * _POSIX_SPIN_LOCKS (== 200112L) + * If == 200112L, you can use spin locks + * + * _POSIX_BARRIERS (== 200112L) + * If == 200112L, you can use barriers + * + * + These functions provide both 'inherit' and/or + * 'protect' protocol, based upon these macro + * settings. + * + * ------------------------------------------------------------- + */ + +/* + * POSIX Options + */ +#undef _POSIX_THREADS +#define _POSIX_THREADS 200112L + +#undef _POSIX_READER_WRITER_LOCKS +#define _POSIX_READER_WRITER_LOCKS 200112L + +#undef _POSIX_SPIN_LOCKS +#define _POSIX_SPIN_LOCKS 200112L + +#undef _POSIX_BARRIERS +#define _POSIX_BARRIERS 200112L + +#undef _POSIX_THREAD_SAFE_FUNCTIONS +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L + +#undef _POSIX_THREAD_ATTR_STACKSIZE +#define _POSIX_THREAD_ATTR_STACKSIZE 200112L + +/* + * The following options are not supported + */ +#undef _POSIX_THREAD_ATTR_STACKADDR +#define _POSIX_THREAD_ATTR_STACKADDR -1 + +#undef _POSIX_THREAD_PRIO_INHERIT +#define _POSIX_THREAD_PRIO_INHERIT -1 + +#undef _POSIX_THREAD_PRIO_PROTECT +#define _POSIX_THREAD_PRIO_PROTECT -1 + +/* TPS is not fully supported. */ +#undef _POSIX_THREAD_PRIORITY_SCHEDULING +#define _POSIX_THREAD_PRIORITY_SCHEDULING -1 + +#undef _POSIX_THREAD_PROCESS_SHARED +#define _POSIX_THREAD_PROCESS_SHARED -1 + + +/* + * POSIX 1003.1-2001 Limits + * =========================== + * + * These limits are normally set in , which is not provided with + * pthreads-win32. + * + * PTHREAD_DESTRUCTOR_ITERATIONS + * Maximum number of attempts to destroy + * a thread's thread-specific data on + * termination (must be at least 4) + * + * PTHREAD_KEYS_MAX + * Maximum number of thread-specific data keys + * available per process (must be at least 128) + * + * PTHREAD_STACK_MIN + * Minimum supported stack size for a thread + * + * PTHREAD_THREADS_MAX + * Maximum number of threads supported per + * process (must be at least 64). + * + * SEM_NSEMS_MAX + * The maximum number of semaphores a process can have. + * (must be at least 256) + * + * SEM_VALUE_MAX + * The maximum value a semaphore can have. + * (must be at least 32767) + * + */ +#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 + +#undef PTHREAD_DESTRUCTOR_ITERATIONS +#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS + +#undef _POSIX_THREAD_KEYS_MAX +#define _POSIX_THREAD_KEYS_MAX 128 + +#undef PTHREAD_KEYS_MAX +#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX + +#undef PTHREAD_STACK_MIN +#define PTHREAD_STACK_MIN 0 + +#undef _POSIX_THREAD_THREADS_MAX +#define _POSIX_THREAD_THREADS_MAX 64 + + /* Arbitrary value */ +#undef PTHREAD_THREADS_MAX +#define PTHREAD_THREADS_MAX 2019 + +#undef _POSIX_SEM_NSEMS_MAX +#define _POSIX_SEM_NSEMS_MAX 256 + + /* Arbitrary value */ +#undef SEM_NSEMS_MAX +#define SEM_NSEMS_MAX 1024 + +#undef _POSIX_SEM_VALUE_MAX +#define _POSIX_SEM_VALUE_MAX 32767 + +#undef SEM_VALUE_MAX +#define SEM_VALUE_MAX INT_MAX + + +#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 + +/* + * The Open Watcom C/C++ compiler uses a non-standard calling convention + * that passes function args in registers unless __cdecl is explicitly specified + * in exposed function prototypes. + * + * We force all calls to cdecl even though this could slow Watcom code down + * slightly. If you know that the Watcom compiler will be used to build both + * the DLL and application, then you can probably define this as a null string. + * Remember that pthread.h (this file) is used for both the DLL and application builds. + */ +#define PTW32_CDECL __cdecl + +#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX +# include +#else +/* + * Generic handle type - intended to extend uniqueness beyond + * that available with a simple pointer. It should scale for either + * IA-32 or IA-64. + */ +typedef struct { + void * p; /* Pointer to actual object */ + unsigned int x; /* Extra information - reuse count etc */ +} ptw32_handle_t; + +typedef ptw32_handle_t pthread_t; +typedef struct pthread_attr_t_ * pthread_attr_t; +typedef struct pthread_once_t_ pthread_once_t; +typedef struct pthread_key_t_ * pthread_key_t; +typedef struct pthread_mutex_t_ * pthread_mutex_t; +typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t; +typedef struct pthread_cond_t_ * pthread_cond_t; +typedef struct pthread_condattr_t_ * pthread_condattr_t; +#endif +typedef struct pthread_rwlock_t_ * pthread_rwlock_t; +typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t; +typedef struct pthread_spinlock_t_ * pthread_spinlock_t; +typedef struct pthread_barrier_t_ * pthread_barrier_t; +typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t; + +/* + * ==================== + * ==================== + * POSIX Threads + * ==================== + * ==================== + */ + +enum { +/* + * pthread_attr_{get,set}detachstate + */ + PTHREAD_CREATE_JOINABLE = 0, /* Default */ + PTHREAD_CREATE_DETACHED = 1, + +/* + * pthread_attr_{get,set}inheritsched + */ + PTHREAD_INHERIT_SCHED = 0, + PTHREAD_EXPLICIT_SCHED = 1, /* Default */ + +/* + * pthread_{get,set}scope + */ + PTHREAD_SCOPE_PROCESS = 0, + PTHREAD_SCOPE_SYSTEM = 1, /* Default */ + +/* + * pthread_setcancelstate paramters + */ + PTHREAD_CANCEL_ENABLE = 0, /* Default */ + PTHREAD_CANCEL_DISABLE = 1, + +/* + * pthread_setcanceltype parameters + */ + PTHREAD_CANCEL_ASYNCHRONOUS = 0, + PTHREAD_CANCEL_DEFERRED = 1, /* Default */ + +/* + * pthread_mutexattr_{get,set}pshared + * pthread_condattr_{get,set}pshared + */ + PTHREAD_PROCESS_PRIVATE = 0, + PTHREAD_PROCESS_SHARED = 1, + +/* + * pthread_barrier_wait + */ + PTHREAD_BARRIER_SERIAL_THREAD = -1 +}; + +/* + * ==================== + * ==================== + * Cancelation + * ==================== + * ==================== + */ +#define PTHREAD_CANCELED ((void *) -1) + + +/* + * ==================== + * ==================== + * Once Key + * ==================== + * ==================== + */ +#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0} + +struct pthread_once_t_ +{ + int done; /* indicates if user function has been executed */ + void * lock; + int reserved1; + int reserved2; +}; + + +/* + * ==================== + * ==================== + * Object initialisers + * ==================== + * ==================== + */ +#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1) +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t) -2) +#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t) -3) + +/* + * Compatibility with LinuxThreads + */ +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER +#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER + +#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) -1) + +#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1) + +#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t) -1) + + +/* + * Mutex types. + */ +enum +{ + /* Compatibility with LinuxThreads */ + PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP, + /* For compatibility with POSIX */ + PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL +}; + + +typedef struct ptw32_cleanup_t ptw32_cleanup_t; + +#if defined(_MSC_VER) +/* Disable MSVC 'anachronism used' warning */ +#pragma warning( disable : 4229 ) +#endif + +typedef void (* PTW32_CDECL ptw32_cleanup_callback_t)(void *); + +#if defined(_MSC_VER) +#pragma warning( default : 4229 ) +#endif + +struct ptw32_cleanup_t +{ + ptw32_cleanup_callback_t routine; + void *arg; + struct ptw32_cleanup_t *prev; +}; + +#ifdef __CLEANUP_SEH + /* + * WIN32 SEH version of cancel cleanup. + */ + +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + ptw32_cleanup_t _cleanup; \ + \ + _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \ + _cleanup.arg = (_arg); \ + __try \ + { \ + +#define pthread_cleanup_pop( _execute ) \ + } \ + __finally \ + { \ + if( _execute || AbnormalTermination()) \ + { \ + (*(_cleanup.routine))( _cleanup.arg ); \ + } \ + } \ + } + +#else /* __CLEANUP_SEH */ + +#ifdef __CLEANUP_C + + /* + * C implementation of PThreads cancel cleanup + */ + +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + ptw32_cleanup_t _cleanup; \ + \ + ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \ + +#define pthread_cleanup_pop( _execute ) \ + (void) ptw32_pop_cleanup( _execute ); \ + } + +#else /* __CLEANUP_C */ + +#ifdef __CLEANUP_CXX + + /* + * C++ version of cancel cleanup. + * - John E. Bossom. + */ + + class PThreadCleanup { + /* + * PThreadCleanup + * + * Purpose + * This class is a C++ helper class that is + * used to implement pthread_cleanup_push/ + * pthread_cleanup_pop. + * The destructor of this class automatically + * pops the pushed cleanup routine regardless + * of how the code exits the scope + * (i.e. such as by an exception) + */ + ptw32_cleanup_callback_t cleanUpRout; + void * obj; + int executeIt; + + public: + PThreadCleanup() : + cleanUpRout( 0 ), + obj( 0 ), + executeIt( 0 ) + /* + * No cleanup performed + */ + { + } + + PThreadCleanup( + ptw32_cleanup_callback_t routine, + void * arg ) : + cleanUpRout( routine ), + obj( arg ), + executeIt( 1 ) + /* + * Registers a cleanup routine for 'arg' + */ + { + } + + ~PThreadCleanup() + { + if ( executeIt && ((void *) cleanUpRout != (void *) 0) ) + { + (void) (*cleanUpRout)( obj ); + } + } + + void execute( int exec ) + { + executeIt = exec; + } + }; + + /* + * C++ implementation of PThreads cancel cleanup; + * This implementation takes advantage of a helper + * class who's destructor automatically calls the + * cleanup routine if we exit our scope weirdly + */ +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \ + (void *) (_arg) ); + +#define pthread_cleanup_pop( _execute ) \ + cleanup.execute( _execute ); \ + } + +#else + +#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. + +#endif /* __CLEANUP_CXX */ + +#endif /* __CLEANUP_C */ + +#endif /* __CLEANUP_SEH */ + +/* + * =============== + * =============== + * Methods + * =============== + * =============== + */ + +/* + * PThread Attribute Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr, + int *detachstate); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr, + void **stackaddr); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr, + size_t * stacksize); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr, + int detachstate); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr, + void *stackaddr); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr, + size_t stacksize); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr, + struct sched_param *param); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, + const struct sched_param *param); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, + int); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (pthread_attr_t *, + int *); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, + int inheritsched); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(pthread_attr_t * attr, + int * inheritsched); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, + int); + +PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *, + int *); + +/* + * PThread Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid, + const pthread_attr_t * attr, + void *(*start) (void *), + void *arg); + +PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid); + +PTW32_DLLPORT int PTW32_CDECL pthread_equal (pthread_t t1, + pthread_t t2); + +PTW32_DLLPORT void PTW32_CDECL pthread_exit (void *value_ptr); + +PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread, + void **value_ptr); + +PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void); + +PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread); + +PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state, + int *oldstate); + +PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type, + int *oldtype); + +PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void); + +PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control, + void (*init_routine) (void)); + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX +PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute); + +PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup, + void (*routine) (void *), + void *arg); +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +/* + * Thread Specific Data Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key, + void (*destructor) (void *)); + +PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key); + +PTW32_DLLPORT int PTW32_CDECL pthread_setspecific (pthread_key_t key, + const void *value); + +PTW32_DLLPORT void * PTW32_CDECL pthread_getspecific (pthread_key_t key); + + +/* + * Mutex Attribute Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t + * attr, + int *pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, + int pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind); + +/* + * Barrier Attribute Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t + * attr, + int *pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, + int pshared); + +/* + * Mutex Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex, + const pthread_mutexattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t *mutex, + const struct timespec *abstime); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); + +PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex); + +/* + * Spinlock Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock); + +/* + * Barrier Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier, + const pthread_barrierattr_t * attr, + unsigned int count); + +PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier); + +PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier); + +/* + * Condition Variable Attribute Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr, + int *pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr, + int pshared); + +/* + * Condition Variable Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond, + const pthread_condattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond); + +PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond, + pthread_mutex_t * mutex); + +PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond, + pthread_mutex_t * mutex, + const struct timespec *abstime); + +PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond); + +PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond); + +/* + * Scheduling + */ +PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam (pthread_t thread, + int policy, + const struct sched_param *param); + +PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread, + int *policy, + struct sched_param *param); + +PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int); + +PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void); + +/* + * Read-Write Lock Functions + */ +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock, + const pthread_rwlockattr_t *attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_tryrdlock(pthread_rwlock_t *); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, + const struct timespec *abstime); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, + const struct timespec *abstime); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, + int *pshared); + +PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, + int pshared); + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 + +/* + * Signal Functions. Should be defined in but MSVC and MinGW32 + * already have signal.h that don't define these. + */ +PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig); + +/* + * Non-portable functions + */ + +/* + * Compatibility with Linux. + */ +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, + int kind); +PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, + int *kind); + +/* + * Possibly supported by other POSIX threads implementations + */ +PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval); +PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); + +/* + * Useful if an application wants to statically link + * the lib rather than load the DLL at run-time. + */ +PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_attach_np(void); +PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_detach_np(void); +PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void); +PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void); + +/* + * Features that are auto-detected at load/run time. + */ +PTW32_DLLPORT int PTW32_CDECL pthread_win32_test_features_np(int); +enum ptw32_features { + PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */ + PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */ +}; + +/* + * Register a system time change with the library. + * Causes the library to perform various functions + * in response to the change. Should be called whenever + * the application's top level window receives a + * WM_TIMECHANGE message. It can be passed directly to + * pthread_create() as a new thread if desired. + */ +PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *); + +#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */ + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX + +/* + * Returns the Win32 HANDLE for the POSIX thread. + */ +PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); + + +/* + * Protected Methods + * + * This function blocks until the given WIN32 handle + * is signaled or pthread_cancel had been called. + * This function allows the caller to hook into the + * PThreads cancel mechanism. It is implemented using + * + * WaitForMultipleObjects + * + * on 'waitHandle' and a manually reset WIN32 Event + * used to implement pthread_cancel. The 'timeout' + * argument to TimedWait is simply passed to + * WaitForMultipleObjects. + */ +PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle); +PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, + DWORD timeout); + +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +/* + * Thread-Safe C Runtime Library Mappings. + */ +#ifndef _UWIN +# if defined(NEED_ERRNO) + PTW32_DLLPORT int * PTW32_CDECL _errno( void ); +# else +# ifndef errno +# if (defined(_MT) || defined(_DLL)) + __declspec(dllimport) extern int * __cdecl _errno(void); +# define errno (*_errno()) +# endif +# endif +# endif +#endif + +/* + * WIN32 C runtime library had been made thread-safe + * without affecting the user interface. Provide + * mappings from the UNIX thread-safe versions to + * the standard C runtime library calls. + * Only provide function mappings for functions that + * actually exist on WIN32. + */ + +#if !defined(__MINGW32__) +#define strtok_r( _s, _sep, _lasts ) \ + ( *(_lasts) = strtok( (_s), (_sep) ) ) +#endif /* !__MINGW32__ */ + +#define asctime_r( _tm, _buf ) \ + ( strcpy( (_buf), asctime( (_tm) ) ), \ + (_buf) ) + +#define ctime_r( _clock, _buf ) \ + ( strcpy( (_buf), ctime( (_clock) ) ), \ + (_buf) ) + +#define gmtime_r( _clock, _result ) \ + ( *(_result) = *gmtime( (_clock) ), \ + (_result) ) + +#define localtime_r( _clock, _result ) \ + ( *(_result) = *localtime( (_clock) ), \ + (_result) ) + +#define rand_r( _seed ) \ + ( _seed == _seed? rand() : rand() ) + + +/* + * Some compiler environments don't define some things. + */ +#if defined(__BORLANDC__) +# define _ftime ftime +# define _timeb timeb +#endif + +#ifdef __cplusplus + +/* + * Internal exceptions + */ +class ptw32_exception {}; +class ptw32_exception_cancel : public ptw32_exception {}; +class ptw32_exception_exit : public ptw32_exception {}; + +#endif + +#if PTW32_LEVEL >= PTW32_LEVEL_MAX + +/* FIXME: This is only required if the library was built using SEH */ +/* + * Get internal SEH tag + */ +PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); + +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +#ifndef PTW32_BUILD + +#ifdef __CLEANUP_SEH + +/* + * Redefine the SEH __except keyword to ensure that applications + * propagate our internal exceptions up to the library's internal handlers. + */ +#define __except( E ) \ + __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \ + ? EXCEPTION_CONTINUE_SEARCH : ( E ) ) + +#endif /* __CLEANUP_SEH */ + +#ifdef __CLEANUP_CXX + +/* + * Redefine the C++ catch keyword to ensure that applications + * propagate our internal exceptions up to the library's internal handlers. + */ +#ifdef _MSC_VER + /* + * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' + * if you want Pthread-Win32 cancelation and pthread_exit to work. + */ + +#ifndef PtW32NoCatchWarn + +#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.") +#pragma message("------------------------------------------------------------------") +#pragma message("When compiling applications with MSVC++ and C++ exception handling:") +#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads") +#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread") +#pragma message(" cancelation and pthread_exit to work. For example:") +#pragma message("") +#pragma message(" #ifdef PtW32CatchAll") +#pragma message(" PtW32CatchAll") +#pragma message(" #else") +#pragma message(" catch(...)") +#pragma message(" #endif") +#pragma message(" {") +#pragma message(" /* Catchall block processing */") +#pragma message(" }") +#pragma message("------------------------------------------------------------------") + +#endif + +#define PtW32CatchAll \ + catch( ptw32_exception & ) { throw; } \ + catch( ... ) + +#else /* _MSC_VER */ + +#define catch( E ) \ + catch( ptw32_exception & ) { throw; } \ + catch( E ) + +#endif /* _MSC_VER */ + +#endif /* __CLEANUP_CXX */ + +#endif /* ! PTW32_BUILD */ + +#ifdef __cplusplus +} /* End of extern "C" */ +#endif /* __cplusplus */ + +#ifdef PTW32__HANDLE_DEF +# undef HANDLE +#endif +#ifdef PTW32__DWORD_DEF +# undef DWORD +#endif + +#undef PTW32_LEVEL +#undef PTW32_LEVEL_MAX + +#endif /* ! RC_INVOKED */ + +#endif /* PTHREAD_H */ diff --git a/tags/release_0_5_0/desmume/src/gtk/dev-cpp/sched.h b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/sched.h new file mode 100644 index 000000000..dfb8e934a --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/sched.h @@ -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 +#endif +#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ + +#if defined(__MINGW32__) || defined(_UWIN) +#if PTW32_LEVEL >= PTW32_LEVEL_MAX +/* For pid_t */ +# include +/* Required by Unix 98 */ +# include +#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 */ + diff --git a/tags/release_0_5_0/desmume/src/gtk/dev-cpp/semaphore.h b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/semaphore.h new file mode 100644 index 000000000..a3330a638 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/dev-cpp/semaphore.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 +#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 */ diff --git a/tags/release_0_5_0/desmume/src/gtk/main.c b/tags/release_0_5_0/desmume/src/gtk/main.c new file mode 100644 index 000000000..750c36a7d --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/main.c @@ -0,0 +1,1272 @@ +#include +#include +#include +#include + +#include +#include + +#include "../MMU.h" +#include "../armcpu.h" +#include "../NDSSystem.h" +#include "../debug.h" +#include "../sndsdl.h" + +#include "desmume.h" + +#include +#include + +#include "DeSmuME.xpm" + +#define EMULOOP_PRIO (G_PRIORITY_HIGH_IDLE + 20) + +/************************ CONFIG FILE *****************************/ + +// extern char FirmwareFile[256]; +// int LoadFirmware(const char *filename); + +static void *Open_Select(GtkWidget* widget, gpointer data); +static void Launch(); +static void Pause(); +static void Printscreen(); +static void Reset(); + +static GtkActionEntry action_entries[] = { + { "open", "gtk-open", "Open", "o", NULL, G_CALLBACK(Open_Select) }, + { "run", "gtk-media-play", "Run", "r", NULL, G_CALLBACK(Launch) }, + { "pause", "gtk-media-pause", "Pause", "p", NULL, G_CALLBACK(Pause) }, + { "quit", "gtk-quit", "Quit", "q", NULL, G_CALLBACK(gtk_main_quit) }, + { "printscreen",NULL, "Printscreen", NULL, NULL, G_CALLBACK(Printscreen) }, + { "reset", "gtk-refresh", "Reset", NULL, NULL, G_CALLBACK(Reset) } +}; + +GtkActionGroup * action_group; + +static gint Keypad_Config[DESMUME_NB_KEYS]; + +const char *Ini_Keypad_Values[DESMUME_NB_KEYS] = +{ + "KEY_A", + "KEY_B", + "KEY_SELECT", + "KEY_START", + "KEY_RIGHT", + "KEY_LEFT", + "KEY_UP", + "KEY_DOWN", + "KEY_R", + "KEY_L", + "KEY_Y", + "KEY_X", + "KEY_DEBUG", +}; + +char * CONFIG_FILE; + +SoundInterface_struct *SNDCoreList[] = { +&SNDDummy, +&SNDFile, +&SNDSDL, +NULL +}; + +int Write_ConfigFile() +{ + int i; + GKeyFile * keyfile; + + keyfile = g_key_file_new(); + + for(i = 0; i < DESMUME_NB_KEYS; i++) + { + g_key_file_set_integer(keyfile, "KEYS", Ini_Keypad_Values[i], Keypad_Config[i]); + } + +// if(FirmwareFile[0]) +// { +// ini_add_section(ini, "FIRMWARE"); +// ini_add_value(ini, "FIRMWARE", "FILE", FirmwareFile); +// } + + g_file_set_contents(CONFIG_FILE, g_key_file_to_data(keyfile, 0, 0), -1, 0); + + g_key_file_free(keyfile); + + return 0; +} + +void Load_DefaultConfig(); +int Read_ConfigFile() +{ + int i, tmp; + GKeyFile * keyfile = g_key_file_new(); + GError * error = NULL; + + Load_DefaultConfig(); + + g_key_file_load_from_file(keyfile, CONFIG_FILE, G_KEY_FILE_NONE, 0); + + const char *c; + + for(i = 0; i < DESMUME_NB_KEYS; i++) + { + tmp = g_key_file_get_integer(keyfile, "KEYS", Ini_Keypad_Values[i], &error); + if (error != NULL) { + g_error_free(error); + error = NULL; + } else { + Keypad_Config[i] = g_key_file_get_integer(keyfile, "KEYS", Ini_Keypad_Values[i], &error); + } + } + + g_key_file_free(keyfile); + + return 0; +} + +const gint Default_Keypad_Config[DESMUME_NB_KEYS] = +{ + 97, // a + 98, // b + 65288, // backspace + 65293, // enter + 65363, // directional arrows + 65361, + 65362, + 65364, + 65454, // numeric . + 65456, // numeric 0 + 121, // y + 120, // x + 112 +}; + +void Load_DefaultConfig() +{ + memcpy(Keypad_Config, Default_Keypad_Config, sizeof(Keypad_Config)); +} + + +/************************ GTK *******************************/ + +uint Frameskip = 0; + +//const gint StaCounter[20] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + +static SDL_Surface *SDL_Screenbuf; +static GdkPixmap *pPixmap; + +static GtkWidget *pWindow; +static GtkWidget *pStatusBar; +static GtkWidget *pToolbar; +static GtkWidget *pDrawingArea; + +static BOOL regMainLoop = FALSE; + +static gint pStatusBar_Ctx; +#define pStatusBar_Change(t) gtk_statusbar_pop(GTK_STATUSBAR(pStatusBar), pStatusBar_Ctx); gtk_statusbar_push(GTK_STATUSBAR(pStatusBar), pStatusBar_Ctx, t); + +gboolean EmuLoop(gpointer data); + +void About(GtkWidget* widget, gpointer data) +{ + GdkPixbuf * pixbuf = gdk_pixbuf_new_from_xpm_data(DeSmuME_xpm); + + gtk_show_about_dialog(GTK_WINDOW(pWindow), + "name", "DeSmuME", + "version", VERSION, + "website", "http://desmume.sf.net", + "logo", pixbuf, + "comments", "Nintendo DS emulator based on work by Yopyop", + NULL); + + g_object_unref(pixbuf); +} + +static int Open(const char *filename) +{ + int i = NDS_LoadROM(filename, MC_TYPE_AUTODETECT, 1); + return i; +} + +static void Launch() +{ + desmume_resume(); + + if(!regMainLoop) + { + g_idle_add_full(EMULOOP_PRIO, &EmuLoop, pWindow, NULL); regMainLoop = TRUE; + } + + pStatusBar_Change("Running ..."); + + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "pause"), TRUE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), FALSE); +} + +static void Pause() +{ + desmume_pause(); + pStatusBar_Change("Paused"); + + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "pause"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); +} + +/* Choose a file then load it */ +static void *Open_Select(GtkWidget* widget, gpointer data) +{ + Pause(); + + GtkFileFilter *pFilter_nds, *pFilter_dsgba, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sChemin; + + pParent = GTK_WIDGET(data); + + pFilter_nds = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_nds, "*.nds"); + gtk_file_filter_set_name(pFilter_nds, "Nds binary (.nds)"); + + pFilter_dsgba = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_dsgba, "*.ds.gba"); + gtk_file_filter_set_name(pFilter_dsgba, "Nds binary with loader (.ds.gba)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + /* Creating the selection window */ + pFileSelection = gtk_file_chooser_dialog_new("Open...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, + NULL); + /* On limite les actions a cette fenetre */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsgba); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + /* Affichage fenetre */ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) + { + case GTK_RESPONSE_OK: + /* Recuperation du chemin */ + sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + if(Open((const char*)sChemin) < 0) + { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + "Unable to load :\n%s", sChemin); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } + + //Launch(NULL, pWindow); + + g_free(sChemin); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); + + // FIXME: should be set sensitive only if a file was really loaded + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "reset"), TRUE); +} + +static void Close() +{ +} + +static void Reset() +{ + NDS_Reset(); + desmume_resume(); + + pStatusBar_Change("Running ..."); +} + +int ScreenCoeff_Size; + +/////////////////////////////// DRAWING SCREEN ////////////////////////////////// + +/* Drawing callback */ +int gtkFloatExposeEvent (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + SDL_PixelFormat screenPixFormat; + SDL_Surface *rawImage, *screenImage; + + rawImage = SDL_CreateRGBSurfaceFrom((void*)&GPU_screen, 256, 192*2, 16, 512, 0x001F, 0x03E0, 0x7C00, 0); + if(rawImage == NULL) return 1; + + memcpy(&screenPixFormat, rawImage->format, sizeof(SDL_PixelFormat)); + + screenPixFormat.BitsPerPixel = 24; + screenPixFormat.BytesPerPixel = 3; + screenPixFormat.Rshift = 0; + screenPixFormat.Gshift = 8; + screenPixFormat.Bshift = 16; + screenPixFormat.Rmask = 0x0000FF; + screenPixFormat.Gmask = 0x00FF00; + screenPixFormat.Bmask = 0xFF0000; + + screenImage = SDL_ConvertSurface(rawImage, &screenPixFormat, 0); + + gdk_draw_rgb_image (widget->window, + widget->style->fg_gc[widget->state],0,0,screenImage->w, screenImage->h, + GDK_RGB_DITHER_NONE,(guchar*)screenImage->pixels,screenImage->pitch); + SDL_FreeSurface(screenImage); + SDL_FreeSurface(rawImage); + + return 1; +} + +static void Draw() +{ +} + +/////////////////////////////// KEYS AND STYLUS UPDATE /////////////////////////////////////// + +static gboolean Stylus_Move(GtkWidget *w, GdkEventMotion *e, gpointer data) +{ + GdkModifierType state; + gint x,y; + s32 EmuX, EmuY; + + + if(click) + { + if(e->is_hint) + gdk_window_get_pointer(w->window, &x, &y, &state); + else + { + x= (gint)e->x; + y= (gint)e->y; + state=(GdkModifierType)e->state; + } + + // fprintf(stderr,"X=%d, Y=%d, S&1=%d\n", x,y,state&GDK_BUTTON1_MASK); + + if(y >= 192 && (state & GDK_BUTTON1_MASK)) + { + EmuX = x; + EmuY = y - 192; + if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255; + if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192; + NDS_setTouchPos(EmuX, EmuY); + } + } + + return TRUE; +} +static gboolean Stylus_Press(GtkWidget *w, GdkEventButton *e, gpointer data) +{ + GdkModifierType state; + gint x,y; + s32 EmuX, EmuY; + + if(desmume_running()) + { + if(e->button == 1) + { + click = TRUE; + + gdk_window_get_pointer(w->window, &x, &y, &state); + if(y >= 192 && (state & GDK_BUTTON1_MASK)) + { + EmuX = x; + EmuY = y - 192; + if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255; + if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192; + NDS_setTouchPos(EmuX, EmuY); + } + } + } + + return TRUE; +} +static gboolean Stylus_Release(GtkWidget *w, GdkEventButton *e, gpointer data) +{ + if(click) NDS_releasTouch(); + click = FALSE; + return TRUE; +} + +static u16 Cur_Keypad = 0; + +static gint Key_Press(GtkWidget *w, GdkEventKey *e) +{ + int i; + u16 Key = 0; + + for(i = 0; i < DESMUME_NB_KEYS; i++) + if(e->keyval == Keypad_Config[i]) break; + + if(i < DESMUME_NB_KEYS) + { + Key = DESMUME_KEYMASK_(i); + Cur_Keypad |= Key; + if(desmume_running()) desmume_keypad(Cur_Keypad); + } + + //fprintf(stderr,"P:%d(%d)->%X => [%X]\n", e->keyval, e->hardware_keycode, Key, Cur_Keypad); + return 1; +} +static gint Key_Release(GtkWidget *w, GdkEventKey *e) +{ + int i; + u16 Key = 0; + + for(i = 0; i < DESMUME_NB_KEYS; i++) + if(e->keyval == Keypad_Config[i]) break; + + if(i < DESMUME_NB_KEYS) + { + Key = DESMUME_KEYMASK_(i); + Cur_Keypad &= ~Key; + if(desmume_running()) desmume_keypad(Cur_Keypad); + } + + //fprintf(stderr,"R:%d(%d)->%X => [%X]\n", e->keyval, e->hardware_keycode, Key, Cur_Keypad); + return 1; +} + +/////////////////////////////// CONTROLS EDIT ////////////////////////////////////// + +const char *Keys_Name[DESMUME_NB_KEYS] = +{ + "A", + "B", + "Select", + "Start", + "Right", + "Left", + "Up", + "Down", + "R", + "L", + "Y", + "X", + "Debug" +}; + +GtkWidget *mkLabel; +gint Modify_Key_Chosen = 0; + +void Modify_Key_Press(GtkWidget *w, GdkEventKey *e) +{ + char YouPressed[128]; + Modify_Key_Chosen = e->keyval; + sprintf(YouPressed, "You pressed : %d\nClick OK to keep this key.", e->keyval); + gtk_label_set(GTK_LABEL(mkLabel), YouPressed); +} + +gint Keypad_Temp[DESMUME_NB_KEYS]; + +void Modify_Key(GtkWidget* widget, gpointer data) +{ + gint Key = GPOINTER_TO_INT(data); + char Title[64]; + char Key_Label[64]; + + GtkWidget *mkDialog; + + sprintf(Title, "Press \"%s\" key ...\n", Keys_Name[Key]); + mkDialog = gtk_dialog_new_with_buttons(Title, + GTK_WINDOW(pWindow), + GTK_DIALOG_MODAL, + GTK_STOCK_OK,GTK_RESPONSE_OK, + GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, + NULL); + + g_signal_connect(G_OBJECT(mkDialog), "key_press_event", G_CALLBACK(Modify_Key_Press), NULL); + + mkLabel = gtk_label_new(Title); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mkDialog)->vbox), mkLabel,TRUE, FALSE, 0); + + gtk_widget_show_all(GTK_DIALOG(mkDialog)->vbox); + + switch(gtk_dialog_run(GTK_DIALOG(mkDialog))) + { + case GTK_RESPONSE_OK: + + Keypad_Temp[Key] = Modify_Key_Chosen; + sprintf(Key_Label, "%s (%d)", Keys_Name[Key], Keypad_Temp[Key]); + gtk_button_set_label(GTK_BUTTON(widget), Key_Label); + + break; + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_NONE: + Modify_Key_Chosen = 0; + break; + } + + gtk_widget_destroy(mkDialog); + +} + +void Edit_Controls(GtkWidget* widget, gpointer data) +{ + char Key_Label[64]; + int i; + GtkWidget *ecDialog; + GtkWidget *ecKey; + + memcpy(&Keypad_Temp, &Keypad_Config, sizeof(Keypad_Config)); + + ecDialog = gtk_dialog_new_with_buttons("Edit controls", + GTK_WINDOW(pWindow), + GTK_DIALOG_MODAL, + GTK_STOCK_OK,GTK_RESPONSE_OK, + GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, + NULL); + + + for(i = 0; i < DESMUME_NB_KEYS; i++) + { + sprintf(Key_Label, "%s (%d)", Keys_Name[i], Keypad_Temp[i]); + ecKey = gtk_button_new_with_label(Key_Label); + g_signal_connect(G_OBJECT(ecKey), "clicked", G_CALLBACK(Modify_Key), GINT_TO_POINTER(i)); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(ecDialog)->vbox), ecKey,TRUE, FALSE, 0); + } + + gtk_widget_show_all(GTK_DIALOG(ecDialog)->vbox); + + switch (gtk_dialog_run(GTK_DIALOG(ecDialog))) + { + case GTK_RESPONSE_OK: + memcpy(&Keypad_Config, &Keypad_Temp, sizeof(Keypad_Config)); + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_NONE: + break; + } + gtk_widget_destroy(ecDialog); + +} + +///////////////////////////////// SCREEN SCALING ////////////////////////////// + +#define MAX_SCREENCOEFF 4 + +void Modify_ScreenCoeff(GtkWidget* widget, gpointer data) +{ + int Size = GPOINTER_TO_INT(data); + + gtk_drawing_area_size(GTK_DRAWING_AREA(pDrawingArea), 256 * Size, 384 * Size); + gtk_widget_set_usize (pDrawingArea, 256 * Size, 384 * Size); + + ScreenCoeff_Size = Size; + +} + +/////////////////////////////// LAYER HIDING ///////////////////////////////// + +void Modify_Layer(GtkWidget* widget, gpointer data) +{ + int i; + gchar *Layer = (gchar*)data; + + if(!desmume_running()) + { + return; + } + + if(memcmp(Layer, "Sub", 3) == 0) + { + if(memcmp(Layer, "Sub BG", 6) == 0) + { + i = atoi(Layer + strlen("Sub BG ")); + if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)) == TRUE) { + if(!SubScreen.gpu->dispBG[i]) GPU_addBack(SubScreen.gpu, i); + } else { + if(SubScreen.gpu->dispBG[i]) GPU_remove(SubScreen.gpu, i); } + } + else + { + /* TODO: Disable sprites */ + } + } + else + { + if(memcmp(Layer, "Main BG", 7) == 0) + { + i = atoi(Layer + strlen("Main BG ")); + if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)) == TRUE) { + if(!MainScreen.gpu->dispBG[i]) GPU_addBack(MainScreen.gpu, i); + } else { + if(MainScreen.gpu->dispBG[i]) GPU_remove(MainScreen.gpu, i); } + } + else + { + /* TODO: Disable sprites */ + } + } + //fprintf(stderr,"Changed %s to %d\n",Layer,gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); +} + +const char *Layers_Menu[10] = +{ + "Main BG 0", + "Main BG 1", + "Main BG 2", + "Main BG 3", + "Main OBJ", + "SUB BG 0", + "SUB BG 1", + "SUB BG 2", + "SUB BG 3", + "SUB OBJ", +}; + +/////////////////////////////// PRINTSCREEN ///////////////////////////////// +// TODO: improve (let choose filename, and use png) + +typedef struct +{ + u32 header_size; + s32 width; + s32 height; + u16 r1; + u16 depth; + u32 r2; + u32 size; + s32 r3,r4; + u32 r5,r6; +}BmpImageHeader; + +typedef struct +{ + u16 type; + u32 size; + u16 r1, r2; + u32 data_offset; +}BmpFileHeader; + + +int WriteBMP(const char *filename,u16 *bmp){ + BmpFileHeader fileheader; + BmpImageHeader imageheader; + fileheader.size = 14; + fileheader.type = 0x4D42; + fileheader.r1 = 0; + fileheader.r2=0; + fileheader.data_offset = 14+40; + + imageheader.header_size = 40; + imageheader.r1 = 1; + imageheader.depth = 24; + imageheader.r2 = 0; + imageheader.size = 256 * 192*2 * 3; + imageheader.r3 = 0; + imageheader.r4 = 0; + imageheader.r5 = 0; + imageheader.r6 = 0; + imageheader.width = 256; + imageheader.height = 192*2; + + FILE *fichier = fopen(filename,"wb"); + //fwrite(&fileheader, 1, 14, fichier); + + //fwrite(&imageheader, 1, 40, fichier); + fwrite( &fileheader.type, sizeof(fileheader.type), 1, fichier); + fwrite( &fileheader.size, sizeof(fileheader.size), 1, fichier); + fwrite( &fileheader.r1, sizeof(fileheader.r1), 1, fichier); + fwrite( &fileheader.r2, sizeof(fileheader.r2), 1, fichier); + fwrite( &fileheader.data_offset, sizeof(fileheader.data_offset), 1, fichier); + fwrite( &imageheader.header_size, sizeof(imageheader.header_size), 1, fichier); + fwrite( &imageheader.width, sizeof(imageheader.width), 1, fichier); + fwrite( &imageheader.height, sizeof(imageheader.height), 1, fichier); + fwrite( &imageheader.r1, sizeof(imageheader.r1), 1, fichier); + fwrite( &imageheader.depth, sizeof(imageheader.depth), 1, fichier); + fwrite( &imageheader.r2, sizeof(imageheader.r2), 1, fichier); + fwrite( &imageheader.size, sizeof(imageheader.size), 1, fichier); + fwrite( &imageheader.r3, sizeof(imageheader.r3), 1, fichier); + fwrite( &imageheader.r4, sizeof(imageheader.r4), 1, fichier); + fwrite( &imageheader.r5, sizeof(imageheader.r5), 1, fichier); + fwrite( &imageheader.r6, sizeof(imageheader.r6), 1, fichier); + int i,j,k; + for(j=0;j<192*2;j++)for(i=0;i<256;i++){ + u8 r,g,b; + u16 pixel = bmp[i+(192*2-j)*256]; + 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(char), fichier); + fwrite(&g, 1, sizeof(char), fichier); + fwrite(&b, 1, sizeof(char), fichier); +} + fclose(fichier); +return 1; +} + +static void Printscreen() +{ + WriteBMP("./test.bmp",GPU_screen); +} + +/////////////////////////////// DS CONFIGURATION ////////////////////////////////// + +#if 0 + +char FirmwareFile[256]; + +int LoadFirmware(const char *filename) +{ + int i; + u32 size; + FILE *f; + + strncpy(FirmwareFile, filename, 256); + + f = fopen(filename, "rb"); + if(!f) return -1; + + fseek(f, 0, SEEK_END); + size = ftell(f); + fseek(f, 0, SEEK_SET); + + if(size > MMU.spi7.fw.size) { fclose(f); return -1; } /* this must be a small file*/ + + i = fread(MMU.spi7.fw.data, size, 1, f); + + fclose(f); + + return i; +} + +int SelectFirmwareFile_Load(GtkWidget *w, gpointer data) +{ + GtkFileFilter *pFilter_nds, *pFilter_bin, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sChemin; + + BOOL oldState = desmume_running(); + Pause(); + + pParent = GTK_WIDGET(data); + + pFilter_nds = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_nds, "*.nds"); + gtk_file_filter_set_name(pFilter_nds, "Nds binary (.nds)"); + + pFilter_bin = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_bin, "*.bin"); + gtk_file_filter_set_name(pFilter_bin, "Binary file (.bin)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + /* Creation de la fenetre de selection */ + pFileSelection = gtk_file_chooser_dialog_new("Load firmware...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, + NULL); + /* On limite les actions a cette fenetre */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_bin); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + if(FirmwareFile[0]) gtk_file_chooser_select_uri(GTK_FILE_CHOOSER(pFileSelection), FirmwareFile); + + /* Affichage fenetre */ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) + { + case GTK_RESPONSE_OK: + /* Recuperation du chemin */ + sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + if(LoadFirmware((const char*)sChemin) < 0) + { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Unable to load :\n%s", sChemin); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } + else + { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Selected firmware :\n%s", sChemin); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } + + g_free(sChemin); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); + + if(oldState) Launch(); + +} + +int SelectFirmwareFile_Load(GtkWidget *w, gpointer data) +{ + GtkFileFilter *pFilter_nds, *pFilter_bin, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sChemin; + + BOOL oldState = desmume_running(); + Pause(); + + pParent = GTK_WIDGET(data); + + pFilter_nds = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_nds, "*.nds"); + gtk_file_filter_set_name(pFilter_nds, "Nds binary (.nds)"); + + pFilter_bin = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_bin, "*.bin"); + gtk_file_filter_set_name(pFilter_bin, "Binary file (.bin)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + /* Creation de la fenetre de selection */ + pFileSelection = gtk_file_chooser_dialog_new("Save firmware...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_OK, + NULL); + /* On limite les actions a cette fenetre */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_bin); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + if(FirmwareFile[0]) gtk_file_chooser_select_uri(GTK_FILE_CHOOSER(pFileSelection), FirmwareFile); + + /* Affichage fenetre */ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) + { + case GTK_RESPONSE_OK: + /* Recuperation du chemin */ + sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + if(LoadFirmware((const char*)sChemin) < 0) + { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Unable to load :\n%s", sChemin); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } + else + { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Selected firmware :\n%s", sChemin); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } + + g_free(sChemin); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); + + if(oldState) Launch(); + +} + +#endif + +/////////////////////////////// FRAMESKIP ///////////////////////////////// + +#define MAX_FRAMESKIP 10 + +void Modify_Frameskip(GtkWidget *widget, gpointer data) +{ + Frameskip = GPOINTER_TO_INT(data); +} + +/////////////////////////////// TOOLS MANAGEMENT /////////////////////////////// + +#include "dTool.h" + +extern const dTool_t *dTools_list[]; +extern const int dTools_list_size; + +BOOL *dTools_running; + +void Start_dTool(GtkWidget *widget, gpointer data) +{ + int tool = GPOINTER_TO_INT(data); + + if(dTools_running[tool]) return; + + dTools_list[tool]->open(tool); + dTools_running[tool] = TRUE; +} + +void dTool_CloseCallback(int tool) +{ + dTools_running[tool] = FALSE; +} + +/////////////////////////////// MAIN EMULATOR LOOP /////////////////////////////// + +static inline void _updateDTools() +{ + int i; + for(i = 0; i < dTools_list_size; i++) + { + if(dTools_running[i]) { dTools_list[i]->update(); } + } +} + +Uint32 fps, fps_SecStart, fps_FrameCount; + +gboolean EmuLoop(gpointer data) +{ + int i; + + if(desmume_running()) /* Si on est en train d'executer le programme ... */ + { + + fps_FrameCount += Frameskip + 1; + if(!fps_SecStart) fps_SecStart = SDL_GetTicks(); + if(SDL_GetTicks() - fps_SecStart >= 1000) + { + fps_SecStart = SDL_GetTicks(); + fps = fps_FrameCount; + fps_FrameCount = 0; + + char Title[32]; + sprintf(Title, "Desmume - %dfps", fps); + gtk_window_set_title(GTK_WINDOW(pWindow), Title); + } + + desmume_cycle(); /* Emule ! */ + for(i = 0; i < Frameskip; i++) desmume_cycle(); /* cycles supplémentaires pour le frameskip */ + + Draw(); + + _updateDTools(); + gtk_widget_queue_draw(pDrawingArea); + + return TRUE; + } + + regMainLoop = FALSE; + return FALSE; +} + + +/////////////////////////////// MAIN /////////////////////////////// + +#ifdef WIN32 +int WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) +{ + main(0,NULL); +} +#endif + +static void dui_set_accel_group(gpointer action, gpointer group) { + gtk_action_set_accel_group(action, group); +} + +int main (int argc, char *argv[]) +{ + int i; + + const char *commandLine_File = NULL; + GtkWidget *pVBox; + GtkWidget *pMenuBar; + GtkWidget *pMenu, *pSubMenu; + GtkWidget *pMenuItem, *pSubMenuItem; + GtkAccelGroup * accel_group; + + if(argc == 2) commandLine_File = argv[1]; + +#ifdef DEBUG + LogStart(); +#endif + + gtk_init(&argc, &argv); + SDL_Init(SDL_INIT_VIDEO); + desmume_init(); + + dTools_running = (BOOL*)malloc(sizeof(BOOL) * dTools_list_size); + for(i=0; i0) mFrameskip_Radio[i] = gtk_radio_menu_item_new_with_label_from_widget(GTK_RADIO_MENU_ITEM(mFrameskip_Radio[i-1]), frameskipRadio_buf); + else mFrameskip_Radio[i] = gtk_radio_menu_item_new_with_label(NULL, frameskipRadio_buf); + g_signal_connect(G_OBJECT(mFrameskip_Radio[i]), "activate", G_CALLBACK(Modify_Frameskip), GINT_TO_POINTER(i)); + gtk_menu_shell_append(GTK_MENU_SHELL(mFrameskip), mFrameskip_Radio[i]); + } + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mFrameskip_Radio[0]), TRUE); + + mGraphics = gtk_menu_new(); + pMenuItem = gtk_menu_item_new_with_label("Graphics"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItem), mGraphics); + gtk_menu_shell_append(GTK_MENU_SHELL(mEmulation), pMenuItem); + +// TODO: Un jour, peut être... >< + mSize = gtk_menu_new(); + pMenuItem = gtk_menu_item_new_with_label("Size"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItem), mSize); + gtk_menu_shell_append(GTK_MENU_SHELL(mGraphics), pMenuItem); + + for(i = 1; i < MAX_SCREENCOEFF; i++) { + char sizeRadio_buf[16]; + sprintf(sizeRadio_buf, "x%d", i); + if(i>1) mSize_Radio[i] = gtk_radio_menu_item_new_with_label_from_widget(GTK_RADIO_MENU_ITEM(mSize_Radio[i-1]), sizeRadio_buf); + else mSize_Radio[i] = gtk_radio_menu_item_new_with_label(NULL, sizeRadio_buf); + g_signal_connect(G_OBJECT(mSize_Radio[i]), "activate", G_CALLBACK(Modify_ScreenCoeff), GINT_TO_POINTER(i)); + gtk_menu_shell_append(GTK_MENU_SHELL(mSize), mSize_Radio[i]); + } + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mFrameskip_Radio[0]), TRUE); + + mLayers = gtk_menu_new(); + pMenuItem = gtk_menu_item_new_with_label("Layers"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItem), mLayers); + gtk_menu_shell_append(GTK_MENU_SHELL(mGraphics), pMenuItem); + + for(i = 0; i < 10; i++) { + mLayers_Radio[i] = gtk_check_menu_item_new_with_label(Layers_Menu[i]); + g_signal_connect(G_OBJECT(mLayers_Radio[i]), "activate", G_CALLBACK(Modify_Layer), (void*)Layers_Menu[i]); + gtk_menu_shell_append(GTK_MENU_SHELL(mLayers), mLayers_Radio[i]); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mLayers_Radio[i]), TRUE); + } + + + /** Menu "Options" **/ + GtkWidget *mConfig = gtk_menu_new(); + pMenuItem = gtk_menu_item_new_with_label("Config"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItem), mConfig); + gtk_menu_shell_append(GTK_MENU_SHELL(pMenuBar), pMenuItem); + + pMenuItem = gtk_menu_item_new_with_label("Edit controls"); + g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(Edit_Controls), (GtkWidget*) pWindow); + gtk_menu_shell_append(GTK_MENU_SHELL(mConfig), pMenuItem); + +#if 0 + + GtkWidget *mFirmware; + + mFirmware = gtk_menu_new(); + pMenuItem = gtk_menu_item_new_with_label("Firmware"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItem), mFirmware); + gtk_menu_shell_append(GTK_MENU_SHELL(mConfig), pMenuItem); + + pMenuItem = gtk_menu_item_new_with_label("Select..."); + g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(SelectFirmwareFile), (gpointer)0); + gtk_menu_shell_append(GTK_MENU_SHELL(mFirmware), pMenuItem); + + pMenuItem = gtk_menu_item_new_with_label("Config"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItem), mConfig); + gtk_menu_shell_append(GTK_MENU_SHELL(pMenuBar), pMenuItem); + +#endif + + /** Menu "Outils" **/ + + pMenu = gtk_menu_new(); + + for(i = 0; i < dTools_list_size; i++) + { + pMenuItem = gtk_menu_item_new_with_label(dTools_list[i]->name); + g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(Start_dTool), GINT_TO_POINTER(i)); + gtk_menu_shell_append(GTK_MENU_SHELL(pMenu), pMenuItem); + } + + pMenuItem = gtk_menu_item_new_with_label("Tools"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItem), pMenu); + gtk_menu_shell_append(GTK_MENU_SHELL(pMenuBar), pMenuItem); + + /** Menu "?" **/ + + pMenu = gtk_menu_new(); + +#if ((GTK_MAJOR_VERSION >= 2) && (GTK_MINOR_VERSION >= 6)) + pMenuItem = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT,NULL); +#else + pMenuItem = gtk_menu_item_new_with_label("About"); +#endif + g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(About), (GtkWidget*) pWindow); + gtk_menu_shell_append(GTK_MENU_SHELL(pMenu), pMenuItem); + + pMenuItem = gtk_menu_item_new_with_label("?"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItem), pMenu); + gtk_menu_shell_append(GTK_MENU_SHELL(pMenuBar), pMenuItem); + + /* Ajout du menu a la fenetre */ + gtk_box_pack_start(GTK_BOX(pVBox), pMenuBar, FALSE, FALSE, 0); + + /* Création de la Toolbar */ + + pToolbar = gtk_toolbar_new(); + gtk_box_pack_start(GTK_BOX(pVBox), pToolbar, FALSE, FALSE, 0); + + gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), GTK_TOOL_ITEM(gtk_action_create_tool_item(gtk_action_group_get_action(action_group, "open"))), -1); + gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), GTK_TOOL_ITEM(gtk_action_create_tool_item(gtk_action_group_get_action(action_group, "run"))), -1); + gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), GTK_TOOL_ITEM(gtk_action_create_tool_item(gtk_action_group_get_action(action_group, "pause"))), -1); + gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), GTK_TOOL_ITEM(gtk_action_create_tool_item(gtk_action_group_get_action(action_group, "quit"))), -1); + + /* Création de l'endroit pour l'affichage des écrans */ + + pDrawingArea= gtk_drawing_area_new(); + + gtk_drawing_area_size(GTK_DRAWING_AREA(pDrawingArea), 256, 384); + gtk_widget_set_usize (pDrawingArea, 256, 384); + + gtk_widget_set_events(pDrawingArea, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK ); + + g_signal_connect(G_OBJECT(pDrawingArea), "button_press_event", G_CALLBACK(Stylus_Press), NULL); + g_signal_connect(G_OBJECT(pDrawingArea), "button_release_event", G_CALLBACK(Stylus_Release), NULL); + g_signal_connect(G_OBJECT(pDrawingArea), "motion_notify_event", G_CALLBACK(Stylus_Move), NULL); + + + g_signal_connect( G_OBJECT(pDrawingArea), "realize", G_CALLBACK(Draw), NULL ) ; + g_signal_connect( G_OBJECT(pDrawingArea), "expose_event", G_CALLBACK(gtkFloatExposeEvent), NULL ) ; + + gtk_box_pack_start(GTK_BOX(pVBox), pDrawingArea, FALSE, FALSE, 0); + + /* Création de la barre d'état */ + + pStatusBar = gtk_statusbar_new(); + + pStatusBar_Ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(pStatusBar), "Global"); + + pStatusBar_Change("Desmume"); + + gtk_box_pack_end(GTK_BOX(pVBox), pStatusBar, FALSE, FALSE, 0); + + gtk_widget_show_all(pWindow); + + //LoadFirmware("fw.bin"); + + /* Vérifie la ligne de commandes */ + if(commandLine_File) + { + if(Open(commandLine_File) >= 0) + { + Launch(); + } + else + { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pWindow), + GTK_DIALOG_MODAL, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + "Unable to load :\n%s", commandLine_File); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } + } + + /* Boucle principale */ + +// gtk_idle_add(&EmuLoop, pWindow); +// g_idle_add(&EmuLoop, pWindow); + + gtk_main(); + + desmume_free(); + +#ifdef DEBUG + LogStop(); +#endif + + SDL_Quit(); + + Write_ConfigFile(); + + return EXIT_SUCCESS; +} diff --git a/tags/release_0_5_0/desmume/src/gtk/tools/ioregsView.c b/tags/release_0_5_0/desmume/src/gtk/tools/ioregsView.c new file mode 100644 index 000000000..b71b4057c --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/tools/ioregsView.c @@ -0,0 +1,464 @@ +#include +#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<>1]&(1<>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<>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<>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 +}; + + + + diff --git a/tags/release_0_5_0/desmume/src/gtk/tools/ioregsView.h b/tags/release_0_5_0/desmume/src/gtk/tools/ioregsView.h new file mode 100644 index 000000000..b36dd3707 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/gtk/tools/ioregsView.h @@ -0,0 +1,9 @@ +#ifndef __IOREGSVIEW_H__ +#define __IOREGSVIEW_H__ + +#include "../dTool.h" + +extern dTool_t dTool_ioregsView; + +#endif /*__IOREGSVIEW_H__*/ + diff --git a/tags/release_0_5_0/desmume/src/instruction_tabdef.inc b/tags/release_0_5_0/desmume/src/instruction_tabdef.inc new file mode 100644 index 000000000..c18e72640 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/instruction_tabdef.inc @@ -0,0 +1,4376 @@ +/* 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 +*/ + +TYPE_RETOUR (*CALLTYPE NOM_TAB[4096])(PARAMETRES)={ + OP_AND_LSL_IMM, // 000 0000 0 0000 + OP_AND_LSL_REG, // 000 0000 0 0001 + OP_AND_LSR_IMM, // 000 0000 0 0010 + OP_AND_LSR_REG, // 000 0000 0 0011 + OP_AND_ASR_IMM, // 000 0000 0 0100 + OP_AND_ASR_REG, // 000 0000 0 0101 + OP_AND_ROR_IMM, // 000 0000 0 0110 + OP_AND_ROR_REG, // 000 0000 0 0111 + + OP_AND_LSL_IMM, // 000 0000 0 1000 + OP_MUL, // 000 0000 0 1001 + OP_AND_LSR_IMM, // OOO OOOO O 1010 + OP_STRH_POS_INDE_M_REG_OFF, // 000 0000 0 1011 + OP_AND_ASR_IMM, // 000 0000 0 1100 + OP_UND, // 000 0000 0 1101 + OP_AND_ROR_IMM, // 000 0000 0 1110 + OP_UND, // 000 0000 0 1111 + + OP_AND_S_LSL_IMM, // 000 0000 1 0000 + OP_AND_S_LSL_REG, // 000 0000 1 0001 + OP_AND_S_LSR_IMM, // 000 0000 1 0010 + OP_AND_S_LSR_REG, // 000 0000 1 0011 + OP_AND_S_ASR_IMM, // 000 0000 1 0100 + OP_AND_S_ASR_REG, // 000 0000 1 0101 + OP_AND_S_ROR_IMM, // 000 0000 1 0110 + OP_AND_S_ROR_REG, // 000 0000 1 0111 + + OP_AND_S_LSL_IMM, // 000 0000 1 1000 + OP_MUL_S, // 000 0000 1 1001 + OP_AND_S_LSR_IMM, // 000 0000 1 1010 + OP_LDRH_POS_INDE_M_REG_OFF, // 000 0000 1 1011 + OP_AND_S_ASR_IMM, // 000 0000 1 1100 + OP_LDRSB_POS_INDE_M_REG_OFF,// 000 0000 1 1101 + OP_AND_S_ROR_IMM, // 000 0000 1 1110 + OP_LDRSH_POS_INDE_M_REG_OFF,// 000 0000 1 1111 + + OP_EOR_LSL_IMM, // 000 0001 0 0000 + OP_EOR_LSL_REG, // 000 0001 0 0001 + OP_EOR_LSR_IMM, // 000 0001 0 0010 + OP_EOR_LSR_REG, // 000 0001 0 0011 + OP_EOR_ASR_IMM, // 000 0001 0 0100 + OP_EOR_ASR_REG, // 000 0001 0 0101 + OP_EOR_ROR_IMM, // 000 0001 0 0110 + OP_EOR_ROR_REG, // 000 0001 0 0111 + + OP_EOR_LSL_IMM, // 000 0001 0 1000 + OP_MLA, // 000 0001 0 1001 + OP_EOR_LSR_IMM, // OOO OOO1 O 1010 + OP_UND, // 000 0001 0 1011 + OP_EOR_ASR_IMM, // 000 0001 0 1100 + OP_UND, // 000 0001 0 1101 + OP_EOR_ROR_IMM, // 000 0001 0 1110 + OP_UND, // 000 0001 0 1111 + + OP_EOR_S_LSL_IMM, // 000 0001 1 0000 + OP_EOR_S_LSL_REG, // 000 0001 1 0001 + OP_EOR_S_LSR_IMM, // 000 0001 1 0010 + OP_EOR_S_LSR_REG, // 000 0001 1 0011 + OP_EOR_S_ASR_IMM, // 000 0001 1 0100 + OP_EOR_S_ASR_REG, // 000 0001 1 0101 + OP_EOR_S_ROR_IMM, // 000 0001 1 0110 + OP_EOR_S_ROR_REG, // 000 0001 1 0111 + + OP_EOR_S_LSL_IMM, // 000 0001 1 1000 + OP_MLA_S, // 000 0001 1 1001 + OP_EOR_S_LSR_IMM, // 000 0001 1 1010 + OP_UND, // 000 0001 1 1011 + OP_EOR_S_ASR_IMM, // 000 0001 1 1100 + OP_UND, // 000 0001 1 1101 + OP_EOR_S_ROR_IMM, // 000 0001 1 1110 + OP_UND, // 000 0001 1 1111 + + OP_SUB_LSL_IMM, // 000 0010 0 0000 + OP_SUB_LSL_REG, // 000 0010 0 0001 + OP_SUB_LSR_IMM, // 000 0010 0 0010 + OP_SUB_LSR_REG, // 000 0010 0 0011 + OP_SUB_ASR_IMM, // 000 0010 0 0100 + OP_SUB_ASR_REG, // 000 0010 0 0101 + OP_SUB_ROR_IMM, // 000 0010 0 0110 + OP_SUB_ROR_REG, // 000 0010 0 0111 + + OP_SUB_LSL_IMM, // 000 0010 0 1000 + OP_UND, // 000 0010 0 1001 + OP_SUB_LSR_IMM, // OOO OO1O O 1010 + OP_STRH_POS_INDE_M_IMM_OFF, // 000 0010 0 1011 + OP_SUB_ASR_IMM, // 000 0010 0 1100 + OP_UND, // 000 0010 0 1101 + OP_SUB_ROR_IMM, // 000 0010 0 1110 + OP_UND, // 000 0010 0 1111 + + OP_SUB_S_LSL_IMM, // 000 0010 1 0000 + OP_SUB_S_LSL_REG, // 000 0010 1 0001 + OP_SUB_S_LSR_IMM, // 000 0010 1 0010 + OP_SUB_S_LSR_REG, // 000 0010 1 0011 + OP_SUB_S_ASR_IMM, // 000 0010 1 0100 + OP_SUB_S_ASR_REG, // 000 0010 1 0101 + OP_SUB_S_ROR_IMM, // 000 0010 1 0110 + OP_SUB_S_ROR_REG, // 000 0010 1 0111 + + OP_SUB_S_LSL_IMM, // 000 0010 1 1000 + OP_UND, // 000 0010 1 1001 + OP_SUB_S_LSR_IMM, // 000 0010 1 1010 + OP_LDRH_POS_INDE_M_IMM_OFF, // 000 0010 1 1011 + OP_SUB_S_ASR_IMM, // 000 0010 1 1100 + OP_LDRSB_POS_INDE_M_IMM_OFF,// 000 0010 1 1101 + OP_SUB_S_ROR_IMM, // 000 0010 1 1110 + OP_LDRSH_POS_INDE_M_IMM_OFF,// 000 0010 1 1111 +//-------------------- + OP_RSB_LSL_IMM, // 000 0011 0 0000 + OP_RSB_LSL_REG, // 000 0011 0 0001 + OP_RSB_LSR_IMM, // 000 0011 0 0010 + OP_RSB_LSR_REG, // 000 0011 0 0011 + OP_RSB_ASR_IMM, // 000 0011 0 0100 + OP_RSB_ASR_REG, // 000 0011 0 0101 + OP_RSB_ROR_IMM, // 000 0011 0 0110 + OP_RSB_ROR_REG, // 000 0011 0 0111 + + OP_RSB_LSL_IMM, // 000 0011 0 1000 + OP_UND, // 000 0011 0 1001 + OP_RSB_LSR_IMM, // OOO OO11 O 1010 + OP_UND, // 000 0011 0 1011 + OP_RSB_ASR_IMM, // 000 0011 0 1100 + OP_UND, // 000 0011 0 1101 + OP_RSB_ROR_IMM, // 000 0011 0 1110 + OP_UND, // 000 0011 0 1111 + + OP_RSB_S_LSL_IMM, // 000 0011 1 0000 + OP_RSB_S_LSL_REG, // 000 0011 1 0001 + OP_RSB_S_LSR_IMM, // 000 0011 1 0010 + OP_RSB_S_LSR_REG, // 000 0011 1 0011 + OP_RSB_S_ASR_IMM, // 000 0011 1 0100 + OP_RSB_S_ASR_REG, // 000 0011 1 0101 + OP_RSB_S_ROR_IMM, // 000 0011 1 0110 + OP_RSB_S_ROR_REG, // 000 0011 1 0111 + + OP_RSB_S_LSL_IMM, // 000 0011 1 1000 + OP_UND, // 000 0011 1 1001 + OP_RSB_S_LSR_IMM, // 000 0011 1 1010 + OP_UND, // 000 0011 1 1011 + OP_RSB_S_ASR_IMM, // 000 0011 1 1100 + OP_UND, // 000 0011 1 1101 + OP_RSB_S_ROR_IMM, // 000 0011 1 1110 + OP_UND, // 000 0011 1 1111 +//-------------------------- + OP_ADD_LSL_IMM, // 000 0100 0 0000 + OP_ADD_LSL_REG, // 000 0100 0 0001 + OP_ADD_LSR_IMM, // 000 0100 0 0010 + OP_ADD_LSR_REG, // 000 0100 0 0011 + OP_ADD_ASR_IMM, // 000 0100 0 0100 + OP_ADD_ASR_REG, // 000 0100 0 0101 + OP_ADD_ROR_IMM, // 000 0100 0 0110 + OP_ADD_ROR_REG, // 000 0100 0 0111 + + OP_ADD_LSL_IMM, // 000 0100 0 1000 + OP_UMULL, // 000 0100 0 1001 + OP_ADD_LSR_IMM, // OOO O10O O 1010 + OP_STRH_POS_INDE_P_REG_OFF, // 000 0100 0 1011 + OP_ADD_ASR_IMM, // 000 0100 0 1100 + OP_UND, // 000 0100 0 1101 + OP_ADD_ROR_IMM, // 000 0100 0 1110 + OP_UND, // 000 0100 0 1111 + + OP_ADD_S_LSL_IMM, // 000 0100 1 0000 + OP_ADD_S_LSL_REG, // 000 0100 1 0001 + OP_ADD_S_LSR_IMM, // 000 0100 1 0010 + OP_ADD_S_LSR_REG, // 000 0100 1 0011 + OP_ADD_S_ASR_IMM, // 000 0100 1 0100 + OP_ADD_S_ASR_REG, // 000 0100 1 0101 + OP_ADD_S_ROR_IMM, // 000 0100 1 0110 + OP_ADD_S_ROR_REG, // 000 0100 1 0111 + + OP_ADD_S_LSL_IMM, // 000 0100 1 1000 + OP_UMULL_S, // 000 0100 1 1001 + OP_ADD_S_LSR_IMM, // 000 0100 1 1010 + OP_LDRH_POS_INDE_P_REG_OFF, // 000 0100 1 1011 + OP_ADD_S_ASR_IMM, // 000 0100 1 1100 + OP_LDRSB_POS_INDE_P_REG_OFF,// 000 0100 1 1101 + OP_ADD_S_ROR_IMM, // 000 0100 1 1110 + OP_LDRSH_POS_INDE_P_REG_OFF,// 000 0100 1 1111 +//----------------------------------------- + OP_ADC_LSL_IMM, // 000 0101 0 0000 + OP_ADC_LSL_REG, // 000 0101 0 0001 + OP_ADC_LSR_IMM, // 000 0101 0 0010 + OP_ADC_LSR_REG, // 000 0101 0 0011 + OP_ADC_ASR_IMM, // 000 0101 0 0100 + OP_ADC_ASR_REG, // 000 0101 0 0101 + OP_ADC_ROR_IMM, // 000 0101 0 0110 + OP_ADC_ROR_REG, // 000 0101 0 0111 + + OP_ADC_LSL_IMM, // 000 0101 0 1000 + OP_UMLAL, // 000 0101 0 1001 + OP_ADC_LSR_IMM, // OOO O101 O 1010 + OP_UND, // 000 0101 0 1011 + OP_ADC_ASR_IMM, // 000 0101 0 1100 + OP_UND, // 000 0101 0 1101 + OP_ADC_ROR_IMM, // 000 0101 0 1110 + OP_UND, // 000 0101 0 1111 + + OP_ADC_S_LSL_IMM, // 000 0101 1 0000 + OP_ADC_S_LSL_REG, // 000 0101 1 0001 + OP_ADC_S_LSR_IMM, // 000 0101 1 0010 + OP_ADC_S_LSR_REG, // 000 0101 1 0011 + OP_ADC_S_ASR_IMM, // 000 0101 1 0100 + OP_ADC_S_ASR_REG, // 000 0101 1 0101 + OP_ADC_S_ROR_IMM, // 000 0101 1 0110 + OP_ADC_S_ROR_REG, // 000 0101 1 0111 + + OP_ADC_S_LSL_IMM, // 000 0101 1 1000 + OP_UMLAL_S, // 000 0101 1 1001 + OP_ADC_S_LSR_IMM, // 000 0101 1 1010 + OP_UND, // 000 0101 1 1011 + OP_ADC_S_ASR_IMM, // 000 0101 1 1100 + OP_UND, // 000 0101 1 1101 + OP_ADC_S_ROR_IMM, // 000 0101 1 1110 + OP_UND, // 000 0101 1 1111 +//------------------------------------------ + OP_SBC_LSL_IMM, // 000 0110 0 0000 + OP_SBC_LSL_REG, // 000 0110 0 0001 + OP_SBC_LSR_IMM, // 000 0110 0 0010 + OP_SBC_LSR_REG, // 000 0110 0 0011 + OP_SBC_ASR_IMM, // 000 0110 0 0100 + OP_SBC_ASR_REG, // 000 0110 0 0101 + OP_SBC_ROR_IMM, // 000 0110 0 0110 + OP_SBC_ROR_REG, // 000 0110 0 0111 + + OP_SBC_LSL_IMM, // 000 0110 0 1000 + OP_SMULL, // 000 0110 0 1001 + OP_SBC_LSR_IMM, // OOO O11O O 1010 + OP_STRH_POS_INDE_P_IMM_OFF, // 000 0110 0 1011 + OP_SBC_ASR_IMM, // 000 0110 0 1100 + OP_UND, // 000 0110 0 1101 + OP_SBC_ROR_IMM, // 000 0110 0 1110 + OP_UND, // 000 0110 0 1111 + + OP_SBC_S_LSL_IMM, // 000 0110 1 0000 + OP_SBC_S_LSL_REG, // 000 0110 1 0001 + OP_SBC_S_LSR_IMM, // 000 0110 1 0010 + OP_SBC_S_LSR_REG, // 000 0110 1 0011 + OP_SBC_S_ASR_IMM, // 000 0110 1 0100 + OP_SBC_S_ASR_REG, // 000 0110 1 0101 + OP_SBC_S_ROR_IMM, // 000 0110 1 0110 + OP_SBC_S_ROR_REG, // 000 0110 1 0111 + + OP_SBC_S_LSL_IMM, // 000 0110 1 1000 + OP_SMULL_S, // 000 0110 1 1001 + OP_SBC_S_LSR_IMM, // 000 0110 1 1010 + OP_LDRH_POS_INDE_P_IMM_OFF, // 000 0110 1 1011 + OP_SBC_S_ASR_IMM, // 000 0110 1 1100 + OP_LDRSB_POS_INDE_P_IMM_OFF,// 000 0110 1 1101 + OP_SBC_S_ROR_IMM, // 000 0110 1 1110 + OP_LDRSH_POS_INDE_P_IMM_OFF,// 000 0110 1 1111 +//------------------------------------------ + OP_RSC_LSL_IMM, // 000 0111 0 0000 + OP_RSC_LSL_REG, // 000 0111 0 0001 + OP_RSC_LSR_IMM, // 000 0111 0 0010 + OP_RSC_LSR_REG, // 000 0111 0 0011 + OP_RSC_ASR_IMM, // 000 0111 0 0100 + OP_RSC_ASR_REG, // 000 0111 0 0101 + OP_RSC_ROR_IMM, // 000 0111 0 0110 + OP_RSC_ROR_REG, // 000 0111 0 0111 + + OP_RSC_LSL_IMM, // 000 0111 0 1000 + OP_SMLAL, // 000 0111 0 1001 + OP_RSC_LSR_IMM, // OOO O111 O 1010 + OP_UND, // 000 0111 0 1011 + OP_RSC_ASR_IMM, // 000 0111 0 1100 + OP_UND, // 000 0111 0 1101 + OP_RSC_ROR_IMM, // 000 0111 0 1110 + OP_UND, // 000 0111 0 1111 + + OP_RSC_S_LSL_IMM, // 000 0111 1 0000 + OP_RSC_S_LSL_REG, // 000 0111 1 0001 + OP_RSC_S_LSR_IMM, // 000 0111 1 0010 + OP_RSC_S_LSR_REG, // 000 0111 1 0011 + OP_RSC_S_ASR_IMM, // 000 0111 1 0100 + OP_RSC_S_ASR_REG, // 000 0111 1 0101 + OP_RSC_S_ROR_IMM, // 000 0111 1 0110 + OP_RSC_S_ROR_REG, // 000 0111 1 0111 + + OP_RSC_S_LSL_IMM, // 000 0111 1 1000 + OP_SMLAL_S, // 000 0111 1 1001 + OP_RSC_S_LSR_IMM, // 000 0111 1 1010 + OP_UND, // 000 0111 1 1011 + OP_RSC_S_ASR_IMM, // 000 0111 1 1100 + OP_UND, // 000 0111 1 1101 + OP_RSC_S_ROR_IMM, // 000 0111 1 1110 + OP_UND, // 000 0111 1 1111 +//------------------------------------------ + OP_MRS_CPSR, // 000 1000 0 0000 + OP_UND, // 000 1000 0 0001 + OP_UND, // 000 1000 0 0010 + OP_UND, // 000 1000 0 0011 + OP_UND, // 000 1000 0 0100 + OP_QADD, // 000 1000 0 0101 + OP_UND, // 000 1000 0 0110 + OP_UND, // 000 1000 0 0111 + + OP_SMLA_B_B, // 000 1000 0 1000 + OP_SWP, // 000 1000 0 1001 + OP_SMLA_T_B, // 000 1000 0 1010 + OP_STRH_M_REG_OFF, // 000 1000 0 1011 + OP_SMLA_B_T, // 000 1000 0 1100 + OP_UND, // 000 1000 0 1101 + OP_SMLA_T_T, // 000 1000 0 1110 + OP_UND, // 000 1000 0 1111 + + OP_TST_LSL_IMM, // 000 1000 1 0000 + OP_TST_LSL_REG, // 000 1000 1 0001 + OP_TST_LSR_IMM, // 000 1000 1 0010 + OP_TST_LSR_REG, // 000 1000 1 0011 + OP_TST_ASR_IMM, // 000 1000 1 0100 + OP_TST_ASR_REG, // 000 1000 1 0101 + OP_TST_ROR_IMM, // 000 1000 1 0110 + OP_TST_ROR_REG, // 000 1000 1 0111 + + OP_TST_LSL_IMM, // 000 1000 1 1000 + OP_UND, // 000 1000 1 1001 + OP_TST_LSR_IMM, // OOO 100O 1 1010 + OP_LDRH_M_REG_OFF, // 000 1000 1 1011 + OP_TST_ASR_IMM, // 000 1000 1 1100 + OP_LDRSB_M_REG_OFF,// 000 1000 1 1101 + OP_TST_ROR_IMM, // 000 1000 1 1110 + OP_LDRSH_M_REG_OFF,// 000 1000 1 1111 +//------------------------------------------ + OP_MSR_CPSR, // 000 1001 0 0000 + OP_BX, // 000 1001 0 0001 + OP_UND, // 000 1001 0 0010 + OP_BLX_REG, // 000 1001 0 0011 + OP_UND, // 000 1001 0 0100 + OP_QSUB, // 000 1001 0 0101 + OP_UND, // 000 1001 0 0110 + OP_BKPT, // 000 1001 0 0111 + + OP_SMLAW_B, // 000 1001 0 1000 + OP_UND, // 000 1001 0 1001 + OP_SMULW_B, // 000 1001 0 1010 + OP_STRH_PRE_INDE_M_REG_OFF, // 000 1001 0 1011 + OP_SMLAW_T, // 000 1001 0 1100 + OP_UND, // 000 1001 0 1101 + OP_SMULW_T, // 000 1001 0 1110 + OP_UND, // 000 1001 0 1111 + + OP_TEQ_LSL_IMM, // 000 1001 1 0000 + OP_TEQ_LSL_REG, // 000 1001 1 0001 + OP_TEQ_LSR_IMM, // 000 1001 1 0010 + OP_TEQ_LSR_REG, // 000 1001 1 0011 + OP_TEQ_ASR_IMM, // 000 1001 1 0100 + OP_TEQ_ASR_REG, // 000 1001 1 0101 + OP_TEQ_ROR_IMM, // 000 1001 1 0110 + OP_TEQ_ROR_REG, // 000 1001 1 0111 + + OP_TEQ_LSL_IMM, // 000 1001 1 1000 + OP_UND, // 000 1001 1 1001 + OP_TEQ_LSR_IMM, // OOO 1001 1 1010 + OP_LDRH_PRE_INDE_M_REG_OFF, // 000 1001 1 1011 + OP_TEQ_ASR_IMM, // 000 1001 1 1100 + OP_LDRSB_PRE_INDE_M_REG_OFF, // 000 1001 1 1101 + OP_TEQ_ROR_IMM, // 000 1001 1 1110 + OP_LDRSH_PRE_INDE_M_REG_OFF, // 000 1001 1 1111 +//------------------------------------------ + OP_MRS_SPSR, // 000 1010 0 0000 + OP_UND, // 000 1010 0 0001 + OP_UND, // 000 1010 0 0010 + OP_UND, // 000 1010 0 0011 + OP_UND, // 000 1010 0 0100 + OP_QDADD, // 000 1010 0 0101 + OP_UND, // 000 1010 0 0110 + OP_UND, // 000 1010 0 0111 + + OP_SMLAL_B_B, // 000 1010 0 1000 + OP_SWPB, // 000 1010 0 1001 + OP_SMLAL_T_B, // 000 1010 0 1010 + OP_STRH_M_IMM_OFF, // 000 1010 0 1011 + OP_SMLAL_B_T, // 000 1010 0 1100 + OP_UND, // 000 1010 0 1101 + OP_SMLAL_T_T, // 000 1010 0 1110 + OP_UND, // 000 1010 0 1111 + + OP_CMP_LSL_IMM, // 000 1010 1 0000 + OP_CMP_LSL_REG, // 000 1010 1 0001 + OP_CMP_LSR_IMM, // 000 1010 1 0010 + OP_CMP_LSR_REG, // 000 1010 1 0011 + OP_CMP_ASR_IMM, // 000 1010 1 0100 + OP_CMP_ASR_REG, // 000 1010 1 0101 + OP_CMP_ROR_IMM, // 000 1010 1 0110 + OP_CMP_ROR_REG, // 000 1010 1 0111 + + OP_CMP_LSL_IMM, // 000 1010 1 1000 + OP_UND, // 000 1010 1 1001 + OP_CMP_LSR_IMM, // OOO 1O1O 1 1010 + OP_LDRH_M_IMM_OFF, // 000 1010 1 1011 + OP_CMP_ASR_IMM, // 000 1010 1 1100 + OP_LDRSB_M_IMM_OFF,// 000 1010 1 1101 + OP_CMP_ROR_IMM, // 000 1010 1 1110 + OP_LDRSH_M_IMM_OFF,// 000 1010 1 1111 +//------------------------------------------ + OP_MSR_SPSR, // 000 1011 0 0000 + OP_CLZ, // 000 1011 0 0001 + OP_UND, // 000 1011 0 0010 + OP_UND, // 000 1011 0 0011 + OP_UND, // 000 1011 0 0100 + OP_QDSUB, // 000 1011 0 0101 + OP_UND, // 000 1011 0 0110 + OP_UND, // 000 1011 0 0111 + + OP_SMUL_B_B, // 000 1011 0 1000 + OP_UND, // 000 1011 0 1001 + OP_SMUL_T_B, // 000 1011 0 1010 + OP_STRH_PRE_INDE_M_IMM_OFF, // 000 1011 0 1011 + OP_SMUL_B_T, // 000 1011 0 1100 + OP_UND, // 000 1011 0 1101 + OP_SMUL_T_T, // 000 1011 0 1110 + OP_UND, // 000 1011 0 1111 + + OP_CMN_LSL_IMM, // 000 1011 1 0000 + OP_CMN_LSL_REG, // 000 1011 1 0001 + OP_CMN_LSR_IMM, // 000 1011 1 0010 + OP_CMN_LSR_REG, // 000 1011 1 0011 + OP_CMN_ASR_IMM, // 000 1011 1 0100 + OP_CMN_ASR_REG, // 000 1011 1 0101 + OP_CMN_ROR_IMM, // 000 1011 1 0110 + OP_CMN_ROR_REG, // 000 1011 1 0111 + + OP_CMN_LSL_IMM, // 000 1011 1 1000 + OP_UND, // 000 1011 1 1001 + OP_CMN_LSR_IMM, // OOO 1O11 1 1010 + OP_LDRH_PRE_INDE_M_IMM_OFF, // 000 1011 1 1011 + OP_CMN_ASR_IMM, // 000 1011 1 1100 + OP_LDRSB_PRE_INDE_M_IMM_OFF, // 000 1011 1 1101 + OP_CMN_ROR_IMM, // 000 1011 1 1110 + OP_LDRSH_PRE_INDE_M_IMM_OFF, // 000 1011 1 1111 +//------------------------------------------ + OP_ORR_LSL_IMM, // 000 1100 0 0000 + OP_ORR_LSL_REG, // 000 1100 0 0001 + OP_ORR_LSR_IMM, // 000 1100 0 0010 + OP_ORR_LSR_REG, // 000 1100 0 0011 + OP_ORR_ASR_IMM, // 000 1100 0 0100 + OP_ORR_ASR_REG, // 000 1100 0 0101 + OP_ORR_ROR_IMM, // 000 1100 0 0110 + OP_ORR_ROR_REG, // 000 1100 0 0111 + + OP_ORR_LSL_IMM, // 000 1100 0 1000 + OP_UND, // 000 1100 0 1001 + OP_ORR_LSR_IMM, // OOO 110O O 1010 + OP_STRH_P_REG_OFF, // 000 1100 0 1011 + OP_ORR_ASR_IMM, // 000 1100 0 1100 + OP_UND, // 000 1100 0 1101 + OP_ORR_ROR_IMM, // 000 1100 0 1110 + OP_UND, // 000 1100 0 1111 + + OP_ORR_S_LSL_IMM, // 000 1100 1 0000 + OP_ORR_S_LSL_REG, // 000 1100 1 0001 + OP_ORR_S_LSR_IMM, // 000 1100 1 0010 + OP_ORR_S_LSR_REG, // 000 1100 1 0011 + OP_ORR_S_ASR_IMM, // 000 1100 1 0100 + OP_ORR_S_ASR_REG, // 000 1100 1 0101 + OP_ORR_S_ROR_IMM, // 000 1100 1 0110 + OP_ORR_S_ROR_REG, // 000 1100 1 0111 + + OP_ORR_S_LSL_IMM, // 000 1100 1 1000 + OP_UND, // 000 1100 1 1001 + OP_ORR_S_LSR_IMM, // 000 1100 1 1010 + OP_LDRH_P_REG_OFF, // 000 1100 1 1011 + OP_ORR_S_ASR_IMM, // 000 1100 1 1100 + OP_LDRSB_P_REG_OFF,// 000 1100 1 1101 + OP_ORR_S_ROR_IMM, // 000 1100 1 1110 + OP_LDRSH_P_REG_OFF,// 000 1100 1 1111 +//------------------------------------------ + OP_MOV_LSL_IMM, // 000 1101 0 0000 + OP_MOV_LSL_REG, // 000 1101 0 0001 + OP_MOV_LSR_IMM, // 000 1101 0 0010 + OP_MOV_LSR_REG, // 000 1101 0 0011 + OP_MOV_ASR_IMM, // 000 1101 0 0100 + OP_MOV_ASR_REG, // 000 1101 0 0101 + OP_MOV_ROR_IMM, // 000 1101 0 0110 + OP_MOV_ROR_REG, // 000 1101 0 0111 + + OP_MOV_LSL_IMM, // 000 1101 0 1000 + OP_UND, // 000 1101 0 1001 + OP_MOV_LSR_IMM, // OOO 1101 O 1010 + OP_STRH_PRE_INDE_P_REG_OFF, // 000 1101 0 1011 + OP_MOV_ASR_IMM, // 000 1101 0 1100 + OP_UND, // 000 1101 0 1101 + OP_MOV_ROR_IMM, // 000 1101 0 1110 + OP_UND, // 000 1101 0 1111 + + OP_MOV_S_LSL_IMM, // 000 1101 1 0000 + OP_MOV_S_LSL_REG, // 000 1101 1 0001 + OP_MOV_S_LSR_IMM, // 000 1101 1 0010 + OP_MOV_S_LSR_REG, // 000 1101 1 0011 + OP_MOV_S_ASR_IMM, // 000 1101 1 0100 + OP_MOV_S_ASR_REG, // 000 1101 1 0101 + OP_MOV_S_ROR_IMM, // 000 1101 1 0110 + OP_MOV_S_ROR_REG, // 000 1101 1 0111 + + OP_MOV_S_LSL_IMM, // 000 1101 1 1000 + OP_UND, // 000 1101 1 1001 + OP_MOV_S_LSR_IMM, // 000 1101 1 1010 + OP_LDRH_PRE_INDE_P_REG_OFF, // 000 1101 1 1011 + OP_MOV_S_ASR_IMM, // 000 1101 1 1100 + OP_LDRSB_PRE_INDE_P_REG_OFF,// 000 1101 1 1101 + OP_MOV_S_ROR_IMM, // 000 1101 1 1110 + OP_LDRSH_PRE_INDE_P_REG_OFF,// 000 1101 1 1111 +//------------------------------------------ + OP_BIC_LSL_IMM, // 000 1110 0 0000 + OP_BIC_LSL_REG, // 000 1110 0 0001 + OP_BIC_LSR_IMM, // 000 1110 0 0010 + OP_BIC_LSR_REG, // 000 1110 0 0011 + OP_BIC_ASR_IMM, // 000 1110 0 0100 + OP_BIC_ASR_REG, // 000 1110 0 0101 + OP_BIC_ROR_IMM, // 000 1110 0 0110 + OP_BIC_ROR_REG, // 000 1110 0 0111 + + OP_BIC_LSL_IMM, // 000 1110 0 1000 + OP_UND, // 000 1110 0 1001 + OP_BIC_LSR_IMM, // OOO 111O O 1010 + OP_STRH_P_IMM_OFF, // 000 1110 0 1011 + OP_BIC_ASR_IMM, // 000 1110 0 1100 + OP_UND, // 000 1110 0 1101 + OP_BIC_ROR_IMM, // 000 1110 0 1110 + OP_UND, // 000 1110 0 1111 + + OP_BIC_S_LSL_IMM, // 000 1110 1 0000 + OP_BIC_S_LSL_REG, // 000 1110 1 0001 + OP_BIC_S_LSR_IMM, // 000 1110 1 0010 + OP_BIC_S_LSR_REG, // 000 1110 1 0011 + OP_BIC_S_ASR_IMM, // 000 1110 1 0100 + OP_BIC_S_ASR_REG, // 000 1110 1 0101 + OP_BIC_S_ROR_IMM, // 000 1110 1 0110 + OP_BIC_S_ROR_REG, // 000 1110 1 0111 + + OP_BIC_S_LSL_IMM, // 000 1110 1 1000 + OP_UND, // 000 1110 1 1001 + OP_BIC_S_LSR_IMM, // 000 1110 1 1010 + OP_LDRH_P_IMM_OFF, // 000 1110 1 1011 + OP_BIC_S_ASR_IMM, // 000 1110 1 1100 + OP_LDRSB_P_IMM_OFF,// 000 1110 1 1101 + OP_BIC_S_ROR_IMM, // 000 1110 1 1110 + OP_LDRSH_P_IMM_OFF,// 000 1110 1 1111 +//------------------------------------------- + OP_MVN_LSL_IMM, // 000 1111 0 0000 + OP_MVN_LSL_REG, // 000 1111 0 0001 + OP_MVN_LSR_IMM, // 000 1111 0 0010 + OP_MVN_LSR_REG, // 000 1111 0 0011 + OP_MVN_ASR_IMM, // 000 1111 0 0100 + OP_MVN_ASR_REG, // 000 1111 0 0101 + OP_MVN_ROR_IMM, // 000 1111 0 0110 + OP_MVN_ROR_REG, // 000 1111 0 0111 + + OP_MVN_LSL_IMM, // 000 1111 0 1000 + OP_UND, // 000 1111 0 1001 + OP_MVN_LSR_IMM, // OOO 1111 O 1010 + OP_STRH_PRE_INDE_P_IMM_OFF, // 000 1111 0 1011 + OP_MVN_ASR_IMM, // 000 1111 0 1100 + OP_UND, // 000 1111 0 1101 + OP_MVN_ROR_IMM, // 000 1111 0 1110 + OP_UND, // 000 1111 0 1111 + + OP_MVN_S_LSL_IMM, // 000 1111 1 0000 + OP_MVN_S_LSL_REG, // 000 1111 1 0001 + OP_MVN_S_LSR_IMM, // 000 1111 1 0010 + OP_MVN_S_LSR_REG, // 000 1111 1 0011 + OP_MVN_S_ASR_IMM, // 000 1111 1 0100 + OP_MVN_S_ASR_REG, // 000 1111 1 0101 + OP_MVN_S_ROR_IMM, // 000 1111 1 0110 + OP_MVN_S_ROR_REG, // 000 1111 1 0111 + + OP_MVN_S_LSL_IMM, // 000 1111 1 1000 + OP_UND, // 000 1111 1 1001 + OP_MVN_S_LSR_IMM, // 000 1111 1 1010 + OP_LDRH_PRE_INDE_P_IMM_OFF, // 000 1111 1 1011 + OP_MVN_S_ASR_IMM, // 000 1111 1 1100 + OP_LDRSB_PRE_INDE_P_IMM_OFF,// 000 1111 1 1101 + OP_MVN_S_ROR_IMM, // 000 1111 1 1110 + OP_LDRSH_PRE_INDE_P_IMM_OFF,// 000 1111 1 1111 +//------------------------------------------- + OP_AND_IMM_VAL, // 001 0000 0 0000 + OP_AND_IMM_VAL, // 001 0000 0 0001 + OP_AND_IMM_VAL, // 001 0000 0 0010 + OP_AND_IMM_VAL, // 001 0000 0 0011 + OP_AND_IMM_VAL, // 001 0000 0 0100 + OP_AND_IMM_VAL, // 001 0000 0 0101 + OP_AND_IMM_VAL, // 001 0000 0 0110 + OP_AND_IMM_VAL, // 001 0000 0 0111 + OP_AND_IMM_VAL, // 001 0000 0 1000 + OP_AND_IMM_VAL, // 001 0000 0 1001 + OP_AND_IMM_VAL, // 001 0000 0 1010 + OP_AND_IMM_VAL, // 001 0000 0 1011 + OP_AND_IMM_VAL, // 001 0000 0 1100 + OP_AND_IMM_VAL, // 001 0000 0 1101 + OP_AND_IMM_VAL, // 001 0000 0 1110 + OP_AND_IMM_VAL, // 001 0000 0 1111 + + OP_AND_S_IMM_VAL, // 001 0000 1 0000 + OP_AND_S_IMM_VAL, // 001 0000 1 0001 + OP_AND_S_IMM_VAL, // 001 0000 1 0010 + OP_AND_S_IMM_VAL, // 001 0000 1 0011 + OP_AND_S_IMM_VAL, // 001 0000 1 0100 + OP_AND_S_IMM_VAL, // 001 0000 1 0101 + OP_AND_S_IMM_VAL, // 001 0000 1 0110 + OP_AND_S_IMM_VAL, // 001 0000 1 0111 + OP_AND_S_IMM_VAL, // 001 0000 1 1000 + OP_AND_S_IMM_VAL, // 001 0000 1 1001 + OP_AND_S_IMM_VAL, // 001 0000 1 1010 + OP_AND_S_IMM_VAL, // 001 0000 1 1011 + OP_AND_S_IMM_VAL, // 001 0000 1 1100 + OP_AND_S_IMM_VAL, // 001 0000 1 1101 + OP_AND_S_IMM_VAL, // 001 0000 1 1110 + OP_AND_S_IMM_VAL, // 001 0000 1 1111 +//------------------------------------------ + OP_EOR_IMM_VAL, // 001 0001 0 0000 + OP_EOR_IMM_VAL, // 001 0001 0 0001 + OP_EOR_IMM_VAL, // 001 0001 0 0010 + OP_EOR_IMM_VAL, // 001 0001 0 0011 + OP_EOR_IMM_VAL, // 001 0001 0 0100 + OP_EOR_IMM_VAL, // 001 0001 0 0101 + OP_EOR_IMM_VAL, // 001 0001 0 0110 + OP_EOR_IMM_VAL, // 001 0001 0 0111 + OP_EOR_IMM_VAL, // 001 0001 0 1000 + OP_EOR_IMM_VAL, // 001 0001 0 1001 + OP_EOR_IMM_VAL, // 001 0001 0 1010 + OP_EOR_IMM_VAL, // 001 0001 0 1011 + OP_EOR_IMM_VAL, // 001 0001 0 1100 + OP_EOR_IMM_VAL, // 001 0001 0 1101 + OP_EOR_IMM_VAL, // 001 0001 0 1110 + OP_EOR_IMM_VAL, // 001 0001 0 1111 + + OP_EOR_S_IMM_VAL, // 001 0001 1 0000 + OP_EOR_S_IMM_VAL, // 001 0001 1 0001 + OP_EOR_S_IMM_VAL, // 001 0001 1 0010 + OP_EOR_S_IMM_VAL, // 001 0001 1 0011 + OP_EOR_S_IMM_VAL, // 001 0001 1 0100 + OP_EOR_S_IMM_VAL, // 001 0001 1 0101 + OP_EOR_S_IMM_VAL, // 001 0001 1 0110 + OP_EOR_S_IMM_VAL, // 001 0001 1 0111 + OP_EOR_S_IMM_VAL, // 001 0001 1 1000 + OP_EOR_S_IMM_VAL, // 001 0001 1 1001 + OP_EOR_S_IMM_VAL, // 001 0001 1 1010 + OP_EOR_S_IMM_VAL, // 001 0001 1 1011 + OP_EOR_S_IMM_VAL, // 001 0001 1 1100 + OP_EOR_S_IMM_VAL, // 001 0001 1 1101 + OP_EOR_S_IMM_VAL, // 001 0001 1 1110 + OP_EOR_S_IMM_VAL, // 001 0001 1 1111 +//------------------------------------------ + OP_SUB_IMM_VAL, // 001 0010 0 0000 + OP_SUB_IMM_VAL, // 001 0010 0 0001 + OP_SUB_IMM_VAL, // 001 0010 0 0010 + OP_SUB_IMM_VAL, // 001 0010 0 0011 + OP_SUB_IMM_VAL, // 001 0010 0 0100 + OP_SUB_IMM_VAL, // 001 0010 0 0101 + OP_SUB_IMM_VAL, // 001 0010 0 0110 + OP_SUB_IMM_VAL, // 001 0010 0 0111 + OP_SUB_IMM_VAL, // 001 0010 0 1000 + OP_SUB_IMM_VAL, // 001 0010 0 1001 + OP_SUB_IMM_VAL, // 001 0010 0 1010 + OP_SUB_IMM_VAL, // 001 0010 0 1011 + OP_SUB_IMM_VAL, // 001 0010 0 1100 + OP_SUB_IMM_VAL, // 001 0010 0 1101 + OP_SUB_IMM_VAL, // 001 0010 0 1110 + OP_SUB_IMM_VAL, // 001 0010 0 1111 + + OP_SUB_S_IMM_VAL, // 001 0010 1 0000 + OP_SUB_S_IMM_VAL, // 001 0010 1 0001 + OP_SUB_S_IMM_VAL, // 001 0010 1 0010 + OP_SUB_S_IMM_VAL, // 001 0010 1 0011 + OP_SUB_S_IMM_VAL, // 001 0010 1 0100 + OP_SUB_S_IMM_VAL, // 001 0010 1 0101 + OP_SUB_S_IMM_VAL, // 001 0010 1 0110 + OP_SUB_S_IMM_VAL, // 001 0010 1 0111 + OP_SUB_S_IMM_VAL, // 001 0010 1 1000 + OP_SUB_S_IMM_VAL, // 001 0010 1 1001 + OP_SUB_S_IMM_VAL, // 001 0010 1 1010 + OP_SUB_S_IMM_VAL, // 001 0010 1 1011 + OP_SUB_S_IMM_VAL, // 001 0010 1 1100 + OP_SUB_S_IMM_VAL, // 001 0010 1 1101 + OP_SUB_S_IMM_VAL, // 001 0010 1 1110 + OP_SUB_S_IMM_VAL, // 001 0010 1 1111 +//------------------------------------------ + OP_RSB_IMM_VAL, // 001 0011 0 0000 + OP_RSB_IMM_VAL, // 001 0011 0 0001 + OP_RSB_IMM_VAL, // 001 0011 0 0010 + OP_RSB_IMM_VAL, // 001 0011 0 0011 + OP_RSB_IMM_VAL, // 001 0011 0 0100 + OP_RSB_IMM_VAL, // 001 0011 0 0101 + OP_RSB_IMM_VAL, // 001 0011 0 0110 + OP_RSB_IMM_VAL, // 001 0011 0 0111 + OP_RSB_IMM_VAL, // 001 0011 0 1000 + OP_RSB_IMM_VAL, // 001 0011 0 1001 + OP_RSB_IMM_VAL, // 001 0011 0 1010 + OP_RSB_IMM_VAL, // 001 0011 0 1011 + OP_RSB_IMM_VAL, // 001 0011 0 1100 + OP_RSB_IMM_VAL, // 001 0011 0 1101 + OP_RSB_IMM_VAL, // 001 0011 0 1110 + OP_RSB_IMM_VAL, // 001 0011 0 1111 + + OP_RSB_S_IMM_VAL, // 001 0011 1 0000 + OP_RSB_S_IMM_VAL, // 001 0011 1 0001 + OP_RSB_S_IMM_VAL, // 001 0011 1 0010 + OP_RSB_S_IMM_VAL, // 001 0011 1 0011 + OP_RSB_S_IMM_VAL, // 001 0011 1 0100 + OP_RSB_S_IMM_VAL, // 001 0011 1 0101 + OP_RSB_S_IMM_VAL, // 001 0011 1 0110 + OP_RSB_S_IMM_VAL, // 001 0011 1 0111 + OP_RSB_S_IMM_VAL, // 001 0011 1 1000 + OP_RSB_S_IMM_VAL, // 001 0011 1 1001 + OP_RSB_S_IMM_VAL, // 001 0011 1 1010 + OP_RSB_S_IMM_VAL, // 001 0011 1 1011 + OP_RSB_S_IMM_VAL, // 001 0011 1 1100 + OP_RSB_S_IMM_VAL, // 001 0011 1 1101 + OP_RSB_S_IMM_VAL, // 001 0011 1 1110 + OP_RSB_S_IMM_VAL, // 001 0011 1 1111 +//------------------------------------------ + OP_ADD_IMM_VAL, // 001 0100 0 0000 + OP_ADD_IMM_VAL, // 001 0100 0 0001 + OP_ADD_IMM_VAL, // 001 0100 0 0010 + OP_ADD_IMM_VAL, // 001 0100 0 0011 + OP_ADD_IMM_VAL, // 001 0100 0 0100 + OP_ADD_IMM_VAL, // 001 0100 0 0101 + OP_ADD_IMM_VAL, // 001 0100 0 0110 + OP_ADD_IMM_VAL, // 001 0100 0 0111 + OP_ADD_IMM_VAL, // 001 0100 0 1000 + OP_ADD_IMM_VAL, // 001 0100 0 1001 + OP_ADD_IMM_VAL, // 001 0100 0 1010 + OP_ADD_IMM_VAL, // 001 0100 0 1011 + OP_ADD_IMM_VAL, // 001 0100 0 1100 + OP_ADD_IMM_VAL, // 001 0100 0 1101 + OP_ADD_IMM_VAL, // 001 0100 0 1110 + OP_ADD_IMM_VAL, // 001 0100 0 1111 + + OP_ADD_S_IMM_VAL, // 001 0100 1 0000 + OP_ADD_S_IMM_VAL, // 001 0100 1 0001 + OP_ADD_S_IMM_VAL, // 001 0100 1 0010 + OP_ADD_S_IMM_VAL, // 001 0100 1 0011 + OP_ADD_S_IMM_VAL, // 001 0100 1 0100 + OP_ADD_S_IMM_VAL, // 001 0100 1 0101 + OP_ADD_S_IMM_VAL, // 001 0100 1 0110 + OP_ADD_S_IMM_VAL, // 001 0100 1 0111 + OP_ADD_S_IMM_VAL, // 001 0100 1 1000 + OP_ADD_S_IMM_VAL, // 001 0100 1 1001 + OP_ADD_S_IMM_VAL, // 001 0100 1 1010 + OP_ADD_S_IMM_VAL, // 001 0100 1 1011 + OP_ADD_S_IMM_VAL, // 001 0100 1 1100 + OP_ADD_S_IMM_VAL, // 001 0100 1 1101 + OP_ADD_S_IMM_VAL, // 001 0100 1 1110 + OP_ADD_S_IMM_VAL, // 001 0100 1 1111 +//------------------------------------------ + OP_ADC_IMM_VAL, // 001 0101 0 0000 + OP_ADC_IMM_VAL, // 001 0101 0 0001 + OP_ADC_IMM_VAL, // 001 0101 0 0010 + OP_ADC_IMM_VAL, // 001 0101 0 0011 + OP_ADC_IMM_VAL, // 001 0101 0 0100 + OP_ADC_IMM_VAL, // 001 0101 0 0101 + OP_ADC_IMM_VAL, // 001 0101 0 0110 + OP_ADC_IMM_VAL, // 001 0101 0 0111 + OP_ADC_IMM_VAL, // 001 0101 0 1000 + OP_ADC_IMM_VAL, // 001 0101 0 1001 + OP_ADC_IMM_VAL, // 001 0101 0 1010 + OP_ADC_IMM_VAL, // 001 0101 0 1011 + OP_ADC_IMM_VAL, // 001 0101 0 1100 + OP_ADC_IMM_VAL, // 001 0101 0 1101 + OP_ADC_IMM_VAL, // 001 0101 0 1110 + OP_ADC_IMM_VAL, // 001 0101 0 1111 + + OP_ADC_S_IMM_VAL, // 001 0101 1 0000 + OP_ADC_S_IMM_VAL, // 001 0101 1 0001 + OP_ADC_S_IMM_VAL, // 001 0101 1 0010 + OP_ADC_S_IMM_VAL, // 001 0101 1 0011 + OP_ADC_S_IMM_VAL, // 001 0101 1 0100 + OP_ADC_S_IMM_VAL, // 001 0101 1 0101 + OP_ADC_S_IMM_VAL, // 001 0101 1 0110 + OP_ADC_S_IMM_VAL, // 001 0101 1 0111 + OP_ADC_S_IMM_VAL, // 001 0101 1 1000 + OP_ADC_S_IMM_VAL, // 001 0101 1 1001 + OP_ADC_S_IMM_VAL, // 001 0101 1 1010 + OP_ADC_S_IMM_VAL, // 001 0101 1 1011 + OP_ADC_S_IMM_VAL, // 001 0101 1 1100 + OP_ADC_S_IMM_VAL, // 001 0101 1 1101 + OP_ADC_S_IMM_VAL, // 001 0101 1 1110 + OP_ADC_S_IMM_VAL, // 001 0101 1 1111 +//------------------------------------------ + OP_SBC_IMM_VAL, // 001 0110 0 0000 + OP_SBC_IMM_VAL, // 001 0110 0 0001 + OP_SBC_IMM_VAL, // 001 0110 0 0010 + OP_SBC_IMM_VAL, // 001 0110 0 0011 + OP_SBC_IMM_VAL, // 001 0110 0 0100 + OP_SBC_IMM_VAL, // 001 0110 0 0101 + OP_SBC_IMM_VAL, // 001 0110 0 0110 + OP_SBC_IMM_VAL, // 001 0110 0 0111 + OP_SBC_IMM_VAL, // 001 0110 0 1000 + OP_SBC_IMM_VAL, // 001 0110 0 1001 + OP_SBC_IMM_VAL, // 001 0110 0 1010 + OP_SBC_IMM_VAL, // 001 0110 0 1011 + OP_SBC_IMM_VAL, // 001 0110 0 1100 + OP_SBC_IMM_VAL, // 001 0110 0 1101 + OP_SBC_IMM_VAL, // 001 0110 0 1110 + OP_SBC_IMM_VAL, // 001 0110 0 1111 + + OP_SBC_S_IMM_VAL, // 001 0110 1 0000 + OP_SBC_S_IMM_VAL, // 001 0110 1 0001 + OP_SBC_S_IMM_VAL, // 001 0110 1 0010 + OP_SBC_S_IMM_VAL, // 001 0110 1 0011 + OP_SBC_S_IMM_VAL, // 001 0110 1 0100 + OP_SBC_S_IMM_VAL, // 001 0110 1 0101 + OP_SBC_S_IMM_VAL, // 001 0110 1 0110 + OP_SBC_S_IMM_VAL, // 001 0110 1 0111 + OP_SBC_S_IMM_VAL, // 001 0110 1 1000 + OP_SBC_S_IMM_VAL, // 001 0110 1 1001 + OP_SBC_S_IMM_VAL, // 001 0110 1 1010 + OP_SBC_S_IMM_VAL, // 001 0110 1 1011 + OP_SBC_S_IMM_VAL, // 001 0110 1 1100 + OP_SBC_S_IMM_VAL, // 001 0110 1 1101 + OP_SBC_S_IMM_VAL, // 001 0110 1 1110 + OP_SBC_S_IMM_VAL, // 001 0110 1 1111 +//------------------------------------------ + OP_RSC_IMM_VAL, // 001 0111 0 0000 + OP_RSC_IMM_VAL, // 001 0111 0 0001 + OP_RSC_IMM_VAL, // 001 0111 0 0010 + OP_RSC_IMM_VAL, // 001 0111 0 0011 + OP_RSC_IMM_VAL, // 001 0111 0 0100 + OP_RSC_IMM_VAL, // 001 0111 0 0101 + OP_RSC_IMM_VAL, // 001 0111 0 0110 + OP_RSC_IMM_VAL, // 001 0111 0 0111 + OP_RSC_IMM_VAL, // 001 0111 0 1000 + OP_RSC_IMM_VAL, // 001 0111 0 1001 + OP_RSC_IMM_VAL, // 001 0111 0 1010 + OP_RSC_IMM_VAL, // 001 0111 0 1011 + OP_RSC_IMM_VAL, // 001 0111 0 1100 + OP_RSC_IMM_VAL, // 001 0111 0 1101 + OP_RSC_IMM_VAL, // 001 0111 0 1110 + OP_RSC_IMM_VAL, // 001 0111 0 1111 + + OP_RSC_S_IMM_VAL, // 001 0111 1 0000 + OP_RSC_S_IMM_VAL, // 001 0111 1 0001 + OP_RSC_S_IMM_VAL, // 001 0111 1 0010 + OP_RSC_S_IMM_VAL, // 001 0111 1 0011 + OP_RSC_S_IMM_VAL, // 001 0111 1 0100 + OP_RSC_S_IMM_VAL, // 001 0111 1 0101 + OP_RSC_S_IMM_VAL, // 001 0111 1 0110 + OP_RSC_S_IMM_VAL, // 001 0111 1 0111 + OP_RSC_S_IMM_VAL, // 001 0111 1 1000 + OP_RSC_S_IMM_VAL, // 001 0111 1 1001 + OP_RSC_S_IMM_VAL, // 001 0111 1 1010 + OP_RSC_S_IMM_VAL, // 001 0111 1 1011 + OP_RSC_S_IMM_VAL, // 001 0111 1 1100 + OP_RSC_S_IMM_VAL, // 001 0111 1 1101 + OP_RSC_S_IMM_VAL, // 001 0111 1 1110 + OP_RSC_S_IMM_VAL, // 001 0111 1 1111 +//------------------------------------------ + OP_UND, // 001 1000 0 0000 + OP_UND, // 001 1000 0 0001 + OP_UND, // 001 1000 0 0010 + OP_UND, // 001 1000 0 0011 + OP_UND, // 001 1000 0 0100 + OP_UND, // 001 1000 0 0101 + OP_UND, // 001 1000 0 0110 + OP_UND, // 001 1000 0 0111 + OP_UND, // 001 1000 0 1000 + OP_UND, // 001 1000 0 1001 + OP_UND, // 001 1000 0 1010 + OP_UND, // 001 1000 0 1011 + OP_UND, // 001 1000 0 1100 + OP_UND, // 001 1000 0 1101 + OP_UND, // 001 1000 0 1110 + OP_UND, // 001 1000 0 1111 + + OP_TST_IMM_VAL, // 001 1000 1 0000 + OP_TST_IMM_VAL, // 001 1000 1 0001 + OP_TST_IMM_VAL, // 001 1000 1 0010 + OP_TST_IMM_VAL, // 001 1000 1 0011 + OP_TST_IMM_VAL, // 001 1000 1 0100 + OP_TST_IMM_VAL, // 001 1000 1 0101 + OP_TST_IMM_VAL, // 001 1000 1 0110 + OP_TST_IMM_VAL, // 001 1000 1 0111 + OP_TST_IMM_VAL, // 001 1000 1 1000 + OP_TST_IMM_VAL, // 001 1000 1 1001 + OP_TST_IMM_VAL, // 001 1000 1 1010 + OP_TST_IMM_VAL, // 001 1000 1 1011 + OP_TST_IMM_VAL, // 001 1000 1 1100 + OP_TST_IMM_VAL, // 001 1000 1 1101 + OP_TST_IMM_VAL, // 001 1000 1 1110 + OP_TST_IMM_VAL, // 001 1000 1 1111 +//------------------------------------------ + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0000 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0001 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0010 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0011 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0100 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0101 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0110 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 0111 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1000 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1001 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1010 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1011 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1100 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1101 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1110 + OP_MSR_CPSR_IMM_VAL, // 001 1001 0 1111 + + OP_TEQ_IMM_VAL, // 001 1001 1 0000 + OP_TEQ_IMM_VAL, // 001 1001 1 0001 + OP_TEQ_IMM_VAL, // 001 1001 1 0010 + OP_TEQ_IMM_VAL, // 001 1001 1 0011 + OP_TEQ_IMM_VAL, // 001 1001 1 0100 + OP_TEQ_IMM_VAL, // 001 1001 1 0101 + OP_TEQ_IMM_VAL, // 001 1001 1 0110 + OP_TEQ_IMM_VAL, // 001 1001 1 0111 + OP_TEQ_IMM_VAL, // 001 1001 1 1000 + OP_TEQ_IMM_VAL, // 001 1001 1 1001 + OP_TEQ_IMM_VAL, // 001 1001 1 1010 + OP_TEQ_IMM_VAL, // 001 1001 1 1011 + OP_TEQ_IMM_VAL, // 001 1001 1 1100 + OP_TEQ_IMM_VAL, // 001 1001 1 1101 + OP_TEQ_IMM_VAL, // 001 1001 1 1110 + OP_TEQ_IMM_VAL, // 001 1001 1 1111 +//------------------------------------------ + OP_UND, // 001 1010 0 0000 + OP_UND, // 001 1010 0 0001 + OP_UND, // 001 1010 0 0010 + OP_UND, // 001 1010 0 0011 + OP_UND, // 001 1010 0 0100 + OP_UND, // 001 1010 0 0101 + OP_UND, // 001 1010 0 0110 + OP_UND, // 001 1010 0 0111 + OP_UND, // 001 1010 0 1000 + OP_UND, // 001 1010 0 1001 + OP_UND, // 001 1010 0 1010 + OP_UND, // 001 1010 0 1011 + OP_UND, // 001 1010 0 1100 + OP_UND, // 001 1010 0 1101 + OP_UND, // 001 1010 0 1110 + OP_UND, // 001 1010 0 1111 + + OP_CMP_IMM_VAL, // 001 1010 1 0000 + OP_CMP_IMM_VAL, // 001 1010 1 0001 + OP_CMP_IMM_VAL, // 001 1010 1 0010 + OP_CMP_IMM_VAL, // 001 1010 1 0011 + OP_CMP_IMM_VAL, // 001 1010 1 0100 + OP_CMP_IMM_VAL, // 001 1010 1 0101 + OP_CMP_IMM_VAL, // 001 1010 1 0110 + OP_CMP_IMM_VAL, // 001 1010 1 0111 + OP_CMP_IMM_VAL, // 001 1010 1 1000 + OP_CMP_IMM_VAL, // 001 1010 1 1001 + OP_CMP_IMM_VAL, // 001 1010 1 1010 + OP_CMP_IMM_VAL, // 001 1010 1 1011 + OP_CMP_IMM_VAL, // 001 1010 1 1100 + OP_CMP_IMM_VAL, // 001 1010 1 1101 + OP_CMP_IMM_VAL, // 001 1010 1 1110 + OP_CMP_IMM_VAL, // 001 1010 1 1111 +//------------------------------------------ + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0000 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0001 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0010 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0011 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0100 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0101 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0110 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 0111 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1000 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1001 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1010 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1011 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1100 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1101 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1110 + OP_MSR_SPSR_IMM_VAL, // 001 1011 0 1111 + + OP_CMN_IMM_VAL, // 001 1011 1 0000 + OP_CMN_IMM_VAL, // 001 1011 1 0001 + OP_CMN_IMM_VAL, // 001 1011 1 0010 + OP_CMN_IMM_VAL, // 001 1011 1 0011 + OP_CMN_IMM_VAL, // 001 1011 1 0100 + OP_CMN_IMM_VAL, // 001 1011 1 0101 + OP_CMN_IMM_VAL, // 001 1011 1 0110 + OP_CMN_IMM_VAL, // 001 1011 1 0111 + OP_CMN_IMM_VAL, // 001 1011 1 1000 + OP_CMN_IMM_VAL, // 001 1011 1 1001 + OP_CMN_IMM_VAL, // 001 1011 1 1010 + OP_CMN_IMM_VAL, // 001 1011 1 1011 + OP_CMN_IMM_VAL, // 001 1011 1 1100 + OP_CMN_IMM_VAL, // 001 1011 1 1101 + OP_CMN_IMM_VAL, // 001 1011 1 1110 + OP_CMN_IMM_VAL, // 001 1011 1 1111 +//------------------------------------------ + OP_ORR_IMM_VAL, // 001 1100 0 0000 + OP_ORR_IMM_VAL, // 001 1100 0 0001 + OP_ORR_IMM_VAL, // 001 1100 0 0010 + OP_ORR_IMM_VAL, // 001 1100 0 0011 + OP_ORR_IMM_VAL, // 001 1100 0 0100 + OP_ORR_IMM_VAL, // 001 1100 0 0101 + OP_ORR_IMM_VAL, // 001 1100 0 0110 + OP_ORR_IMM_VAL, // 001 1100 0 0111 + OP_ORR_IMM_VAL, // 001 1100 0 1000 + OP_ORR_IMM_VAL, // 001 1100 0 1001 + OP_ORR_IMM_VAL, // 001 1100 0 1010 + OP_ORR_IMM_VAL, // 001 1100 0 1011 + OP_ORR_IMM_VAL, // 001 1100 0 1100 + OP_ORR_IMM_VAL, // 001 1100 0 1101 + OP_ORR_IMM_VAL, // 001 1100 0 1110 + OP_ORR_IMM_VAL, // 001 1100 0 1111 + + OP_ORR_S_IMM_VAL, // 001 1100 1 0000 + OP_ORR_S_IMM_VAL, // 001 1100 1 0001 + OP_ORR_S_IMM_VAL, // 001 1100 1 0010 + OP_ORR_S_IMM_VAL, // 001 1100 1 0011 + OP_ORR_S_IMM_VAL, // 001 1100 1 0100 + OP_ORR_S_IMM_VAL, // 001 1100 1 0101 + OP_ORR_S_IMM_VAL, // 001 1100 1 0110 + OP_ORR_S_IMM_VAL, // 001 1100 1 0111 + OP_ORR_S_IMM_VAL, // 001 1100 1 1000 + OP_ORR_S_IMM_VAL, // 001 1100 1 1001 + OP_ORR_S_IMM_VAL, // 001 1100 1 1010 + OP_ORR_S_IMM_VAL, // 001 1100 1 1011 + OP_ORR_S_IMM_VAL, // 001 1100 1 1100 + OP_ORR_S_IMM_VAL, // 001 1100 1 1101 + OP_ORR_S_IMM_VAL, // 001 1100 1 1110 + OP_ORR_S_IMM_VAL, // 001 1100 1 1111 +//------------------------------------------ + OP_MOV_IMM_VAL, // 001 1101 0 0000 + OP_MOV_IMM_VAL, // 001 1101 0 0001 + OP_MOV_IMM_VAL, // 001 1101 0 0010 + OP_MOV_IMM_VAL, // 001 1101 0 0011 + OP_MOV_IMM_VAL, // 001 1101 0 0100 + OP_MOV_IMM_VAL, // 001 1101 0 0101 + OP_MOV_IMM_VAL, // 001 1101 0 0110 + OP_MOV_IMM_VAL, // 001 1101 0 0111 + OP_MOV_IMM_VAL, // 001 1101 0 1000 + OP_MOV_IMM_VAL, // 001 1101 0 1001 + OP_MOV_IMM_VAL, // 001 1101 0 1010 + OP_MOV_IMM_VAL, // 001 1101 0 1011 + OP_MOV_IMM_VAL, // 001 1101 0 1100 + OP_MOV_IMM_VAL, // 001 1101 0 1101 + OP_MOV_IMM_VAL, // 001 1101 0 1110 + OP_MOV_IMM_VAL, // 001 1101 0 1111 + + OP_MOV_S_IMM_VAL, // 001 1101 1 0000 + OP_MOV_S_IMM_VAL, // 001 1101 1 0001 + OP_MOV_S_IMM_VAL, // 001 1101 1 0010 + OP_MOV_S_IMM_VAL, // 001 1101 1 0011 + OP_MOV_S_IMM_VAL, // 001 1101 1 0100 + OP_MOV_S_IMM_VAL, // 001 1101 1 0101 + OP_MOV_S_IMM_VAL, // 001 1101 1 0110 + OP_MOV_S_IMM_VAL, // 001 1101 1 0111 + OP_MOV_S_IMM_VAL, // 001 1101 1 1000 + OP_MOV_S_IMM_VAL, // 001 1101 1 1001 + OP_MOV_S_IMM_VAL, // 001 1101 1 1010 + OP_MOV_S_IMM_VAL, // 001 1101 1 1011 + OP_MOV_S_IMM_VAL, // 001 1101 1 1100 + OP_MOV_S_IMM_VAL, // 001 1101 1 1101 + OP_MOV_S_IMM_VAL, // 001 1101 1 1110 + OP_MOV_S_IMM_VAL, // 001 1101 1 1111 +//------------------------------------------ + OP_BIC_IMM_VAL, // 001 1110 0 0000 + OP_BIC_IMM_VAL, // 001 1110 0 0001 + OP_BIC_IMM_VAL, // 001 1110 0 0010 + OP_BIC_IMM_VAL, // 001 1110 0 0011 + OP_BIC_IMM_VAL, // 001 1110 0 0100 + OP_BIC_IMM_VAL, // 001 1110 0 0101 + OP_BIC_IMM_VAL, // 001 1110 0 0110 + OP_BIC_IMM_VAL, // 001 1110 0 0111 + OP_BIC_IMM_VAL, // 001 1110 0 1000 + OP_BIC_IMM_VAL, // 001 1110 0 1001 + OP_BIC_IMM_VAL, // 001 1110 0 1010 + OP_BIC_IMM_VAL, // 001 1110 0 1011 + OP_BIC_IMM_VAL, // 001 1110 0 1100 + OP_BIC_IMM_VAL, // 001 1110 0 1101 + OP_BIC_IMM_VAL, // 001 1110 0 1110 + OP_BIC_IMM_VAL, // 001 1110 0 1111 + + OP_BIC_S_IMM_VAL, // 001 1110 1 0000 + OP_BIC_S_IMM_VAL, // 001 1110 1 0001 + OP_BIC_S_IMM_VAL, // 001 1110 1 0010 + OP_BIC_S_IMM_VAL, // 001 1110 1 0011 + OP_BIC_S_IMM_VAL, // 001 1110 1 0100 + OP_BIC_S_IMM_VAL, // 001 1110 1 0101 + OP_BIC_S_IMM_VAL, // 001 1110 1 0110 + OP_BIC_S_IMM_VAL, // 001 1110 1 0111 + OP_BIC_S_IMM_VAL, // 001 1110 1 1000 + OP_BIC_S_IMM_VAL, // 001 1110 1 1001 + OP_BIC_S_IMM_VAL, // 001 1110 1 1010 + OP_BIC_S_IMM_VAL, // 001 1110 1 1011 + OP_BIC_S_IMM_VAL, // 001 1110 1 1100 + OP_BIC_S_IMM_VAL, // 001 1110 1 1101 + OP_BIC_S_IMM_VAL, // 001 1110 1 1110 + OP_BIC_S_IMM_VAL, // 001 1110 1 1111 +//------------------------------------------ + OP_MVN_IMM_VAL, // 001 1111 0 0000 + OP_MVN_IMM_VAL, // 001 1111 0 0001 + OP_MVN_IMM_VAL, // 001 1111 0 0010 + OP_MVN_IMM_VAL, // 001 1111 0 0011 + OP_MVN_IMM_VAL, // 001 1111 0 0100 + OP_MVN_IMM_VAL, // 001 1111 0 0101 + OP_MVN_IMM_VAL, // 001 1111 0 0110 + OP_MVN_IMM_VAL, // 001 1111 0 0111 + OP_MVN_IMM_VAL, // 001 1111 0 1000 + OP_MVN_IMM_VAL, // 001 1111 0 1001 + OP_MVN_IMM_VAL, // 001 1111 0 1010 + OP_MVN_IMM_VAL, // 001 1111 0 1011 + OP_MVN_IMM_VAL, // 001 1111 0 1100 + OP_MVN_IMM_VAL, // 001 1111 0 1101 + OP_MVN_IMM_VAL, // 001 1111 0 1110 + OP_MVN_IMM_VAL, // 001 1111 0 1111 + + OP_MVN_S_IMM_VAL, // 001 1111 1 0000 + OP_MVN_S_IMM_VAL, // 001 1111 1 0001 + OP_MVN_S_IMM_VAL, // 001 1111 1 0010 + OP_MVN_S_IMM_VAL, // 001 1111 1 0011 + OP_MVN_S_IMM_VAL, // 001 1111 1 0100 + OP_MVN_S_IMM_VAL, // 001 1111 1 0101 + OP_MVN_S_IMM_VAL, // 001 1111 1 0110 + OP_MVN_S_IMM_VAL, // 001 1111 1 0111 + OP_MVN_S_IMM_VAL, // 001 1111 1 1000 + OP_MVN_S_IMM_VAL, // 001 1111 1 1001 + OP_MVN_S_IMM_VAL, // 001 1111 1 1010 + OP_MVN_S_IMM_VAL, // 001 1111 1 1011 + OP_MVN_S_IMM_VAL, // 001 1111 1 1100 + OP_MVN_S_IMM_VAL, // 001 1111 1 1101 + OP_MVN_S_IMM_VAL, // 001 1111 1 1110 + OP_MVN_S_IMM_VAL, // 001 1111 1 1111 +//------------------------------------------ + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0000 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0001 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0010 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0011 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0100 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0101 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0110 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 0111 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1000 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1001 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1010 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1011 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1100 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1101 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1110 + OP_STR_M_IMM_OFF_POSTIND, //010 0000 0 1111 + + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0000 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0001 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0010 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0011 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0100 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0101 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0110 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 0111 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1000 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1001 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1010 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1011 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1100 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1101 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1110 + OP_LDR_M_IMM_OFF_POSTIND, //010 0000 1 1111 +//------------------------------------------ + OP_UND, //010 0001 0 0000 + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, +//------------------------------------------ + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0000 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0001 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0010 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0011 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0100 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0101 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0110 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 0111 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1000 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1001 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1010 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1011 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1100 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1101 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1110 + OP_STRB_M_IMM_OFF_POSTIND, //010 0010 0 1111 + + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0000 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0001 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0010 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0011 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0100 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0101 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0110 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 0111 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1000 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1001 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1010 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1011 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1100 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1101 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1110 + OP_LDRB_M_IMM_OFF_POSTIND, //010 0010 1 1111 +//------------------------------------------ + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_STRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 + OP_LDRBT_M_IMM_OFF_POSTIND, //010 0011 0 0000 +//------------------------------------------ + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND, //010 0100 0 0000 +//------------------------------------------ + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STR_P_IMM_OFF_POSTIND, //010 0100 0 0000 + + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 + OP_LDR_P_IMM_OFF_POSTIND2, //010 0100 0 0000 +//------------------------------------------ + OP_STRB_P_IMM_OFF_POSTIND, //010 0110 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRB_P_IMM_OFF_POSTIND, //010 0110 1 1111 +//------------------------------------------ + OP_STRBT_P_IMM_OFF_POSTIND, //010 0111 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_STRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0100 0 0000 + OP_LDRBT_P_IMM_OFF_POSTIND, //010 0111 1 1111 +//------------------------------------------ + OP_STR_M_IMM_OFF, //010 1000 0 0000 + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + OP_STR_M_IMM_OFF, + + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, + OP_LDR_M_IMM_OFF, //010 1000 1 1111 +//------------------------------------------ + OP_STR_M_IMM_OFF_PREIND, //010 1001 0 0000 + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + OP_STR_M_IMM_OFF_PREIND, + + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, + OP_LDR_M_IMM_OFF_PREIND, //010 1001 1 1111 +//------------------------------------------ + OP_STRB_M_IMM_OFF, //010 1010 0 0000 + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + OP_STRB_M_IMM_OFF, + + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, + OP_LDRB_M_IMM_OFF, //010 1010 1 1111 +//------------------------------------------ + OP_STRB_M_IMM_OFF_PREIND, //010 1011 0 0000 + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + OP_STRB_M_IMM_OFF_PREIND, + + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, + OP_LDRB_M_IMM_OFF_PREIND, //010 1011 1 1111 +//------------------------------------------ + OP_STR_P_IMM_OFF, //010 1100 0 0000 + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + OP_STR_P_IMM_OFF, + + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, + OP_LDR_P_IMM_OFF, //010 1100 1 1111 +//------------------------------------------ + OP_STR_P_IMM_OFF_PREIND, //010 1101 0 0000 + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + OP_STR_P_IMM_OFF_PREIND, + + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, + OP_LDR_P_IMM_OFF_PREIND, //010 1101 1 1111 +//------------------------------------------ + OP_STRB_P_IMM_OFF, //010 1110 0 0000 + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + OP_STRB_P_IMM_OFF, + + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, + OP_LDRB_P_IMM_OFF, //010 1110 1 1111 +//------------------------------------------ + OP_STRB_P_IMM_OFF_PREIND, //010 1111 0 0000 + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + OP_STRB_P_IMM_OFF_PREIND, + + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, + OP_LDRB_P_IMM_OFF_PREIND, //010 1111 1 1111 +//------------------------------------------ + OP_STR_M_LSL_IMM_OFF_POSTIND, //011 0000 0 0000 + OP_UND, + OP_STR_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STR_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STR_M_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_STR_M_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_STR_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STR_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STR_M_ROR_IMM_OFF_POSTIND, + OP_UND, + + OP_LDR_M_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_M_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_M_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_M_ROR_IMM_OFF_POSTIND, + OP_UND, //011 0000 1 1111 +//------------------------------------------ + OP_UND, //011 0001 0 0000 + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, //011 0001 1 1111 +//------------------------------------------ + OP_STRB_M_LSL_IMM_OFF_POSTIND, //011 0010 0 0000 + OP_UND, + OP_STRB_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_M_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_M_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_M_ROR_IMM_OFF_POSTIND, + OP_UND, + + OP_LDRB_M_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_M_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_M_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_M_ROR_IMM_OFF_POSTIND, + OP_UND, //011 0010 1 1111 +//------------------------------------------ + OP_STRBT_M_LSL_IMM_OFF_POSTIND, //011 0011 0 0000 + OP_UND, + OP_STRBT_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_M_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_M_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_M_ROR_IMM_OFF_POSTIND, + OP_UND, + + OP_LDRBT_M_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_M_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_M_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_M_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_M_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_M_ROR_IMM_OFF_POSTIND, + OP_UND, //011 0011 1 1111 +//------------------------------------------ + OP_STR_P_LSL_IMM_OFF_POSTIND, //011 0100 0 0000 + OP_UND, + OP_STR_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STR_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STR_P_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_STR_P_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_STR_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STR_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STR_P_ROR_IMM_OFF_POSTIND, + OP_UND, + + OP_LDR_P_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_P_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_P_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDR_P_ROR_IMM_OFF_POSTIND, + OP_UND, //011 0100 1 1111 +//------------------------------------------ + OP_UND, //011 0101 0 0000 + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, + OP_UND, //011 0101 1 1111 +//------------------------------------------ + OP_STRB_P_LSL_IMM_OFF_POSTIND, //011 0110 0 0000 + OP_UND, + OP_STRB_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_P_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_P_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STRB_P_ROR_IMM_OFF_POSTIND, + OP_UND, + + OP_LDRB_P_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_P_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_P_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRB_P_ROR_IMM_OFF_POSTIND, + OP_UND, +//------------------------------------------ + OP_STRBT_P_LSL_IMM_OFF_POSTIND, //011 0111 0 0000 + OP_UND, + OP_STRBT_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_P_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_P_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_STRBT_P_ROR_IMM_OFF_POSTIND, + OP_UND, + + OP_LDRBT_P_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_P_ROR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_P_LSL_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_P_LSR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_P_ASR_IMM_OFF_POSTIND, + OP_UND, + OP_LDRBT_P_ROR_IMM_OFF_POSTIND, + OP_UND, +//------------------------------------------ + OP_STR_M_LSL_IMM_OFF, //011 1000 0 0000 + OP_UND, + OP_STR_M_LSR_IMM_OFF, + OP_UND, + OP_STR_M_ASR_IMM_OFF, + OP_UND, + OP_STR_M_ROR_IMM_OFF, + OP_UND, + OP_STR_M_LSL_IMM_OFF, + OP_UND, + OP_STR_M_LSR_IMM_OFF, + OP_UND, + OP_STR_M_ASR_IMM_OFF, + OP_UND, + OP_STR_M_ROR_IMM_OFF, + OP_UND, + + OP_LDR_M_LSL_IMM_OFF, + OP_UND, + OP_LDR_M_LSR_IMM_OFF, + OP_UND, + OP_LDR_M_ASR_IMM_OFF, + OP_UND, + OP_LDR_M_ROR_IMM_OFF, + OP_UND, + OP_LDR_M_LSL_IMM_OFF, + OP_UND, + OP_LDR_M_LSR_IMM_OFF, + OP_UND, + OP_LDR_M_ASR_IMM_OFF, + OP_UND, + OP_LDR_M_ROR_IMM_OFF, + OP_UND, +//------------------------------------------ + OP_STR_M_LSL_IMM_OFF_PREIND, //011 1001 0 0000 + OP_UND, + OP_STR_M_LSR_IMM_OFF_PREIND, + OP_UND, + OP_STR_M_ASR_IMM_OFF_PREIND, + OP_UND, + OP_STR_M_ROR_IMM_OFF_PREIND, + OP_UND, + OP_STR_M_LSL_IMM_OFF_PREIND, + OP_UND, + OP_STR_M_LSR_IMM_OFF_PREIND, + OP_UND, + OP_STR_M_ASR_IMM_OFF_PREIND, + OP_UND, + OP_STR_M_ROR_IMM_OFF_PREIND, + OP_UND, + + OP_LDR_M_LSL_IMM_OFF_PREIND, + OP_UND, + OP_LDR_M_LSR_IMM_OFF_PREIND, + OP_UND, + OP_LDR_M_ASR_IMM_OFF_PREIND, + OP_UND, + OP_LDR_M_ROR_IMM_OFF_PREIND, + OP_UND, + OP_LDR_M_LSL_IMM_OFF_PREIND, + OP_UND, + OP_LDR_M_LSR_IMM_OFF_PREIND, + OP_UND, + OP_LDR_M_ASR_IMM_OFF_PREIND, + OP_UND, + OP_LDR_M_ROR_IMM_OFF_PREIND, + OP_UND, +//------------------------------------------ + OP_STRB_M_LSL_IMM_OFF, //011 1010 0 0000 + OP_UND, + OP_STRB_M_LSR_IMM_OFF, + OP_UND, + OP_STRB_M_ASR_IMM_OFF, + OP_UND, + OP_STRB_M_ROR_IMM_OFF, + OP_UND, + OP_STRB_M_LSL_IMM_OFF, + OP_UND, + OP_STRB_M_LSR_IMM_OFF, + OP_UND, + OP_STRB_M_ASR_IMM_OFF, + OP_UND, + OP_STRB_M_ROR_IMM_OFF, + OP_UND, + + OP_LDRB_M_LSL_IMM_OFF, + OP_UND, + OP_LDRB_M_LSR_IMM_OFF, + OP_UND, + OP_LDRB_M_ASR_IMM_OFF, + OP_UND, + OP_LDRB_M_ROR_IMM_OFF, + OP_UND, + OP_LDRB_M_LSL_IMM_OFF, + OP_UND, + OP_LDRB_M_LSR_IMM_OFF, + OP_UND, + OP_LDRB_M_ASR_IMM_OFF, + OP_UND, + OP_LDRB_M_ROR_IMM_OFF, + OP_UND, +//------------------------------------------ + OP_STRB_M_LSL_IMM_OFF_PREIND, //011 1011 0 0000 + OP_UND, + OP_STRB_M_LSR_IMM_OFF_PREIND, + OP_UND, + OP_STRB_M_ASR_IMM_OFF_PREIND, + OP_UND, + OP_STRB_M_ROR_IMM_OFF_PREIND, + OP_UND, + OP_STRB_M_LSL_IMM_OFF_PREIND, + OP_UND, + OP_STRB_M_LSR_IMM_OFF_PREIND, + OP_UND, + OP_STRB_M_ASR_IMM_OFF_PREIND, + OP_UND, + OP_STRB_M_ROR_IMM_OFF_PREIND, + OP_UND, + + OP_LDRB_M_LSL_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_M_LSR_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_M_ASR_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_M_ROR_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_M_LSL_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_M_LSR_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_M_ASR_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_M_ROR_IMM_OFF_PREIND, + OP_UND, +//------------------------------------------ + OP_STR_P_LSL_IMM_OFF, //011 1100 0 0000 + OP_UND, + OP_STR_P_LSR_IMM_OFF, + OP_UND, + OP_STR_P_ASR_IMM_OFF, + OP_UND, + OP_STR_P_ROR_IMM_OFF, + OP_UND, + OP_STR_P_LSL_IMM_OFF, + OP_UND, + OP_STR_P_LSR_IMM_OFF, + OP_UND, + OP_STR_P_ASR_IMM_OFF, + OP_UND, + OP_STR_P_ROR_IMM_OFF, + OP_UND, + + OP_LDR_P_LSL_IMM_OFF, + OP_UND, + OP_LDR_P_LSR_IMM_OFF, + OP_UND, + OP_LDR_P_ASR_IMM_OFF, + OP_UND, + OP_LDR_P_ROR_IMM_OFF, + OP_UND, + OP_LDR_P_LSL_IMM_OFF, + OP_UND, + OP_LDR_P_LSR_IMM_OFF, + OP_UND, + OP_LDR_P_ASR_IMM_OFF, + OP_UND, + OP_LDR_P_ROR_IMM_OFF, + OP_UND, +//------------------------------------------ + OP_STR_P_LSL_IMM_OFF_PREIND, //011 1101 0 0000 + OP_UND, + OP_STR_P_LSR_IMM_OFF_PREIND, + OP_UND, + OP_STR_P_ASR_IMM_OFF_PREIND, + OP_UND, + OP_STR_P_ROR_IMM_OFF_PREIND, + OP_UND, + OP_STR_P_LSL_IMM_OFF_PREIND, + OP_UND, + OP_STR_P_LSR_IMM_OFF_PREIND, + OP_UND, + OP_STR_P_ASR_IMM_OFF_PREIND, + OP_UND, + OP_STR_P_ROR_IMM_OFF_PREIND, + OP_UND, + + OP_LDR_P_LSL_IMM_OFF_PREIND, + OP_UND, + OP_LDR_P_LSR_IMM_OFF_PREIND, + OP_UND, + OP_LDR_P_ASR_IMM_OFF_PREIND, + OP_UND, + OP_LDR_P_ROR_IMM_OFF_PREIND, + OP_UND, + OP_LDR_P_LSL_IMM_OFF_PREIND, + OP_UND, + OP_LDR_P_LSR_IMM_OFF_PREIND, + OP_UND, + OP_LDR_P_ASR_IMM_OFF_PREIND, + OP_UND, + OP_LDR_P_ROR_IMM_OFF_PREIND, + OP_UND, +//------------------------------------------ + OP_STRB_P_LSL_IMM_OFF, //011 1110 0 0000 + OP_UND, + OP_STRB_P_LSR_IMM_OFF, + OP_UND, + OP_STRB_P_ASR_IMM_OFF, + OP_UND, + OP_STRB_P_ROR_IMM_OFF, + OP_UND, + OP_STRB_P_LSL_IMM_OFF, + OP_UND, + OP_STRB_P_LSR_IMM_OFF, + OP_UND, + OP_STRB_P_ASR_IMM_OFF, + OP_UND, + OP_STRB_P_ROR_IMM_OFF, + OP_UND, + + OP_LDRB_P_LSL_IMM_OFF, + OP_UND, + OP_LDRB_P_LSR_IMM_OFF, + OP_UND, + OP_LDRB_P_ASR_IMM_OFF, + OP_UND, + OP_LDRB_P_ROR_IMM_OFF, + OP_UND, + OP_LDRB_P_LSL_IMM_OFF, + OP_UND, + OP_LDRB_P_LSR_IMM_OFF, + OP_UND, + OP_LDRB_P_ASR_IMM_OFF, + OP_UND, + OP_LDRB_P_ROR_IMM_OFF, + OP_UND, +//------------------------------------------ + OP_STRB_P_LSL_IMM_OFF_PREIND, //011 1111 0 0000 + OP_UND, + OP_STRB_P_LSR_IMM_OFF_PREIND, + OP_UND, + OP_STRB_P_ASR_IMM_OFF_PREIND, + OP_UND, + OP_STRB_P_ROR_IMM_OFF_PREIND, + OP_UND, + OP_STRB_P_LSL_IMM_OFF_PREIND, + OP_UND, + OP_STRB_P_LSR_IMM_OFF_PREIND, + OP_UND, + OP_STRB_P_ASR_IMM_OFF_PREIND, + OP_UND, + OP_STRB_P_ROR_IMM_OFF_PREIND, + OP_UND, + + OP_LDRB_P_LSL_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_P_LSR_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_P_ASR_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_P_ROR_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_P_LSL_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_P_LSR_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_P_ASR_IMM_OFF_PREIND, + OP_UND, + OP_LDRB_P_ROR_IMM_OFF_PREIND, + OP_UND, //011 1111 1 1111 +//------------------------------------------ + OP_STMDA, //100 0000 0 0000 + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + OP_STMDA, + + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, + OP_LDMDA, +//------------------------------------------ + OP_STMDA_W, //100 0001 0 0000 + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + OP_STMDA_W, + + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, + OP_LDMDA_W, +//------------------------------------------ + OP_STMDA2, //100 0010 0 0000 + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + OP_STMDA2, + + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, + OP_LDMDA2, +//------------------------------------------ + OP_STMDA2_W, //100 0011 0 0000 + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + OP_STMDA2_W, + + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, + OP_LDMDA2_W, +//------------------------------------------ + OP_STMIA, //100 0100 0 0000 + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + OP_STMIA, + + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, + OP_LDMIA, +//------------------------------------------ + OP_STMIA_W, //100 0101 0 0000 + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + OP_STMIA_W, + + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, + OP_LDMIA_W, +//------------------------------------------ + OP_STMIA2, //100 0110 0 0000 + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + OP_STMIA2, + + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, + OP_LDMIA2, +//------------------------------------------ + OP_STMIA2_W, //100 0111 0 0000 + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + OP_STMIA2_W, + + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, + OP_LDMIA2_W, +//------------------------------------------ + OP_STMDB, //100 1000 0 0000 + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + OP_STMDB, + + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, + OP_LDMDB, +//------------------------------------------ + OP_STMDB_W, //100 1001 0 0000 + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + OP_STMDB_W, + + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, + OP_LDMDB_W, +//------------------------------------------ + OP_STMDB2, //100 1010 0 0000 + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + OP_STMDB2, + + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, + OP_LDMDB2, +//------------------------------------------ + OP_STMDB2_W, //100 1011 0 0000 + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + OP_STMDB2_W, + + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, + OP_LDMDB2_W, +//------------------------------------------ + + + OP_STMIB, //100 1100 0 0000 + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + OP_STMIB, + + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, + OP_LDMIB, +//------------------------------------------ + OP_STMIB_W, //100 1101 0 0000 + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + OP_STMIB_W, + + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, + OP_LDMIB_W, +//------------------------------------------ + OP_STMIB2, //100 1110 0 0000 + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + OP_STMIB2, + + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, + OP_LDMIB2, +//------------------------------------------ + OP_STMIB2_W, //100 1111 0 0000 + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + OP_STMIB2_W, + + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, + OP_LDMIB2_W, +//------------------------------------------ + OP_B, //101 0000 0 0000 + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, +//------------------------------------------ + OP_B, //101 0001 0 0000 + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, +//------------------------------------------ + OP_B, //101 0010 0 0000 + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, +//------------------------------------------ + OP_B, //101 0011 0 0000 + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, +//------------------------------------------ + OP_B, //101 0100 0 0000 + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, +//------------------------------------------ + OP_B, //101 0101 0 0000 + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, +//------------------------------------------ + OP_B, //101 0110 0 0000 + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, +//------------------------------------------ + OP_B, //101 0111 0 0000 + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, + OP_B, +//------------------------------------------ + OP_BL, //101 1000 0 0000 + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, +//------------------------------------------ + OP_BL, //101 1001 0 0000 + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, +//------------------------------------------ + OP_BL, //101 1010 0 0000 + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, +//------------------------------------------ + OP_BL, //101 1011 0 0000 + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, +//------------------------------------------ + OP_BL, //101 1100 0 0000 + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, +//------------------------------------------ + OP_BL, //101 1101 0 0000 + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, +//------------------------------------------ + OP_BL, //101 1110 0 0000 + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, +//------------------------------------------ + OP_BL, //101 1111 0 0000 + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, + OP_BL, +//------------------------------------------ + OP_STC_OPTION, //110 0000 0 0000 + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, +//------------------------------------------ + OP_STC_M_POSTIND, //110 0001 0 0000 + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, +//------------------------------------------ + OP_STC_OPTION, //110 0010 0 0000 + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, +//------------------------------------------ + OP_STC_M_POSTIND, //110 0011 0 0000 + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + OP_STC_M_POSTIND, + + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, + OP_LDC_M_POSTIND, +//------------------------------------------ + OP_STC_OPTION, //110 0100 0 0000 + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, +//------------------------------------------ + OP_STC_P_POSTIND, //110 0101 0 0000 + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, +//------------------------------------------ + OP_STC_OPTION, //110 0110 0 0000 + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + OP_STC_OPTION, + + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, + OP_LDC_OPTION, +//------------------------------------------ + OP_STC_P_POSTIND, //110 0111 0 0000 + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + OP_STC_P_POSTIND, + + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, + OP_LDC_P_POSTIND, +//------------------------------------------ + OP_STC_M_IMM_OFF, //110 1000 0 0000 + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, +//------------------------------------------ + OP_STC_M_PREIND, //110 1001 0 0000 + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, +//------------------------------------------ + OP_STC_M_IMM_OFF, //110 1010 0 0000 + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + OP_STC_M_IMM_OFF, + + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, + OP_LDC_M_IMM_OFF, +//------------------------------------------ + OP_STC_M_PREIND, //110 1011 0 0000 + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + OP_STC_M_PREIND, + + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, + OP_LDC_M_PREIND, +//------------------------------------------ + OP_STC_P_IMM_OFF, //110 1100 0 0000 + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, +//------------------------------------------ + OP_STC_P_PREIND, //110 1101 0 0000 + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, +//------------------------------------------ + OP_STC_P_IMM_OFF, //110 1110 0 0000 + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + OP_STC_P_IMM_OFF, + + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, + OP_LDC_P_IMM_OFF, +//------------------------------------------ + OP_STC_P_PREIND, //110 1111 0 0000 + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + OP_STC_P_PREIND, + + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, + OP_LDC_P_PREIND, +//------------------------------------------ + OP_CDP, //111 0000 0 0000 + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, +//--------------------------------------------- + OP_CDP, //111 0001 0 0000 + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, +//--------------------------------------------- + OP_CDP, //111 0010 0 0000 + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, +//--------------------------------------------- + OP_CDP, //111 0011 0 0000 + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, +//--------------------------------------------- + OP_CDP, //111 0100 0 0000 + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, +//--------------------------------------------- + OP_CDP, //111 0101 0 0000 + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, +//--------------------------------------------- + OP_CDP, //111 0110 0 0000 + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, +//--------------------------------------------- + OP_CDP, //111 0111 0 0000 + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + OP_CDP, + OP_MCR, + + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, + OP_CDP, + OP_MRC, +//--------------------------------------------- + OP_SWI, //111 1000 0 0000 + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, + OP_SWI, +}; + diff --git a/tags/release_0_5_0/desmume/src/mc.c b/tags/release_0_5_0/desmume/src/mc.c new file mode 100644 index 000000000..ac9f44941 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/mc.c @@ -0,0 +1,399 @@ +#include +#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; +} + diff --git a/tags/release_0_5_0/desmume/src/mc.h b/tags/release_0_5_0/desmume/src/mc.h new file mode 100644 index 000000000..bd8a5e138 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/mc.h @@ -0,0 +1,64 @@ +#ifndef __FW_H__ +#define __FW_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#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__*/ + diff --git a/tags/release_0_5_0/desmume/src/mem.h b/tags/release_0_5_0/desmume/src/mem.h new file mode 100644 index 000000000..b41bc9889 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/mem.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 +#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 diff --git a/tags/release_0_5_0/desmume/src/registers.h b/tags/release_0_5_0/desmume/src/registers.h new file mode 100644 index 000000000..952bfa9f9 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/registers.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/saves.c b/tags/release_0_5_0/desmume/src/saves.c new file mode 100644 index 000000000..2ac83a9c4 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/saves.c @@ -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 +#endif +#include +#include +#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 +} + diff --git a/tags/release_0_5_0/desmume/src/saves.h b/tags/release_0_5_0/desmume/src/saves.h new file mode 100644 index 000000000..4aa5ac455 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/saves.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/sndsdl.c b/tags/release_0_5_0/desmume/src/sndsdl.c new file mode 100644 index 000000000..342b77b49 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/sndsdl.c @@ -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 +#include + +#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) +{ +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/tags/release_0_5_0/desmume/src/sndsdl.h b/tags/release_0_5_0/desmume/src/sndsdl.h new file mode 100644 index 000000000..2561455b5 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/sndsdl.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/thumb_instructions.c b/tags/release_0_5_0/desmume/src/thumb_instructions.c new file mode 100644 index 000000000..2eeaff6c8 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/thumb_instructions.c @@ -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" diff --git a/tags/release_0_5_0/desmume/src/thumb_instructions.h b/tags/release_0_5_0/desmume/src/thumb_instructions.h new file mode 100644 index 000000000..87a8c22b3 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/thumb_instructions.h @@ -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 + diff --git a/tags/release_0_5_0/desmume/src/thumb_tabdef.inc b/tags/release_0_5_0/desmume/src/thumb_tabdef.inc new file mode 100644 index 000000000..1a9c53b03 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/thumb_tabdef.inc @@ -0,0 +1,1111 @@ +/* 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 +*/ + +TYPE_RETOUR (* CALLTYPE NOM_THUMB_TAB[1024])(PARAMETRES)={ + OP_LSL_0, //00 0000 0000 + OP_LSL, //00 0000 0001 + OP_LSL, //00 0000 0010 + OP_LSL, //00 0000 0011 + OP_LSL, //00 0000 0100 + OP_LSL, //00 0000 0101 + OP_LSL, //00 0000 0110 + OP_LSL, //00 0000 0111 + OP_LSL, //00 0000 1000 + OP_LSL, //00 0000 1001 + OP_LSL, //00 0000 1010 + OP_LSL, //00 0000 1011 + OP_LSL, //00 0000 1100 + OP_LSL, //00 0000 1101 + OP_LSL, //00 0000 1110 + OP_LSL, //00 0000 1111 + + OP_LSL, //00 0001 0000 + OP_LSL, //00 0001 0001 + OP_LSL, //00 0001 0010 + OP_LSL, //00 0001 0011 + OP_LSL, //00 0001 0100 + OP_LSL, //00 0001 0101 + OP_LSL, //00 0001 0110 + OP_LSL, //00 0001 0111 + OP_LSL, //00 0001 1000 + OP_LSL, //00 0001 1001 + OP_LSL, //00 0001 1010 + OP_LSL, //00 0001 1011 + OP_LSL, //00 0001 1100 + OP_LSL, //00 0001 1101 + OP_LSL, //00 0001 1110 + OP_LSL, //00 0001 1111 + + OP_LSR_0, //00 0010 0000 + OP_LSR, //00 0010 0001 + OP_LSR, //00 0010 0010 + OP_LSR, //00 0010 0011 + OP_LSR, //00 0010 0100 + OP_LSR, //00 0010 0101 + OP_LSR, //00 0010 0110 + OP_LSR, //00 0010 0111 + OP_LSR, //00 0010 1000 + OP_LSR, //00 0010 1001 + OP_LSR, //00 0010 1010 + OP_LSR, //00 0010 1011 + OP_LSR, //00 0010 1100 + OP_LSR, //00 0010 1101 + OP_LSR, //00 0010 1110 + OP_LSR, //00 0010 1111 + + OP_LSR, //00 0011 0000 + OP_LSR, //00 0011 0001 + OP_LSR, //00 0011 0010 + OP_LSR, //00 0011 0011 + OP_LSR, //00 0011 0100 + OP_LSR, //00 0011 0101 + OP_LSR, //00 0011 0110 + OP_LSR, //00 0011 0111 + OP_LSR, //00 0011 1000 + OP_LSR, //00 0011 1001 + OP_LSR, //00 0011 1010 + OP_LSR, //00 0011 1011 + OP_LSR, //00 0011 1100 + OP_LSR, //00 0011 1101 + OP_LSR, //00 0011 1110 + OP_LSR, //00 0011 1111 + + OP_ASR_0, //00 0100 0000 + OP_ASR, //00 0100 0001 + OP_ASR, //00 0100 0010 + OP_ASR, //00 0100 0011 + OP_ASR, //00 0100 0100 + OP_ASR, //00 0100 0101 + OP_ASR, //00 0100 0110 + OP_ASR, //00 0100 0111 + OP_ASR, //00 0100 1000 + OP_ASR, //00 0100 1001 + OP_ASR, //00 0100 1010 + OP_ASR, //00 0100 1011 + OP_ASR, //00 0100 1100 + OP_ASR, //00 0100 1101 + OP_ASR, //00 0100 1110 + OP_ASR, //00 0100 1111 + + OP_ASR, //00 0101 0000 + OP_ASR, //00 0101 0001 + OP_ASR, //00 0101 0010 + OP_ASR, //00 0101 0011 + OP_ASR, //00 0101 0100 + OP_ASR, //00 0101 0101 + OP_ASR, //00 0101 0110 + OP_ASR, //00 0101 0111 + OP_ASR, //00 0101 1000 + OP_ASR, //00 0101 1001 + OP_ASR, //00 0101 1010 + OP_ASR, //00 0101 1011 + OP_ASR, //00 0101 1100 + OP_ASR, //00 0101 1101 + OP_ASR, //00 0101 1110 + OP_ASR, //00 0101 1111 + + OP_ADD_REG, //00 0110 0000 + OP_ADD_REG, //00 0110 0001 + OP_ADD_REG, //00 0110 0010 + OP_ADD_REG, //00 0110 0011 + OP_ADD_REG, //00 0110 0100 + OP_ADD_REG, //00 0110 0101 + OP_ADD_REG, //00 0110 0110 + OP_ADD_REG, //00 0110 0111 + OP_SUB_REG, //00 0110 1000 + OP_SUB_REG, //00 0110 1001 + OP_SUB_REG, //00 0110 1010 + OP_SUB_REG, //00 0110 1011 + OP_SUB_REG, //00 0110 1100 + OP_SUB_REG, //00 0110 1101 + OP_SUB_REG, //00 0110 1110 + OP_SUB_REG, //00 0110 1111 + + OP_ADD_IMM3, //00 0111 0000 + OP_ADD_IMM3, //00 0111 0001 + OP_ADD_IMM3, //00 0111 0010 + OP_ADD_IMM3, //00 0111 0011 + OP_ADD_IMM3, //00 0111 0100 + OP_ADD_IMM3, //00 0111 0101 + OP_ADD_IMM3, //00 0111 0110 + OP_ADD_IMM3, //00 0111 0111 + OP_SUB_IMM3, //00 0111 1000 + OP_SUB_IMM3, //00 0111 1001 + OP_SUB_IMM3, //00 0111 1010 + OP_SUB_IMM3, //00 0111 1011 + OP_SUB_IMM3, //00 0111 1100 + OP_SUB_IMM3, //00 0111 1101 + OP_SUB_IMM3, //00 0111 1110 + OP_SUB_IMM3, //00 0111 1111 + + OP_MOV_IMM8, //00 1000 0000 + OP_MOV_IMM8, //00 1000 0001 + OP_MOV_IMM8, //00 1000 0010 + OP_MOV_IMM8, //00 1000 0011 + OP_MOV_IMM8, //00 1000 0100 + OP_MOV_IMM8, //00 1000 0101 + OP_MOV_IMM8, //00 1000 0110 + OP_MOV_IMM8, //00 1000 0111 + OP_MOV_IMM8, //00 1000 1000 + OP_MOV_IMM8, //00 1000 1001 + OP_MOV_IMM8, //00 1000 1010 + OP_MOV_IMM8, //00 1000 1011 + OP_MOV_IMM8, //00 1000 1100 + OP_MOV_IMM8, //00 1000 1101 + OP_MOV_IMM8, //00 1000 1110 + OP_MOV_IMM8, //00 1000 1111 + + OP_MOV_IMM8, //00 1001 0000 + OP_MOV_IMM8, //00 1001 0001 + OP_MOV_IMM8, //00 1001 0010 + OP_MOV_IMM8, //00 1001 0011 + OP_MOV_IMM8, //00 1001 0100 + OP_MOV_IMM8, //00 1001 0101 + OP_MOV_IMM8, //00 1001 0110 + OP_MOV_IMM8, //00 1001 0111 + OP_MOV_IMM8, //00 1001 1000 + OP_MOV_IMM8, //00 1001 1001 + OP_MOV_IMM8, //00 1001 1010 + OP_MOV_IMM8, //00 1001 1011 + OP_MOV_IMM8, //00 1001 1100 + OP_MOV_IMM8, //00 1001 1101 + OP_MOV_IMM8, //00 1001 1110 + OP_MOV_IMM8, //00 1001 1111 + + OP_CMP_IMM8, //00 1010 0000 + OP_CMP_IMM8, //00 1010 0001 + OP_CMP_IMM8, //00 1010 0010 + OP_CMP_IMM8, //00 1010 0011 + OP_CMP_IMM8, //00 1010 0100 + OP_CMP_IMM8, //00 1010 0101 + OP_CMP_IMM8, //00 1010 0110 + OP_CMP_IMM8, //00 1010 0111 + OP_CMP_IMM8, //00 1010 1000 + OP_CMP_IMM8, //00 1010 1001 + OP_CMP_IMM8, //00 1010 1010 + OP_CMP_IMM8, //00 1010 1011 + OP_CMP_IMM8, //00 1010 1100 + OP_CMP_IMM8, //00 1010 1101 + OP_CMP_IMM8, //00 1010 1110 + OP_CMP_IMM8, //00 1010 1111 + + OP_CMP_IMM8, //00 1011 0000 + OP_CMP_IMM8, //00 1011 0001 + OP_CMP_IMM8, //00 1011 0010 + OP_CMP_IMM8, //00 1011 0011 + OP_CMP_IMM8, //00 1011 0100 + OP_CMP_IMM8, //00 1011 0101 + OP_CMP_IMM8, //00 1011 0110 + OP_CMP_IMM8, //00 1011 0111 + OP_CMP_IMM8, //00 1011 1000 + OP_CMP_IMM8, //00 1011 1001 + OP_CMP_IMM8, //00 1011 1010 + OP_CMP_IMM8, //00 1011 1011 + OP_CMP_IMM8, //00 1011 1100 + OP_CMP_IMM8, //00 1011 1101 + OP_CMP_IMM8, //00 1011 1110 + OP_CMP_IMM8, //00 1011 1111 + + OP_ADD_IMM8, //00 1100 0000 + OP_ADD_IMM8, //00 1100 0001 + OP_ADD_IMM8, //00 1100 0010 + OP_ADD_IMM8, //00 1100 0011 + OP_ADD_IMM8, //00 1100 0100 + OP_ADD_IMM8, //00 1100 0101 + OP_ADD_IMM8, //00 1100 0110 + OP_ADD_IMM8, //00 1100 0111 + OP_ADD_IMM8, //00 1100 1000 + OP_ADD_IMM8, //00 1100 1001 + OP_ADD_IMM8, //00 1100 1010 + OP_ADD_IMM8, //00 1100 1011 + OP_ADD_IMM8, //00 1100 1100 + OP_ADD_IMM8, //00 1100 1101 + OP_ADD_IMM8, //00 1100 1110 + OP_ADD_IMM8, //00 1100 1111 + + OP_ADD_IMM8, //00 1101 0000 + OP_ADD_IMM8, //00 1101 0001 + OP_ADD_IMM8, //00 1101 0010 + OP_ADD_IMM8, //00 1101 0011 + OP_ADD_IMM8, //00 1101 0100 + OP_ADD_IMM8, //00 1101 0101 + OP_ADD_IMM8, //00 1101 0110 + OP_ADD_IMM8, //00 1101 0111 + OP_ADD_IMM8, //00 1101 1000 + OP_ADD_IMM8, //00 1101 1001 + OP_ADD_IMM8, //00 1101 1010 + OP_ADD_IMM8, //00 1101 1011 + OP_ADD_IMM8, //00 1101 1100 + OP_ADD_IMM8, //00 1101 1101 + OP_ADD_IMM8, //00 1101 1110 + OP_ADD_IMM8, //00 1101 1111 + + OP_SUB_IMM8, //00 1110 0000 + OP_SUB_IMM8, //00 1110 0001 + OP_SUB_IMM8, //00 1110 0010 + OP_SUB_IMM8, //00 1110 0011 + OP_SUB_IMM8, //00 1110 0100 + OP_SUB_IMM8, //00 1110 0101 + OP_SUB_IMM8, //00 1110 0110 + OP_SUB_IMM8, //00 1110 0111 + OP_SUB_IMM8, //00 1110 1000 + OP_SUB_IMM8, //00 1110 1001 + OP_SUB_IMM8, //00 1110 1010 + OP_SUB_IMM8, //00 1110 1011 + OP_SUB_IMM8, //00 1110 1100 + OP_SUB_IMM8, //00 1110 1101 + OP_SUB_IMM8, //00 1110 1110 + OP_SUB_IMM8, //00 1110 1111 + + OP_SUB_IMM8, //00 1111 0000 + OP_SUB_IMM8, //00 1111 0001 + OP_SUB_IMM8, //00 1111 0010 + OP_SUB_IMM8, //00 1111 0011 + OP_SUB_IMM8, //00 1111 0100 + OP_SUB_IMM8, //00 1111 0101 + OP_SUB_IMM8, //00 1111 0110 + OP_SUB_IMM8, //00 1111 0111 + OP_SUB_IMM8, //00 1111 1000 + OP_SUB_IMM8, //00 1111 1001 + OP_SUB_IMM8, //00 1111 1010 + OP_SUB_IMM8, //00 1111 1011 + OP_SUB_IMM8, //00 1111 1100 + OP_SUB_IMM8, //00 1111 1101 + OP_SUB_IMM8, //00 1111 1110 + OP_SUB_IMM8, //00 1111 1111 + + OP_AND, //01 0000 0000 + OP_EOR, //01 0000 0001 + OP_LSL_REG, //01 0000 0010 + OP_LSR_REG, //01 0000 0011 + OP_ASR_REG, //01 0000 0100 + OP_ADC_REG, //01 0000 0101 + OP_SBC_REG, //01 0000 0110 + OP_ROR_REG, //01 0000 0111 + OP_TST, //01 0000 1000 + OP_NEG, //01 0000 1001 + OP_CMP, //01 0000 1010 + OP_CMN, //01 0000 1011 + OP_ORR, //01 0000 1100 + OP_MUL_REG, //01 0000 1101 + OP_BIC, //01 0000 1110 + OP_MVN, //01 0000 1111 + + OP_ADD_SPE, //01 0001 0000 + OP_ADD_SPE, //01 0001 0001 + OP_ADD_SPE, //01 0001 0010 + OP_ADD_SPE, //01 0001 0011 + OP_CMP_SPE, //01 0001 0100 + OP_CMP_SPE, //01 0001 0101 + OP_CMP_SPE, //01 0001 0110 + OP_CMP_SPE, //01 0001 0111 + OP_MOV_SPE, //01 0001 1000 + OP_MOV_SPE, //01 0001 1001 + OP_MOV_SPE, //01 0001 1010 + OP_MOV_SPE, //01 0001 1011 + OP_BX_THUMB, //01 0001 1100 + OP_BX_THUMB, //01 0001 1101 + OP_BLX_THUMB, //01 0001 1110 + OP_BLX_THUMB, //01 0001 1111 + + OP_LDR_PCREL, //01 0010 0000 + OP_LDR_PCREL, //01 0010 0001 + OP_LDR_PCREL, //01 0010 0010 + OP_LDR_PCREL, //01 0010 0011 + OP_LDR_PCREL, //01 0010 0100 + OP_LDR_PCREL, //01 0010 0101 + OP_LDR_PCREL, //01 0010 0110 + OP_LDR_PCREL, //01 0010 0111 + OP_LDR_PCREL, //01 0010 1000 + OP_LDR_PCREL, //01 0010 1001 + OP_LDR_PCREL, //01 0010 1010 + OP_LDR_PCREL, //01 0010 1011 + OP_LDR_PCREL, //01 0010 1100 + OP_LDR_PCREL, //01 0010 1101 + OP_LDR_PCREL, //01 0010 1110 + OP_LDR_PCREL, //01 0010 1111 + + OP_LDR_PCREL, //01 0011 0000 + OP_LDR_PCREL, //01 0011 0001 + OP_LDR_PCREL, //01 0011 0010 + OP_LDR_PCREL, //01 0011 0011 + OP_LDR_PCREL, //01 0011 0100 + OP_LDR_PCREL, //01 0011 0101 + OP_LDR_PCREL, //01 0011 0110 + OP_LDR_PCREL, //01 0011 0111 + OP_LDR_PCREL, //01 0011 1000 + OP_LDR_PCREL, //01 0011 1001 + OP_LDR_PCREL, //01 0011 1010 + OP_LDR_PCREL, //01 0011 1011 + OP_LDR_PCREL, //01 0011 1100 + OP_LDR_PCREL, //01 0011 1101 + OP_LDR_PCREL, //01 0011 1110 + OP_LDR_PCREL, //01 0011 1111 + + OP_STR_REG_OFF, //01 0100 0000 + OP_STR_REG_OFF, //01 0100 0001 + OP_STR_REG_OFF, //01 0100 0010 + OP_STR_REG_OFF, //01 0100 0011 + OP_STR_REG_OFF, //01 0100 0100 + OP_STR_REG_OFF, //01 0100 0101 + OP_STR_REG_OFF, //01 0100 0110 + OP_STR_REG_OFF, //01 0100 0111 + OP_STRH_REG_OFF, //01 0100 1000 + OP_STRH_REG_OFF, //01 0100 1001 + OP_STRH_REG_OFF, //01 0100 1010 + OP_STRH_REG_OFF, //01 0100 1011 + OP_STRH_REG_OFF, //01 0100 1100 + OP_STRH_REG_OFF, //01 0100 1101 + OP_STRH_REG_OFF, //01 0100 1110 + OP_STRH_REG_OFF, //01 0100 1111 + + OP_STRB_REG_OFF, //01 0101 0000 + OP_STRB_REG_OFF, //01 0101 0001 + OP_STRB_REG_OFF, //01 0101 0010 + OP_STRB_REG_OFF, //01 0101 0011 + OP_STRB_REG_OFF, //01 0101 0100 + OP_STRB_REG_OFF, //01 0101 0101 + OP_STRB_REG_OFF, //01 0101 0110 + OP_STRB_REG_OFF, //01 0101 0111 + OP_LDRSB_REG_OFF, //01 0101 1000 + OP_LDRSB_REG_OFF, //01 0101 1001 + OP_LDRSB_REG_OFF, //01 0101 1010 + OP_LDRSB_REG_OFF, //01 0101 1011 + OP_LDRSB_REG_OFF, //01 0101 1100 + OP_LDRSB_REG_OFF, //01 0101 1101 + OP_LDRSB_REG_OFF, //01 0101 1110 + OP_LDRSB_REG_OFF, //01 0101 1111 + + OP_LDR_REG_OFF, //01 0110 0000 + OP_LDR_REG_OFF, //01 0110 0001 + OP_LDR_REG_OFF, //01 0110 0010 + OP_LDR_REG_OFF, //01 0110 0011 + OP_LDR_REG_OFF, //01 0110 0100 + OP_LDR_REG_OFF, //01 0110 0101 + OP_LDR_REG_OFF, //01 0110 0110 + OP_LDR_REG_OFF, //01 0110 0111 + OP_LDRH_REG_OFF, //01 0110 1000 + OP_LDRH_REG_OFF, //01 0110 1001 + OP_LDRH_REG_OFF, //01 0110 1010 + OP_LDRH_REG_OFF, //01 0110 1011 + OP_LDRH_REG_OFF, //01 0110 1100 + OP_LDRH_REG_OFF, //01 0110 1101 + OP_LDRH_REG_OFF, //01 0110 1110 + OP_LDRH_REG_OFF, //01 0110 1111 + + OP_LDRB_REG_OFF, //01 0111 0000 + OP_LDRB_REG_OFF, //01 0111 0001 + OP_LDRB_REG_OFF, //01 0111 0010 + OP_LDRB_REG_OFF, //01 0111 0011 + OP_LDRB_REG_OFF, //01 0111 0100 + OP_LDRB_REG_OFF, //01 0111 0101 + OP_LDRB_REG_OFF, //01 0111 0110 + OP_LDRB_REG_OFF, //01 0111 0111 + OP_LDRSH_REG_OFF, //01 0111 1000 + OP_LDRSH_REG_OFF, //01 0111 1001 + OP_LDRSH_REG_OFF, //01 0111 1010 + OP_LDRSH_REG_OFF, //01 0111 1011 + OP_LDRSH_REG_OFF, //01 0111 1100 + OP_LDRSH_REG_OFF, //01 0111 1101 + OP_LDRSH_REG_OFF, //01 0111 1110 + OP_LDRSH_REG_OFF, //01 0111 1111 + + OP_STR_IMM_OFF, //01 1000 0000 + OP_STR_IMM_OFF, //01 1000 0001 + OP_STR_IMM_OFF, //01 1000 0010 + OP_STR_IMM_OFF, //01 1000 0011 + OP_STR_IMM_OFF, //01 1000 0100 + OP_STR_IMM_OFF, //01 1000 0101 + OP_STR_IMM_OFF, //01 1000 0110 + OP_STR_IMM_OFF, //01 1000 0111 + OP_STR_IMM_OFF, //01 1000 1000 + OP_STR_IMM_OFF, //01 1000 1001 + OP_STR_IMM_OFF, //01 1000 1010 + OP_STR_IMM_OFF, //01 1000 1011 + OP_STR_IMM_OFF, //01 1000 1100 + OP_STR_IMM_OFF, //01 1000 1101 + OP_STR_IMM_OFF, //01 1000 1110 + OP_STR_IMM_OFF, //01 1000 1111 + + OP_STR_IMM_OFF, //01 1001 0000 + OP_STR_IMM_OFF, //01 1001 0001 + OP_STR_IMM_OFF, //01 1001 0010 + OP_STR_IMM_OFF, //01 1001 0011 + OP_STR_IMM_OFF, //01 1001 0100 + OP_STR_IMM_OFF, //01 1001 0101 + OP_STR_IMM_OFF, //01 1001 0110 + OP_STR_IMM_OFF, //01 1001 0111 + OP_STR_IMM_OFF, //01 1001 1000 + OP_STR_IMM_OFF, //01 1001 1001 + OP_STR_IMM_OFF, //01 1001 1010 + OP_STR_IMM_OFF, //01 1001 1011 + OP_STR_IMM_OFF, //01 1001 1100 + OP_STR_IMM_OFF, //01 1001 1101 + OP_STR_IMM_OFF, //01 1001 1110 + OP_STR_IMM_OFF, //01 1001 1111 + + OP_LDR_IMM_OFF, //01 1010 0000 + OP_LDR_IMM_OFF, //01 1010 0001 + OP_LDR_IMM_OFF, //01 1010 0010 + OP_LDR_IMM_OFF, //01 1010 0011 + OP_LDR_IMM_OFF, //01 1010 0100 + OP_LDR_IMM_OFF, //01 1010 0101 + OP_LDR_IMM_OFF, //01 1010 0110 + OP_LDR_IMM_OFF, //01 1010 0111 + OP_LDR_IMM_OFF, //01 1010 1000 + OP_LDR_IMM_OFF, //01 1010 1001 + OP_LDR_IMM_OFF, //01 1010 1010 + OP_LDR_IMM_OFF, //01 1010 1011 + OP_LDR_IMM_OFF, //01 1010 1100 + OP_LDR_IMM_OFF, //01 1010 1101 + OP_LDR_IMM_OFF, //01 1010 1110 + OP_LDR_IMM_OFF, //01 1010 1111 + + OP_LDR_IMM_OFF, //01 1011 0000 + OP_LDR_IMM_OFF, //01 1011 0001 + OP_LDR_IMM_OFF, //01 1011 0010 + OP_LDR_IMM_OFF, //01 1011 0011 + OP_LDR_IMM_OFF, //01 1011 0100 + OP_LDR_IMM_OFF, //01 1011 0101 + OP_LDR_IMM_OFF, //01 1011 0110 + OP_LDR_IMM_OFF, //01 1011 0111 + OP_LDR_IMM_OFF, //01 1011 1000 + OP_LDR_IMM_OFF, //01 1011 1001 + OP_LDR_IMM_OFF, //01 1011 1010 + OP_LDR_IMM_OFF, //01 1011 1011 + OP_LDR_IMM_OFF, //01 1011 1100 + OP_LDR_IMM_OFF, //01 1011 1101 + OP_LDR_IMM_OFF, //01 1011 1110 + OP_LDR_IMM_OFF, //01 1011 1111 + + OP_STRB_IMM_OFF, //01 1100 0000 + OP_STRB_IMM_OFF, //01 1100 0001 + OP_STRB_IMM_OFF, //01 1100 0010 + OP_STRB_IMM_OFF, //01 1100 0011 + OP_STRB_IMM_OFF, //01 1100 0100 + OP_STRB_IMM_OFF, //01 1100 0101 + OP_STRB_IMM_OFF, //01 1100 0110 + OP_STRB_IMM_OFF, //01 1100 0111 + OP_STRB_IMM_OFF, //01 1100 1000 + OP_STRB_IMM_OFF, //01 1100 1001 + OP_STRB_IMM_OFF, //01 1100 1010 + OP_STRB_IMM_OFF, //01 1100 1011 + OP_STRB_IMM_OFF, //01 1100 1100 + OP_STRB_IMM_OFF, //01 1100 1101 + OP_STRB_IMM_OFF, //01 1100 1110 + OP_STRB_IMM_OFF, //01 1100 1111 + + OP_STRB_IMM_OFF, //01 1101 0000 + OP_STRB_IMM_OFF, //01 1101 0001 + OP_STRB_IMM_OFF, //01 1101 0010 + OP_STRB_IMM_OFF, //01 1101 0011 + OP_STRB_IMM_OFF, //01 1101 0100 + OP_STRB_IMM_OFF, //01 1101 0101 + OP_STRB_IMM_OFF, //01 1101 0110 + OP_STRB_IMM_OFF, //01 1101 0111 + OP_STRB_IMM_OFF, //01 1101 1000 + OP_STRB_IMM_OFF, //01 1101 1001 + OP_STRB_IMM_OFF, //01 1101 1010 + OP_STRB_IMM_OFF, //01 1101 1011 + OP_STRB_IMM_OFF, //01 1101 1100 + OP_STRB_IMM_OFF, //01 1101 1101 + OP_STRB_IMM_OFF, //01 1101 1110 + OP_STRB_IMM_OFF, //01 1101 1111 + + OP_LDRB_IMM_OFF, //01 1110 0000 + OP_LDRB_IMM_OFF, //01 1110 0001 + OP_LDRB_IMM_OFF, //01 1110 0010 + OP_LDRB_IMM_OFF, //01 1110 0011 + OP_LDRB_IMM_OFF, //01 1110 0100 + OP_LDRB_IMM_OFF, //01 1110 0101 + OP_LDRB_IMM_OFF, //01 1110 0110 + OP_LDRB_IMM_OFF, //01 1110 0111 + OP_LDRB_IMM_OFF, //01 1110 1000 + OP_LDRB_IMM_OFF, //01 1110 1001 + OP_LDRB_IMM_OFF, //01 1110 1010 + OP_LDRB_IMM_OFF, //01 1110 1011 + OP_LDRB_IMM_OFF, //01 1110 1100 + OP_LDRB_IMM_OFF, //01 1110 1101 + OP_LDRB_IMM_OFF, //01 1110 1110 + OP_LDRB_IMM_OFF, //01 1110 1111 + + OP_LDRB_IMM_OFF, //01 1111 0000 + OP_LDRB_IMM_OFF, //01 1111 0001 + OP_LDRB_IMM_OFF, //01 1111 0010 + OP_LDRB_IMM_OFF, //01 1111 0011 + OP_LDRB_IMM_OFF, //01 1111 0100 + OP_LDRB_IMM_OFF, //01 1111 0101 + OP_LDRB_IMM_OFF, //01 1111 0110 + OP_LDRB_IMM_OFF, //01 1111 0111 + OP_LDRB_IMM_OFF, //01 1111 1000 + OP_LDRB_IMM_OFF, //01 1111 1001 + OP_LDRB_IMM_OFF, //01 1111 1010 + OP_LDRB_IMM_OFF, //01 1111 1011 + OP_LDRB_IMM_OFF, //01 1111 1100 + OP_LDRB_IMM_OFF, //01 1111 1101 + OP_LDRB_IMM_OFF, //01 1111 1110 + OP_LDRB_IMM_OFF, //01 1111 1111 + + OP_STRH_IMM_OFF, //10 0000 0000 + OP_STRH_IMM_OFF, //10 0000 0001 + OP_STRH_IMM_OFF, //10 0000 0010 + OP_STRH_IMM_OFF, //10 0000 0011 + OP_STRH_IMM_OFF, //10 0000 0100 + OP_STRH_IMM_OFF, //10 0000 0101 + OP_STRH_IMM_OFF, //10 0000 0110 + OP_STRH_IMM_OFF, //10 0000 0111 + OP_STRH_IMM_OFF, //10 0000 1000 + OP_STRH_IMM_OFF, //10 0000 1001 + OP_STRH_IMM_OFF, //10 0000 1010 + OP_STRH_IMM_OFF, //10 0000 1011 + OP_STRH_IMM_OFF, //10 0000 1100 + OP_STRH_IMM_OFF, //10 0000 1101 + OP_STRH_IMM_OFF, //10 0000 1110 + OP_STRH_IMM_OFF, //10 0000 1111 + + OP_STRH_IMM_OFF, //10 0001 0000 + OP_STRH_IMM_OFF, //10 0001 0001 + OP_STRH_IMM_OFF, //10 0001 0010 + OP_STRH_IMM_OFF, //10 0001 0011 + OP_STRH_IMM_OFF, //10 0001 0100 + OP_STRH_IMM_OFF, //10 0001 0101 + OP_STRH_IMM_OFF, //10 0001 0110 + OP_STRH_IMM_OFF, //10 0001 0111 + OP_STRH_IMM_OFF, //10 0001 1000 + OP_STRH_IMM_OFF, //10 0001 1001 + OP_STRH_IMM_OFF, //10 0001 1010 + OP_STRH_IMM_OFF, //10 0001 1011 + OP_STRH_IMM_OFF, //10 0001 1100 + OP_STRH_IMM_OFF, //10 0001 1101 + OP_STRH_IMM_OFF, //10 0001 1110 + OP_STRH_IMM_OFF, //10 0001 1111 + + OP_LDRH_IMM_OFF, //10 0010 0000 + OP_LDRH_IMM_OFF, //10 0010 0001 + OP_LDRH_IMM_OFF, //10 0010 0010 + OP_LDRH_IMM_OFF, //10 0010 0011 + OP_LDRH_IMM_OFF, //10 0010 0100 + OP_LDRH_IMM_OFF, //10 0010 0101 + OP_LDRH_IMM_OFF, //10 0010 0110 + OP_LDRH_IMM_OFF, //10 0010 0111 + OP_LDRH_IMM_OFF, //10 0010 1000 + OP_LDRH_IMM_OFF, //10 0010 1001 + OP_LDRH_IMM_OFF, //10 0010 1010 + OP_LDRH_IMM_OFF, //10 0010 1011 + OP_LDRH_IMM_OFF, //10 0010 1100 + OP_LDRH_IMM_OFF, //10 0010 1101 + OP_LDRH_IMM_OFF, //10 0010 1110 + OP_LDRH_IMM_OFF, //10 0010 1111 + + OP_LDRH_IMM_OFF, //10 0011 0000 + OP_LDRH_IMM_OFF, //10 0011 0001 + OP_LDRH_IMM_OFF, //10 0011 0010 + OP_LDRH_IMM_OFF, //10 0011 0011 + OP_LDRH_IMM_OFF, //10 0011 0100 + OP_LDRH_IMM_OFF, //10 0011 0101 + OP_LDRH_IMM_OFF, //10 0011 0110 + OP_LDRH_IMM_OFF, //10 0011 0111 + OP_LDRH_IMM_OFF, //10 0011 1000 + OP_LDRH_IMM_OFF, //10 0011 1001 + OP_LDRH_IMM_OFF, //10 0011 1010 + OP_LDRH_IMM_OFF, //10 0011 1011 + OP_LDRH_IMM_OFF, //10 0011 1100 + OP_LDRH_IMM_OFF, //10 0011 1101 + OP_LDRH_IMM_OFF, //10 0011 1110 + OP_LDRH_IMM_OFF, //10 0011 1111 + + OP_STR_SPREL, //10 0100 0000 + OP_STR_SPREL, //10 0100 0001 + OP_STR_SPREL, //10 0100 0010 + OP_STR_SPREL, //10 0100 0011 + OP_STR_SPREL, //10 0100 0100 + OP_STR_SPREL, //10 0100 0101 + OP_STR_SPREL, //10 0100 0110 + OP_STR_SPREL, //10 0100 0111 + OP_STR_SPREL, //10 0100 1000 + OP_STR_SPREL, //10 0100 1001 + OP_STR_SPREL, //10 0100 1010 + OP_STR_SPREL, //10 0100 1011 + OP_STR_SPREL, //10 0100 1100 + OP_STR_SPREL, //10 0100 1101 + OP_STR_SPREL, //10 0100 1110 + OP_STR_SPREL, //10 0100 1111 + + OP_STR_SPREL, //10 0101 0000 + OP_STR_SPREL, //10 0101 0001 + OP_STR_SPREL, //10 0101 0010 + OP_STR_SPREL, //10 0101 0011 + OP_STR_SPREL, //10 0101 0100 + OP_STR_SPREL, //10 0101 0101 + OP_STR_SPREL, //10 0101 0110 + OP_STR_SPREL, //10 0101 0111 + OP_STR_SPREL, //10 0101 1000 + OP_STR_SPREL, //10 0101 1001 + OP_STR_SPREL, //10 0101 1010 + OP_STR_SPREL, //10 0101 1011 + OP_STR_SPREL, //10 0101 1100 + OP_STR_SPREL, //10 0101 1101 + OP_STR_SPREL, //10 0101 1110 + OP_STR_SPREL, //10 0101 1111 + + OP_LDR_SPREL, //10 0110 0000 + OP_LDR_SPREL, //10 0110 0001 + OP_LDR_SPREL, //10 0110 0010 + OP_LDR_SPREL, //10 0110 0011 + OP_LDR_SPREL, //10 0110 0100 + OP_LDR_SPREL, //10 0110 0101 + OP_LDR_SPREL, //10 0110 0110 + OP_LDR_SPREL, //10 0110 0111 + OP_LDR_SPREL, //10 0110 1000 + OP_LDR_SPREL, //10 0110 1001 + OP_LDR_SPREL, //10 0110 1010 + OP_LDR_SPREL, //10 0110 1011 + OP_LDR_SPREL, //10 0110 1100 + OP_LDR_SPREL, //10 0110 1101 + OP_LDR_SPREL, //10 0110 1110 + OP_LDR_SPREL, //10 0110 1111 + + OP_LDR_SPREL, //10 0111 0000 + OP_LDR_SPREL, //10 0111 0001 + OP_LDR_SPREL, //10 0111 0010 + OP_LDR_SPREL, //10 0111 0011 + OP_LDR_SPREL, //10 0111 0100 + OP_LDR_SPREL, //10 0111 0101 + OP_LDR_SPREL, //10 0111 0110 + OP_LDR_SPREL, //10 0111 0111 + OP_LDR_SPREL, //10 0111 1000 + OP_LDR_SPREL, //10 0111 1001 + OP_LDR_SPREL, //10 0111 1010 + OP_LDR_SPREL, //10 0111 1011 + OP_LDR_SPREL, //10 0111 1100 + OP_LDR_SPREL, //10 0111 1101 + OP_LDR_SPREL, //10 0111 1110 + OP_LDR_SPREL, //10 0111 1111 + + OP_ADD_2PC, //10 1000 0000 + OP_ADD_2PC, //10 1000 0001 + OP_ADD_2PC, //10 1000 0010 + OP_ADD_2PC, //10 1000 0011 + OP_ADD_2PC, //10 1000 0100 + OP_ADD_2PC, //10 1000 0101 + OP_ADD_2PC, //10 1000 0110 + OP_ADD_2PC, //10 1000 0111 + OP_ADD_2PC, //10 1000 1000 + OP_ADD_2PC, //10 1000 1001 + OP_ADD_2PC, //10 1000 1010 + OP_ADD_2PC, //10 1000 1011 + OP_ADD_2PC, //10 1000 1100 + OP_ADD_2PC, //10 1000 1101 + OP_ADD_2PC, //10 1000 1110 + OP_ADD_2PC, //10 1000 1111 + + OP_ADD_2PC, //10 1001 0000 + OP_ADD_2PC, //10 1001 0001 + OP_ADD_2PC, //10 1001 0010 + OP_ADD_2PC, //10 1001 0011 + OP_ADD_2PC, //10 1001 0100 + OP_ADD_2PC, //10 1001 0101 + OP_ADD_2PC, //10 1001 0110 + OP_ADD_2PC, //10 1001 0111 + OP_ADD_2PC, //10 1001 1000 + OP_ADD_2PC, //10 1001 1001 + OP_ADD_2PC, //10 1001 1010 + OP_ADD_2PC, //10 1001 1011 + OP_ADD_2PC, //10 1001 1100 + OP_ADD_2PC, //10 1001 1101 + OP_ADD_2PC, //10 1001 1110 + OP_ADD_2PC, //10 1001 1111 + + OP_ADD_2SP, //10 1010 0000 + OP_ADD_2SP, //10 1010 0001 + OP_ADD_2SP, //10 1010 0010 + OP_ADD_2SP, //10 1010 0011 + OP_ADD_2SP, //10 1010 0100 + OP_ADD_2SP, //10 1010 0101 + OP_ADD_2SP, //10 1010 0110 + OP_ADD_2SP, //10 1010 0111 + OP_ADD_2SP, //10 1010 1000 + OP_ADD_2SP, //10 1010 1001 + OP_ADD_2SP, //10 1010 1010 + OP_ADD_2SP, //10 1010 1011 + OP_ADD_2SP, //10 1010 1100 + OP_ADD_2SP, //10 1010 1101 + OP_ADD_2SP, //10 1010 1110 + OP_ADD_2SP, //10 1010 1111 + + OP_ADD_2SP, //10 1011 0000 + OP_ADD_2SP, //10 1011 0001 + OP_ADD_2SP, //10 1011 0010 + OP_ADD_2SP, //10 1011 0011 + OP_ADD_2SP, //10 1011 0100 + OP_ADD_2SP, //10 1011 0101 + OP_ADD_2SP, //10 1011 0110 + OP_ADD_2SP, //10 1011 0111 + OP_ADD_2SP, //10 1011 1000 + OP_ADD_2SP, //10 1011 1001 + OP_ADD_2SP, //10 1011 1010 + OP_ADD_2SP, //10 1011 1011 + OP_ADD_2SP, //10 1011 1100 + OP_ADD_2SP, //10 1011 1101 + OP_ADD_2SP, //10 1011 1110 + OP_ADD_2SP, //10 1011 1111 + + OP_ADJUST_P_SP, //10 1100 0000 + OP_ADJUST_P_SP, //10 1100 0001 + OP_ADJUST_M_SP, //10 1100 0010 + OP_ADJUST_M_SP, //10 1100 0011 + OP_UND_THUMB, //10 1100 0100 + OP_UND_THUMB, //10 1100 0101 + OP_UND_THUMB, //10 1100 0110 + OP_UND_THUMB, //10 1100 0111 + OP_UND_THUMB, //10 1100 1000 + OP_UND_THUMB, //10 1100 1001 + OP_UND_THUMB, //10 1100 1010 + OP_UND_THUMB, //10 1100 1011 + OP_UND_THUMB, //10 1100 1100 + OP_UND_THUMB, //10 1100 1101 + OP_UND_THUMB, //10 1100 1110 + OP_UND_THUMB, //10 1100 1111 + + OP_PUSH, //10 1101 0000 + OP_PUSH, //10 1101 0001 + OP_PUSH, //10 1101 0010 + OP_PUSH, //10 1101 0011 + OP_PUSH_LR, //10 1101 0100 + OP_PUSH_LR, //10 1101 0101 + OP_PUSH_LR, //10 1101 0110 + OP_PUSH_LR, //10 1101 0111 + OP_UND_THUMB, //10 1101 1000 + OP_UND_THUMB, //10 1101 1001 + OP_UND_THUMB, //10 1101 1010 + OP_UND_THUMB, //10 1101 1011 + OP_UND_THUMB, //10 1101 1100 + OP_UND_THUMB, //10 1101 1101 + OP_UND_THUMB, //10 1101 1110 + OP_UND_THUMB, //10 1101 1111 + + OP_UND_THUMB, //10 1110 0000 + OP_UND_THUMB, //10 1110 0001 + OP_UND_THUMB, //10 1110 0010 + OP_UND_THUMB, //10 1110 0011 + OP_UND_THUMB, //10 1110 0100 + OP_UND_THUMB, //10 1110 0101 + OP_UND_THUMB, //10 1110 0110 + OP_UND_THUMB, //10 1110 0111 + OP_UND_THUMB, //10 1110 1000 + OP_UND_THUMB, //10 1110 1001 + OP_UND_THUMB, //10 1110 1010 + OP_UND_THUMB, //10 1110 1011 + OP_UND_THUMB, //10 1110 1100 + OP_UND_THUMB, //10 1110 1101 + OP_UND_THUMB, //10 1110 1110 + OP_UND_THUMB, //10 1110 1111 + + OP_POP, //10 1111 0000 + OP_POP, //10 1111 0001 + OP_POP, //10 1111 0010 + OP_POP, //10 1111 0011 + OP_POP_PC, //10 1111 0100 + OP_POP_PC, //10 1111 0101 + OP_POP_PC, //10 1111 0110 + OP_POP_PC, //10 1111 0111 + OP_BKPT_THUMB, //10 1111 1000 + OP_BKPT_THUMB, //10 1111 1001 + OP_BKPT_THUMB, //10 1111 1010 + OP_BKPT_THUMB, //10 1111 1011 + OP_UND_THUMB, //10 1111 1100 + OP_UND_THUMB, //10 1111 1101 + OP_UND_THUMB, //10 1111 1110 + OP_UND_THUMB, //10 1111 1111 + + OP_STMIA_THUMB, //11 0000 0000 + OP_STMIA_THUMB, //11 0000 0001 + OP_STMIA_THUMB, //11 0000 0010 + OP_STMIA_THUMB, //11 0000 0011 + OP_STMIA_THUMB, //11 0000 0100 + OP_STMIA_THUMB, //11 0000 0101 + OP_STMIA_THUMB, //11 0000 0110 + OP_STMIA_THUMB, //11 0000 0111 + OP_STMIA_THUMB, //11 0000 1000 + OP_STMIA_THUMB, //11 0000 1001 + OP_STMIA_THUMB, //11 0000 1010 + OP_STMIA_THUMB, //11 0000 1011 + OP_STMIA_THUMB, //11 0000 1100 + OP_STMIA_THUMB, //11 0000 1101 + OP_STMIA_THUMB, //11 0000 1110 + OP_STMIA_THUMB, //11 0000 1111 + + OP_STMIA_THUMB, //11 0001 0000 + OP_STMIA_THUMB, //11 0001 0001 + OP_STMIA_THUMB, //11 0001 0010 + OP_STMIA_THUMB, //11 0001 0011 + OP_STMIA_THUMB, //11 0001 0100 + OP_STMIA_THUMB, //11 0001 0101 + OP_STMIA_THUMB, //11 0001 0110 + OP_STMIA_THUMB, //11 0001 0111 + OP_STMIA_THUMB, //11 0001 1000 + OP_STMIA_THUMB, //11 0001 1001 + OP_STMIA_THUMB, //11 0001 1010 + OP_STMIA_THUMB, //11 0001 1011 + OP_STMIA_THUMB, //11 0001 1100 + OP_STMIA_THUMB, //11 0001 1101 + OP_STMIA_THUMB, //11 0001 1110 + OP_STMIA_THUMB, //11 0001 1111 + + OP_LDMIA_THUMB, //11 0010 0000 + OP_LDMIA_THUMB, //11 0010 0001 + OP_LDMIA_THUMB, //11 0010 0010 + OP_LDMIA_THUMB, //11 0010 0011 + OP_LDMIA_THUMB, //11 0010 0100 + OP_LDMIA_THUMB, //11 0010 0101 + OP_LDMIA_THUMB, //11 0010 0110 + OP_LDMIA_THUMB, //11 0010 0111 + OP_LDMIA_THUMB, //11 0010 1000 + OP_LDMIA_THUMB, //11 0010 1001 + OP_LDMIA_THUMB, //11 0010 1010 + OP_LDMIA_THUMB, //11 0010 1011 + OP_LDMIA_THUMB, //11 0010 1100 + OP_LDMIA_THUMB, //11 0010 1101 + OP_LDMIA_THUMB, //11 0010 1110 + OP_LDMIA_THUMB, //11 0010 1111 + + OP_LDMIA_THUMB, //11 0011 0000 + OP_LDMIA_THUMB, //11 0011 0001 + OP_LDMIA_THUMB, //11 0011 0010 + OP_LDMIA_THUMB, //11 0011 0011 + OP_LDMIA_THUMB, //11 0011 0100 + OP_LDMIA_THUMB, //11 0011 0101 + OP_LDMIA_THUMB, //11 0011 0110 + OP_LDMIA_THUMB, //11 0011 0111 + OP_LDMIA_THUMB, //11 0011 1000 + OP_LDMIA_THUMB, //11 0011 1001 + OP_LDMIA_THUMB, //11 0011 1010 + OP_LDMIA_THUMB, //11 0011 1011 + OP_LDMIA_THUMB, //11 0011 1100 + OP_LDMIA_THUMB, //11 0011 1101 + OP_LDMIA_THUMB, //11 0011 1110 + OP_LDMIA_THUMB, //11 0011 1111 + + OP_B_COND, //11 0100 0000 + OP_B_COND, //11 0100 0001 + OP_B_COND, //11 0100 0010 + OP_B_COND, //11 0100 0011 + OP_B_COND, //11 0100 0100 + OP_B_COND, //11 0100 0101 + OP_B_COND, //11 0100 0110 + OP_B_COND, //11 0100 0111 + OP_B_COND, //11 0100 1000 + OP_B_COND, //11 0100 1001 + OP_B_COND, //11 0100 1010 + OP_B_COND, //11 0100 1011 + OP_B_COND, //11 0100 1100 + OP_B_COND, //11 0100 1101 + OP_B_COND, //11 0100 1110 + OP_B_COND, //11 0100 1111 + + OP_B_COND, //11 0101 0000 + OP_B_COND, //11 0101 0001 + OP_B_COND, //11 0101 0010 + OP_B_COND, //11 0101 0011 + OP_B_COND, //11 0101 0100 + OP_B_COND, //11 0101 0101 + OP_B_COND, //11 0101 0110 + OP_B_COND, //11 0101 0111 + OP_B_COND, //11 0101 1000 + OP_B_COND, //11 0101 1001 + OP_B_COND, //11 0101 1010 + OP_B_COND, //11 0101 1011 + OP_B_COND, //11 0101 1100 + OP_B_COND, //11 0101 1101 + OP_B_COND, //11 0101 1110 + OP_B_COND, //11 0101 1111 + + OP_B_COND, //11 0110 0000 + OP_B_COND, //11 0110 0001 + OP_B_COND, //11 0110 0010 + OP_B_COND, //11 0110 0011 + OP_B_COND, //11 0110 0100 + OP_B_COND, //11 0110 0101 + OP_B_COND, //11 0110 0110 + OP_B_COND, //11 0110 0111 + OP_B_COND, //11 0110 1000 + OP_B_COND, //11 0110 1001 + OP_B_COND, //11 0110 1010 + OP_B_COND, //11 0110 1011 + OP_B_COND, //11 0110 1100 + OP_B_COND, //11 0110 1101 + OP_B_COND, //11 0110 1110 + OP_B_COND, //11 0110 1111 + + OP_B_COND, //11 0111 0000 + OP_B_COND, //11 0111 0001 + OP_B_COND, //11 0111 0010 + OP_B_COND, //11 0111 0011 + OP_B_COND, //11 0111 0100 + OP_B_COND, //11 0111 0101 + OP_B_COND, //11 0111 0110 + OP_B_COND, //11 0111 0111 + OP_B_COND, //11 0111 1000 + OP_B_COND, //11 0111 1001 + OP_B_COND, //11 0111 1010 + OP_B_COND, //11 0111 1011 + OP_SWI_THUMB, //11 0111 1100 + OP_SWI_THUMB, //11 0111 1101 + OP_SWI_THUMB, //11 0111 1110 + OP_SWI_THUMB, //11 0111 1111 + + OP_B_UNCOND, //11 1000 0000 + OP_B_UNCOND, //11 1000 0001 + OP_B_UNCOND, //11 1000 0010 + OP_B_UNCOND, //11 1000 0011 + OP_B_UNCOND, //11 1000 0100 + OP_B_UNCOND, //11 1000 0101 + OP_B_UNCOND, //11 1000 0110 + OP_B_UNCOND, //11 1000 0111 + OP_B_UNCOND, //11 1000 1000 + OP_B_UNCOND, //11 1000 1001 + OP_B_UNCOND, //11 1000 1010 + OP_B_UNCOND, //11 1000 1011 + OP_B_UNCOND, //11 1000 1100 + OP_B_UNCOND, //11 1000 1101 + OP_B_UNCOND, //11 1000 1110 + OP_B_UNCOND, //11 1000 1111 + + OP_B_UNCOND, //11 1001 0000 + OP_B_UNCOND, //11 1001 0001 + OP_B_UNCOND, //11 1001 0010 + OP_B_UNCOND, //11 1001 0011 + OP_B_UNCOND, //11 1001 0100 + OP_B_UNCOND, //11 1001 0101 + OP_B_UNCOND, //11 1001 0110 + OP_B_UNCOND, //11 1001 0111 + OP_B_UNCOND, //11 1001 1000 + OP_B_UNCOND, //11 1001 1001 + OP_B_UNCOND, //11 1001 1010 + OP_B_UNCOND, //11 1001 1011 + OP_B_UNCOND, //11 1001 1100 + OP_B_UNCOND, //11 1001 1101 + OP_B_UNCOND, //11 1001 1110 + OP_B_UNCOND, //11 1001 1111 + + OP_BLX, //11 1010 0000 + OP_BLX, //11 1010 0001 + OP_BLX, //11 1010 0010 + OP_BLX, //11 1010 0011 + OP_BLX, //11 1010 0100 + OP_BLX, //11 1010 0101 + OP_BLX, //11 1010 0110 + OP_BLX, //11 1010 0111 + OP_BLX, //11 1010 1000 + OP_BLX, //11 1010 1001 + OP_BLX, //11 1010 1010 + OP_BLX, //11 1010 1011 + OP_BLX, //11 1010 1100 + OP_BLX, //11 1010 1101 + OP_BLX, //11 1010 1110 + OP_BLX, //11 1010 1111 + + OP_BLX, //11 1011 0000 + OP_BLX, //11 1011 0001 + OP_BLX, //11 1011 0010 + OP_BLX, //11 1011 0011 + OP_BLX, //11 1011 0100 + OP_BLX, //11 1011 0101 + OP_BLX, //11 1011 0110 + OP_BLX, //11 1011 0111 + OP_BLX, //11 1011 1000 + OP_BLX, //11 1011 1001 + OP_BLX, //11 1011 1010 + OP_BLX, //11 1011 1011 + OP_BLX, //11 1011 1100 + OP_BLX, //11 1011 1101 + OP_BLX, //11 1011 1110 + OP_BLX, //11 1011 1111 + + OP_BL_10, //11 1100 0000 + OP_BL_10, //11 1100 0001 + OP_BL_10, //11 1100 0010 + OP_BL_10, //11 1100 0011 + OP_BL_10, //11 1100 0100 + OP_BL_10, //11 1100 0101 + OP_BL_10, //11 1100 0110 + OP_BL_10, //11 1100 0111 + OP_BL_10, //11 1100 1000 + OP_BL_10, //11 1100 1001 + OP_BL_10, //11 1100 1010 + OP_BL_10, //11 1100 1011 + OP_BL_10, //11 1100 1100 + OP_BL_10, //11 1100 1101 + OP_BL_10, //11 1100 1110 + OP_BL_10, //11 1100 1111 + + OP_BL_10, //11 1101 0000 + OP_BL_10, //11 1101 0001 + OP_BL_10, //11 1101 0010 + OP_BL_10, //11 1101 0011 + OP_BL_10, //11 1101 0100 + OP_BL_10, //11 1101 0101 + OP_BL_10, //11 1101 0110 + OP_BL_10, //11 1101 0111 + OP_BL_10, //11 1101 1000 + OP_BL_10, //11 1101 1001 + OP_BL_10, //11 1101 1010 + OP_BL_10, //11 1101 1011 + OP_BL_10, //11 1101 1100 + OP_BL_10, //11 1101 1101 + OP_BL_10, //11 1101 1110 + OP_BL_10, //11 1101 1111 + + OP_BL_THUMB, //11 1110 0000 + OP_BL_THUMB, //11 1110 0001 + OP_BL_THUMB, //11 1110 0010 + OP_BL_THUMB, //11 1110 0011 + OP_BL_THUMB, //11 1110 0100 + OP_BL_THUMB, //11 1110 0101 + OP_BL_THUMB, //11 1110 0110 + OP_BL_THUMB, //11 1110 0111 + OP_BL_THUMB, //11 1110 1000 + OP_BL_THUMB, //11 1110 1001 + OP_BL_THUMB, //11 1110 1010 + OP_BL_THUMB, //11 1110 1011 + OP_BL_THUMB, //11 1110 1100 + OP_BL_THUMB, //11 1110 1101 + OP_BL_THUMB, //11 1110 1110 + OP_BL_THUMB, //11 1110 1111 + + OP_BL_THUMB, //11 1111 0000 + OP_BL_THUMB, //11 1111 0001 + OP_BL_THUMB, //11 1111 0010 + OP_BL_THUMB, //11 1111 0011 + OP_BL_THUMB, //11 1111 0100 + OP_BL_THUMB, //11 1111 0101 + OP_BL_THUMB, //11 1111 0110 + OP_BL_THUMB, //11 1111 0111 + OP_BL_THUMB, //11 1111 1000 + OP_BL_THUMB, //11 1111 1001 + OP_BL_THUMB, //11 1111 1010 + OP_BL_THUMB, //11 1111 1011 + OP_BL_THUMB, //11 1111 1100 + OP_BL_THUMB, //11 1111 1101 + OP_BL_THUMB, //11 1111 1110 + OP_BL_THUMB, //11 1111 1111 +}; //1089 + diff --git a/tags/release_0_5_0/desmume/src/types.h b/tags/release_0_5_0/desmume/src/types.h new file mode 100644 index 000000000..fb2892207 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/types.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/windows/CWindow.c b/tags/release_0_5_0/desmume/src/windows/CWindow.c new file mode 100644 index 000000000..4c04f3a66 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/CWindow.c @@ -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); +} + +////////////////////////////////////////////////////////////////////////////// + diff --git a/tags/release_0_5_0/desmume/src/windows/CWindow.h b/tags/release_0_5_0/desmume/src/windows/CWindow.h new file mode 100644 index 000000000..3dd46ae78 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/CWindow.h @@ -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 +#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 diff --git a/tags/release_0_5_0/desmume/src/windows/ConfigKeys.c b/tags/release_0_5_0/desmume/src/windows/ConfigKeys.c new file mode 100644 index 000000000..d5bed3a51 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/ConfigKeys.c @@ -0,0 +1,266 @@ +#include +#include +#include +#include +#include +#include + +#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; +} + + diff --git a/tags/release_0_5_0/desmume/src/windows/ConfigKeys.h b/tags/release_0_5_0/desmume/src/windows/ConfigKeys.h new file mode 100644 index 000000000..0e6491fe9 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/ConfigKeys.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/windows/DeSmuME.dev b/tags/release_0_5_0/desmume/src/windows/DeSmuME.dev new file mode 100644 index 000000000..99071f881 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/DeSmuME.dev @@ -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) + diff --git a/tags/release_0_5_0/desmume/src/windows/DeSmuME.ico b/tags/release_0_5_0/desmume/src/windows/DeSmuME.ico new file mode 100644 index 000000000..fe691527c Binary files /dev/null and b/tags/release_0_5_0/desmume/src/windows/DeSmuME.ico differ diff --git a/tags/release_0_5_0/desmume/src/windows/DeSmuME.layout b/tags/release_0_5_0/desmume/src/windows/DeSmuME.layout new file mode 100644 index 000000000..f8eb9890a --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/DeSmuME.layout @@ -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 diff --git a/tags/release_0_5_0/desmume/src/windows/IORegView.c b/tags/release_0_5_0/desmume/src/windows/IORegView.c new file mode 100644 index 000000000..31acf81bb --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/IORegView.c @@ -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 +#include "CWindow.h" +#include "resource.h" +#include "../MMU.h" +#include + +////////////////////////////////////////////////////////////////////////////// + +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; +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/tags/release_0_5_0/desmume/src/windows/IORegView.h b/tags/release_0_5_0/desmume/src/windows/IORegView.h new file mode 100644 index 000000000..65287f0b6 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/IORegView.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/windows/Makefile.am b/tags/release_0_5_0/desmume/src/windows/Makefile.am new file mode 100644 index 000000000..4ea77f53d --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/Makefile.am @@ -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 diff --git a/tags/release_0_5_0/desmume/src/windows/Makefile.win b/tags/release_0_5_0/desmume/src/windows/Makefile.win new file mode 100644 index 000000000..e9c7d8ce8 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/Makefile.win @@ -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 diff --git a/tags/release_0_5_0/desmume/src/windows/disView.c b/tags/release_0_5_0/desmume/src/windows/disView.c new file mode 100644 index 000000000..e6d3e0121 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/disView.c @@ -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 +#include +#include +#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='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='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); +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/tags/release_0_5_0/desmume/src/windows/disView.h b/tags/release_0_5_0/desmume/src/windows/disView.h new file mode 100644 index 000000000..e62409571 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/disView.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/windows/ginfo.c b/tags/release_0_5_0/desmume/src/windows/ginfo.c new file mode 100644 index 000000000..d725bbbfe --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/ginfo.c @@ -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 +#include "resource.h" +#include "../NDSSystem.h" +#include "../MMU.h" +#include +#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; +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/tags/release_0_5_0/desmume/src/windows/ginfo.h b/tags/release_0_5_0/desmume/src/windows/ginfo.h new file mode 100644 index 000000000..46ce36613 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/ginfo.h @@ -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 + diff --git a/tags/release_0_5_0/desmume/src/windows/main.c b/tags/release_0_5_0/desmume/src/windows/main.c new file mode 100644 index 000000000..23cdad8e2 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/main.c @@ -0,0 +1,1189 @@ +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 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 +*/ + +//#define RENDER3D + +#include +#include +#include +#include "CWindow.h" +#include "../MMU.h" +#include "../armcpu.h" +#include "../NDSSystem.h" +#include "resource.h" +#include "memView.h" +#include "disView.h" +#include "ginfo.h" +#include "IORegView.h" +#include "palView.h" +#include "tileView.h" +#include "oamView.h" +#include "../debug.h" +#include "mapview.h" +#include "../saves.h" +#include "../cflash.h" +#include "ConfigKeys.h" + +#include "snddx.h" + +#ifdef RENDER3D + #include "OGLRender.h" +#endif + +/* Declare Windows procedure */ +LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); + +/* Make the class name into a global variable */ +char SavName[MAX_PATH] = ""; +char SavName2[MAX_PATH] = ""; +char szClassName[ ] = "DeSmuME"; +int romnum = 0; + +DWORD threadID; + +HWND hwnd; +HDC hdc; +HINSTANCE hAppInst; + +volatile BOOL execute = FALSE; +volatile BOOL paused = TRUE; +u32 glock = 0; + +BOOL click = FALSE; + +BOOL finished = FALSE; +BOOL romloaded = FALSE; + +HMENU menu; +HANDLE runthread=INVALID_HANDLE_VALUE; + +const DWORD tabkey[48]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,VK_SPACE,VK_UP,VK_DOWN,VK_LEFT,VK_RIGHT,VK_TAB,VK_SHIFT,VK_DELETE,VK_INSERT,VK_HOME,VK_END,0x0d}; +DWORD ds_up,ds_down,ds_left,ds_right,ds_a,ds_b,ds_x,ds_y,ds_l,ds_r,ds_select,ds_start,ds_debug; +static char IniName[MAX_PATH]; +int sndcoretype=SNDCORE_DIRECTX; +int sndbuffersize=735*4; +int sndvolume=100; + +SoundInterface_struct *SNDCoreList[] = { +&SNDDummy, +&SNDFile, +&SNDDIRECTX, +NULL +}; + +int autoframeskipenab=1; +int frameskiprate=0; +static int backupmemorytype=MC_TYPE_AUTODETECT; +static u32 backupmemorysize=1; + +LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, + LPARAM lParam); + +DWORD WINAPI run( LPVOID lpParameter) +{ + char txt[80]; + BITMAPV4HEADER bmi; + u32 cycles = 0; + int wait=0; + u64 freq; + u64 OneFrameTime; + int framestoskip=0; + int framesskipped=0; + int skipnextframe=0; + u64 lastticks=0; + u64 curticks=0; + u64 diffticks=0; + u32 framecount=0; + u64 onesecondticks=0; + int fps=0; + int fpsframecount=0; + u64 fpsticks=0; + + //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; + + #ifdef RENDER3D + OGLRender::init(&hdc); + #endif + QueryPerformanceFrequency((LARGE_INTEGER *)&freq); + QueryPerformanceCounter((LARGE_INTEGER *)&lastticks); + OneFrameTime = freq / 60; + + while(!finished) + { + while(execute) + { + cycles = NDS_exec((560190<<1)-cycles,FALSE); + SPU_Emulate(); + + if (!skipnextframe) + { + #ifndef RENDER3D + SetDIBitsToDevice(hdc, 0, 0, 256, 192*2, 0, 0, 0, 192*2, GPU_screen, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + //SetDIBitsToDevice(hdc, 0, 192, 256, 192*2, 0, 0, 192, 192*2, GPU_screen, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + #else + SetDIBitsToDevice(hdc, 0, 0, 256, 192*2, 0, 0, 192, 192*2, GPU_screen, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + //SetDIBitsToDevice(hdc, 0, 0, 256, 192, 0, 0, 0, 192, GPU_screen, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + #endif + fpsframecount++; + QueryPerformanceCounter((LARGE_INTEGER *)&curticks); + if(curticks >= fpsticks + freq) + { + fps = fpsframecount; + sprintf(txt,"DeSmuME %d", fps); + SetWindowText(hwnd, txt); + fpsframecount = 0; + QueryPerformanceCounter((LARGE_INTEGER *)&fpsticks); + } + + framesskipped = 0; + + if (framestoskip > 0) + skipnextframe = 1; + } + else + { + framestoskip--; + + if (framestoskip < 1) + skipnextframe = 0; + else + skipnextframe = 1; + + framesskipped++; + } + + if (autoframeskipenab) + { + framecount++; + + if (framecount > 60) + { + framecount = 1; + onesecondticks = 0; + } + + QueryPerformanceCounter((LARGE_INTEGER *)&curticks); + diffticks = curticks-lastticks; + + if ((onesecondticks+diffticks) > (OneFrameTime * (u64)framecount) && + framesskipped < 9) + { + // Skip the next frame + skipnextframe = 1; + + // How many frames should we skip? + framestoskip = 1; + } + else if ((onesecondticks+diffticks) < (OneFrameTime * (u64)framecount)) + { + // Check to see if we need to limit speed at all + for (;;) + { + QueryPerformanceCounter((LARGE_INTEGER *)&curticks); + diffticks = curticks-lastticks; + if ((onesecondticks+diffticks) >= (OneFrameTime * (u64)framecount)) + break; + } + } + + onesecondticks += diffticks; + lastticks = curticks; + } + else + { + if (framestoskip < 1) + framestoskip = frameskiprate + 1; + } + + CWindow_RefreshALL(); + Sleep(0); + } + paused = TRUE; + Sleep(500); + } + return 1; +} + +void NDS_Pause() +{ + execute = FALSE; + SPU_Pause(1); + while (!paused) {} +} + +void NDS_UnPause() +{ + paused = FALSE; + execute = TRUE; + SPU_Pause(0); +} + +BOOL LoadROM(char * filename) +{ + NDS_Pause(); + + if (NDS_LoadROM(filename, backupmemorytype, backupmemorysize) > 0) + return TRUE; + + return FALSE; +} + +int WINAPI WinMain (HINSTANCE hThisInstance, + HINSTANCE hPrevInstance, + LPSTR lpszArgument, + int nFunsterStil) + +{ + MSG messages; /* Here messages to the application are saved */ + char text[80]; + cwindow_struct MainWindow; + HACCEL hAccel; + hAppInst=hThisInstance; + + InitializeCriticalSection(§ion); + sprintf(text, "DeSmuME v%s", VERSION); + + hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL)); + + if (CWindow_Init(&MainWindow, hThisInstance, szClassName, text, + WS_CAPTION| WS_SYSMENU |WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + 256, 384, WindowProcedure) != 0) + { + MessageBox(NULL,"Unable to create main window","Error",MB_OK); + return 0; + } + + hwnd = MainWindow.hwnd; + menu = LoadMenu(hThisInstance, "MENU_PRINCIPAL"); + SetMenu(hwnd, menu); + hdc = GetDC(hwnd); + DragAcceptFiles(hwnd, TRUE); + + /* Make the window visible on the screen */ + CWindow_Show(&MainWindow); + + InitMemViewBox(); + InitDesViewBox(); + InitTileViewBox(); + InitOAMViewBox(); + +#ifdef DEBUG + LogStart(); +#endif + + GetINIPath(IniName); + + NDS_Init(); + + GetPrivateProfileString("Video", "FrameSkip", "AUTO", text, 80, IniName); + + if (strcmp(text, "AUTO") == 0) + { + autoframeskipenab=1; + frameskiprate=0; + CheckMenuItem(menu, IDC_FRAMESKIPAUTO, MF_BYCOMMAND | MF_CHECKED); + } + else + { + autoframeskipenab=0; + frameskiprate=atoi(text); + CheckMenuItem(menu, frameskiprate + IDC_FRAMESKIP0, MF_BYCOMMAND | MF_CHECKED); + } + + sndcoretype = GetPrivateProfileInt("Sound","SoundCore", SNDCORE_DIRECTX, IniName); + sndbuffersize = GetPrivateProfileInt("Sound","SoundBufferSize", 735 * 4, IniName); + + if (SPU_ChangeSoundCore(sndcoretype, sndbuffersize) != 0) + { + MessageBox(hwnd,"Unable to initialize DirectSound","Error",MB_OK); + return messages.wParam; + } + + sndvolume = GetPrivateProfileInt("Sound","Volume",100, IniName); + SPU_SetVolume(sndvolume); + + runthread = CreateThread(NULL, 0, run, NULL, 0, &threadID); + + if(LoadROM(lpszArgument)) + { + EnableMenuItem(menu, IDM_EXEC, MF_GRAYED); + EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); + EnableMenuItem(menu, IDM_RESET, MF_ENABLED); + EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); + romloaded = TRUE; + NDS_UnPause(); + } + else + { + EnableMenuItem(menu, IDM_EXEC, MF_ENABLED); + EnableMenuItem(menu, IDM_PAUSE, MF_GRAYED); + EnableMenuItem(menu, IDM_RESET, MF_GRAYED); + EnableMenuItem(menu, IDM_GAME_INFO, MF_GRAYED); + } + + CheckMenuItem(menu, IDC_SAVETYPE1, MF_BYCOMMAND | MF_CHECKED); + CheckMenuItem(menu, IDC_SAVETYPE2, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_SAVETYPE3, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_SAVETYPE4, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_SAVETYPE5, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_SAVETYPE6, MF_BYCOMMAND | MF_UNCHECKED); + + while (GetMessage (&messages, NULL, 0, 0)) + { + if (TranslateAccelerator(hwnd, hAccel, &messages) == 0) + { + // Translate virtual-key messages into character messages + TranslateMessage(&messages); + // Send message to WindowProcedure + DispatchMessage(&messages); + } + } + +#ifdef DEBUG + LogStop(); +#endif + /* The program return-value is 0 - The value that PostQuitMessage() gave */ + return messages.wParam; +} + +void StateSaveSlot(int num) +{ + char filename[MAX_PATH]; + NDS_Pause(); + strcpy(filename, szRomBaseName); + sprintf(filename+strlen(filename), "%d.dst", num); + savestate_save(filename); + NDS_UnPause(); +} + +void StateLoadSlot(int num) +{ + char filename[MAX_PATH]; + NDS_Pause(); + strcpy(filename, szRomBaseName); + sprintf(filename+strlen(filename), "%d.dst", num); + savestate_load(filename); + NDS_UnPause(); +} + +LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) // handle the messages + { + case WM_CREATE: + ReadConfig(); + return 0; + case WM_DESTROY: + NDS_Pause(); + finished = TRUE; + + if (runthread != INVALID_HANDLE_VALUE) + { + if (WaitForSingleObject(runthread,INFINITE) == WAIT_TIMEOUT) + { + // Couldn't close thread cleanly + TerminateThread(runthread,0); + } + CloseHandle(runthread); + } + + NDS_DeInit(); + + PostQuitMessage (0); // send a WM_QUIT to the message queue + return 0; + case WM_CLOSE: + NDS_Pause(); + finished = TRUE; + + if (runthread != INVALID_HANDLE_VALUE) + { + if (WaitForSingleObject(runthread,INFINITE) == WAIT_TIMEOUT) + { + // Couldn't close thread cleanly + TerminateThread(runthread,0); + } + CloseHandle(runthread); + } + + NDS_DeInit(); + PostMessage(hwnd, WM_QUIT, 0, 0); + return 0; + case WM_DROPFILES: + { + char filename[MAX_PATH] = ""; + DragQueryFile((HDROP)wParam,0,filename,MAX_PATH); + DragFinish((HDROP)wParam); + if(LoadROM(filename)) + { + EnableMenuItem(menu, IDM_EXEC, MF_GRAYED); + EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); + EnableMenuItem(menu, IDM_RESET, MF_ENABLED); + EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); + romloaded = TRUE; + NDS_UnPause(); + } + } + return 0; + case WM_KEYDOWN: + //if(wParam=='1'){PostMessage(hwnd, WM_DESTROY, 0, 0);return 0;} + + if(wParam==tabkey[ds_a]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFFE; + ((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFFE; + return 0; } + if(wParam==tabkey[ds_b]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFFD; + ((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFFD; + return 0; } + if(wParam==tabkey[ds_select]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFFB; + ((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFFB; + return 0; } + if(wParam==tabkey[ds_start]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFF7; + ((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFF7; + return 0; } + if(wParam==tabkey[ds_right]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFEF; + ((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFEF; + return 0; } + if(wParam==tabkey[ds_left]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFDF; + ((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFDF; + return 0; } + if(wParam==tabkey[ds_up]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFBF; + ((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFBF; + return 0; } + if(wParam==tabkey[ds_down]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFF7F; + ((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFF7F; + return 0; } + if(wParam==tabkey[ds_r]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFEFF; + ((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFEFF; + return 0; } + if(wParam==tabkey[ds_l]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFDFF; + ((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFDFF; + return 0; } + if(wParam==tabkey[ds_x]){ + ((u16 *)MMU.ARM7_REG)[0x136>>1] &= 0xFFFE; + return 0; } + if(wParam==tabkey[ds_y]){ + ((u16 *)MMU.ARM7_REG)[0x136>>1] &= 0xFFFD; + return 0; } + if(wParam==tabkey[ds_debug]){ + ((u16 *)MMU.ARM7_REG)[0x136>>1] &= 0xFFFB; + return 0; } + return 0; + /*case 0x1E : + MMU.ARM7_REG[0x136] &= 0xFE; + break; + case 0x1F : + MMU.ARM7_REG[0x136] &= 0xFD; + break; + case 0x21 : + NDS_ARM9.wIRQ = TRUE; + break; */ + case WM_KEYUP: + if(wParam==tabkey[ds_a]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x1; + ((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x1; + return 0; } + if(wParam==tabkey[ds_b]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x2; + ((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x2; + return 0; } + if(wParam==tabkey[ds_select]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x4; + ((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x4; + return 0; } + if(wParam==tabkey[ds_start]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x8; + ((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x8; + return 0; } + if(wParam==tabkey[ds_right]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x10; + ((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x10; + return 0; } + if(wParam==tabkey[ds_left]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x20; + ((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x20; + return 0; } + if(wParam==tabkey[ds_up]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x40; + ((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x40; + return 0; } + if(wParam==tabkey[ds_down]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x80; + ((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x80; + return 0; } + if(wParam==tabkey[ds_r]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x100; + ((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x100; + return 0; } + if(wParam==tabkey[ds_l]){ + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x200; + ((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x200; + return 0; } + if(wParam==tabkey[ds_x]){ + ((u16 *)MMU.ARM7_REG)[0x136>>1] |= 0x1; + return 0; } + if(wParam==tabkey[ds_y]){ + ((u16 *)MMU.ARM7_REG)[0x136>>1] |= 0x2; + return 0; } + if(wParam==tabkey[ds_debug]){ + ((u16 *)MMU.ARM7_REG)[0x136>>1] |= 0x4; + return 0; } + break; + + /*case 0x1E : + MMU.ARM7_REG[0x136] |= 1; + break; + case 0x1F : + MMU.ARM7_REG[0x136] |= 2; + break;*/ + /*case 0x21 : + MMU.REG_IME[0] = 1;*/ + case WM_MOUSEMOVE: + { + if (wParam & MK_LBUTTON) + { + s32 x = (s32)((s16)LOWORD(lParam)); + s32 y = (s32)((s16)HIWORD(lParam)) - 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); + return 0; + } + } + NDS_releasTouch(); + return 0; + case WM_LBUTTONDOWN: + if(HIWORD(lParam)>=192) + { + s32 x; + s32 y; + SetCapture(hwnd); + x = LOWORD(lParam); + y = HIWORD(lParam) - 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); + click = TRUE; + } + return 0; + case WM_LBUTTONUP: + if(click) + ReleaseCapture(); + NDS_releasTouch(); + return 0; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDM_OPEN: + { + OPENFILENAME ofn; + char filename[MAX_PATH] = ""; + NDS_Pause(); //Stop emulation while opening new rom + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "NDS ROM file (*.nds)\0*.nds\0NDS/GBA ROM File (*.ds.gba)\0*.ds.gba\0Any file (*.*)\0*.*\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "nds"; + + if(!GetOpenFileName(&ofn)) + { + if (romloaded) + NDS_UnPause(); //Restart emulation if no new rom chosen + return 0; + } + + LOG("%s\r\n", filename); + + if(LoadROM(filename)) + { + EnableMenuItem(menu, IDM_EXEC, MF_GRAYED); + EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); + EnableMenuItem(menu, IDM_RESET, MF_ENABLED); + EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); + romloaded = TRUE; + NDS_UnPause(); + } + } + return 0; + case IDM_PRINTSCREEN: + { + OPENFILENAME ofn; + char filename[MAX_PATH] = ""; + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "Bmp file (*.bmp)\0*.bmp\0Any file (*.*)\0*.*\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "bmp"; + ofn.Flags = OFN_OVERWRITEPROMPT; + GetSaveFileName(&ofn); + NDS_WriteBMP(filename); + } + return 0; + case IDM_QUICK_PRINTSCREEN: + { + NDS_WriteBMP("./printscreen.bmp"); + } + return 0; + case IDM_STATE_LOAD: + { + OPENFILENAME ofn; + NDS_Pause(); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "DeSmuME Savestate (*.dst)\0*.dst\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = SavName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "dst"; + + if(!GetOpenFileName(&ofn)) + { + NDS_UnPause(); + return 0; + } + + savestate_load(SavName); + NDS_UnPause(); + } + return 0; + case IDM_STATE_SAVE: + { + OPENFILENAME ofn; + NDS_Pause(); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "DeSmuME Savestate (*.dst)\0*.dst\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = SavName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "dst"; + + if(!GetSaveFileName(&ofn)) + { + return 0; + } + + savestate_save(SavName); + NDS_UnPause(); + } + return 0; + case IDM_STATE_SAVE_F1: + StateSaveSlot(1); + return 0; + case IDM_STATE_SAVE_F2: + StateSaveSlot(2); + return 0; + case IDM_STATE_SAVE_F3: + StateSaveSlot(3); + return 0; + case IDM_STATE_SAVE_F4: + StateSaveSlot(4); + return 0; + case IDM_STATE_SAVE_F5: + StateSaveSlot(5); + return 0; + case IDM_STATE_SAVE_F6: + StateSaveSlot(6); + return 0; + case IDM_STATE_SAVE_F7: + StateSaveSlot(7); + return 0; + case IDM_STATE_SAVE_F8: + StateSaveSlot(8); + return 0; + case IDM_STATE_SAVE_F9: + StateSaveSlot(9); + return 0; + case IDM_STATE_SAVE_F10: + StateSaveSlot(10); + return 0; + case IDM_STATE_LOAD_F1: + StateLoadSlot(1); + return 0; + case IDM_STATE_LOAD_F2: + StateLoadSlot(2); + return 0; + case IDM_STATE_LOAD_F3: + StateLoadSlot(3); + return 0; + case IDM_STATE_LOAD_F4: + StateLoadSlot(4); + return 0; + case IDM_STATE_LOAD_F5: + StateLoadSlot(5); + return 0; + case IDM_STATE_LOAD_F6: + StateLoadSlot(6); + return 0; + case IDM_STATE_LOAD_F7: + StateLoadSlot(7); + return 0; + case IDM_STATE_LOAD_F8: + StateLoadSlot(8); + return 0; + case IDM_STATE_LOAD_F9: + StateLoadSlot(9); + return 0; + case IDM_STATE_LOAD_F10: + StateLoadSlot(10); + return 0; + case IDM_SOUNDSETTINGS: + { + DialogBox(GetModuleHandle(NULL), "SoundSettingsDlg", hwnd, (DLGPROC)SoundSettingsDlgProc); + } + return 0; + case IDM_GAME_INFO: + { + CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_GAME_INFO), hwnd, GinfoView_Proc); + } + return 0; + case IDM_PAL: + { + palview_struct *PalView; + + if ((PalView = PalView_Init(hAppInst, HWND_DESKTOP)) != NULL) + CWindow_Show(PalView); + } + return 0; + case IDM_TILE: + { + tileview_struct *TileView; + + if ((TileView = TileView_Init(hAppInst, HWND_DESKTOP)) != NULL) + CWindow_Show(TileView); + } + return 0; + case IDM_IOREG: + { + cwindow_struct *IoregView; + + if ((IoregView = malloc(sizeof(cwindow_struct))) == NULL) + return 0; + + if (CWindow_Init2(IoregView, hAppInst, HWND_DESKTOP, "IO REG VIEW", IDD_IO_REG, IoregView_Proc) == 0) + { + CWindow_AddToRefreshList(IoregView); + CWindow_Show(IoregView); + } + } + return 0; + case IDM_QUIT: + PostMessage(hwnd, WM_QUIT, 0, 0); + return 0; + case IDM_MEMORY: + { + memview_struct *MemView; + + if ((MemView = MemView_Init(hAppInst, HWND_DESKTOP, "ARM7 memory viewer", 1)) != NULL) + CWindow_Show(MemView); + + if ((MemView = MemView_Init(hAppInst, HWND_DESKTOP, "ARM9 memory viewer", 0)) != NULL) + CWindow_Show(MemView); + } + return 0; + case IDM_DISASSEMBLER: + { + disview_struct *DisView; + + if ((DisView = DisView_Init(hAppInst, HWND_DESKTOP, "ARM7 Disassembler", &NDS_ARM7)) != NULL) + CWindow_Show(DisView); + + if ((DisView = DisView_Init(hAppInst, HWND_DESKTOP, "ARM9 Disassembler", &NDS_ARM9)) != NULL) + CWindow_Show(DisView); + } + return 0; + case IDM_MAP: + { + mapview_struct *MapView; + + if ((MapView = MapView_Init(hAppInst, HWND_DESKTOP)) != NULL) + { + CWindow_AddToRefreshList(MapView); + CWindow_Show(MapView); + } + } + return 0; + case IDM_OAM: + { + oamview_struct *OamView; + + if ((OamView = OamView_Init(hAppInst, HWND_DESKTOP)) != NULL) + { + CWindow_AddToRefreshList(OamView); + CWindow_Show(OamView); + } + } + return 0; + case IDM_MBG0 : + if(MainScreen.gpu->dispBG[0]) + { + GPU_remove(MainScreen.gpu, 0); + CheckMenuItem(menu, IDM_MBG0, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(MainScreen.gpu, 0); + CheckMenuItem(menu, IDM_MBG0, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_MBG1 : + if(MainScreen.gpu->dispBG[1]) + { + GPU_remove(MainScreen.gpu, 1); + CheckMenuItem(menu, IDM_MBG1, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(MainScreen.gpu, 1); + CheckMenuItem(menu, IDM_MBG1, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_MBG2 : + if(MainScreen.gpu->dispBG[2]) + { + GPU_remove(MainScreen.gpu, 2); + CheckMenuItem(menu, IDM_MBG2, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(MainScreen.gpu, 2); + CheckMenuItem(menu, IDM_MBG2, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_MBG3 : + if(MainScreen.gpu->dispBG[3]) + { + GPU_remove(MainScreen.gpu, 3); + CheckMenuItem(menu, IDM_MBG3, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(MainScreen.gpu, 3); + CheckMenuItem(menu, IDM_MBG3, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_SBG0 : + if(SubScreen.gpu->dispBG[0]) + { + GPU_remove(SubScreen.gpu, 0); + CheckMenuItem(menu, IDM_SBG0, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(SubScreen.gpu, 0); + CheckMenuItem(menu, IDM_SBG0, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_SBG1 : + if(SubScreen.gpu->dispBG[1]) + { + GPU_remove(SubScreen.gpu, 1); + CheckMenuItem(menu, IDM_SBG1, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(SubScreen.gpu, 1); + CheckMenuItem(menu, IDM_SBG1, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_SBG2 : + if(SubScreen.gpu->dispBG[2]) + { + GPU_remove(SubScreen.gpu, 2); + CheckMenuItem(menu, IDM_SBG2, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(SubScreen.gpu, 2); + CheckMenuItem(menu, IDM_SBG2, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_SBG3 : + if(SubScreen.gpu->dispBG[3]) + { + GPU_remove(SubScreen.gpu, 3); + CheckMenuItem(menu, IDM_SBG3, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(SubScreen.gpu, 3); + CheckMenuItem(menu, IDM_SBG3, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_EXEC: + EnableMenuItem(menu, IDM_EXEC, MF_GRAYED); + EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); + NDS_UnPause(); + return 0; + case IDM_PAUSE: + EnableMenuItem(menu, IDM_EXEC, MF_ENABLED); + EnableMenuItem(menu, IDM_PAUSE, MF_GRAYED); + NDS_Pause(); + return 0; + + #define saver(one,two,three,four,five, six) \ + CheckMenuItem(menu, IDC_SAVETYPE1, MF_BYCOMMAND | one); \ + CheckMenuItem(menu, IDC_SAVETYPE2, MF_BYCOMMAND | two); \ + CheckMenuItem(menu, IDC_SAVETYPE3, MF_BYCOMMAND | three); \ + CheckMenuItem(menu, IDC_SAVETYPE4, MF_BYCOMMAND | four); \ + CheckMenuItem(menu, IDC_SAVETYPE5, MF_BYCOMMAND | five); \ + CheckMenuItem(menu, IDC_SAVETYPE6, MF_BYCOMMAND | six); + + case IDC_SAVETYPE1: + saver(MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); + backupmemorytype = MC_TYPE_AUTODETECT; + backupmemorysize = 1; + mc_realloc(&MMU.bupmem, backupmemorytype,backupmemorysize); + return 0; + case IDC_SAVETYPE2: + saver(MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); + backupmemorytype = MC_TYPE_EEPROM1; + backupmemorysize = MC_SIZE_4KBITS; + mc_realloc(&MMU.bupmem, backupmemorytype,backupmemorysize); + return 0; + case IDC_SAVETYPE3: + saver(MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); + backupmemorytype = MC_TYPE_EEPROM2; + backupmemorysize = MC_SIZE_64KBITS; + mc_realloc(&MMU.bupmem, backupmemorytype,backupmemorysize); + return 0; + case IDC_SAVETYPE4: + saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED); + backupmemorytype = MC_TYPE_EEPROM2; + backupmemorysize = MC_SIZE_512KBITS; + mc_realloc(&MMU.bupmem, backupmemorytype,backupmemorysize); + return 0; + case IDC_SAVETYPE5: + saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED); + backupmemorytype = MC_TYPE_FRAM; + backupmemorysize = MC_SIZE_256KBITS; + mc_realloc(&MMU.bupmem, backupmemorytype,backupmemorysize); + return 0; + case IDC_SAVETYPE6: + saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED); + backupmemorytype = MC_TYPE_FLASH; + backupmemorysize = MC_SIZE_2MBITS; + mc_realloc(&MMU.bupmem, backupmemorytype,backupmemorysize); + return 0; + + case IDM_RESET: + NDS_Reset(); + return 0; + case IDM_CONFIG: + { + cwindow_struct ConfigView; + + if (CWindow_Init2(&ConfigView, hAppInst, HWND_DESKTOP, "Configure Controls", IDD_CONFIG, ConfigView_Proc) == 0) + CWindow_Show(&ConfigView); + + } + return 0; + case IDC_FRAMESKIPAUTO: + case IDC_FRAMESKIP0: + case IDC_FRAMESKIP1: + case IDC_FRAMESKIP2: + case IDC_FRAMESKIP3: + case IDC_FRAMESKIP4: + case IDC_FRAMESKIP5: + case IDC_FRAMESKIP6: + case IDC_FRAMESKIP7: + case IDC_FRAMESKIP8: + case IDC_FRAMESKIP9: + { + if(LOWORD(wParam) == IDC_FRAMESKIPAUTO) + { + autoframeskipenab = 1; + WritePrivateProfileString("Video", "FrameSkip", "AUTO", IniName); + } + else + { + char text[80]; + autoframeskipenab = 0; + frameskiprate = LOWORD(wParam) - IDC_FRAMESKIP0; + sprintf(text, "%d", frameskiprate); + WritePrivateProfileString("Video", "FrameSkip", text, IniName); + } + + CheckMenuItem(menu, IDC_FRAMESKIPAUTO, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_FRAMESKIP0, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_FRAMESKIP1, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_FRAMESKIP2, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_FRAMESKIP3, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_FRAMESKIP4, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_FRAMESKIP5, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_FRAMESKIP6, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_FRAMESKIP7, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_FRAMESKIP8, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, IDC_FRAMESKIP9, MF_BYCOMMAND | MF_UNCHECKED); + CheckMenuItem(menu, LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_WEBSITE: + ShellExecute(NULL, "open", "http://desmume.sourceforge.net", NULL, NULL, SW_SHOWNORMAL); + return 0; + case IDM_FORUM: + ShellExecute(NULL, "open", "http://sourceforge.net/forum/?group_id=164579", NULL, NULL, SW_SHOWNORMAL); + return 0; + case IDM_SUBMITBUGREPORT: + ShellExecute(NULL, "open", "http://sourceforge.net/tracker/?func=add&group_id=164579&atid=832291", NULL, NULL, SW_SHOWNORMAL); + return 0; + } + return 0; + default: /* for messages that we don't deal with */ + return DefWindowProc (hwnd, message, wParam, lParam); + } + + return 0; +} + +LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, + LPARAM lParam) +{ + static timerid=0; + + switch (uMsg) + { + case WM_INITDIALOG: + { + int i; + char tempstr[MAX_PATH]; + + // Setup Sound Core Combo box + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_RESETCONTENT, 0, 0); + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (long)"None"); + + for (i = 1; SNDCoreList[i] != NULL; i++) + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (long)SNDCoreList[i]->Name); + + // Set Selected Sound Core + for (i = 0; SNDCoreList[i] != NULL; i++) + { + if (sndcoretype == SNDCoreList[i]->id) + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_SETCURSEL, i, 0); + } + + // Setup Sound Buffer Size Edit Text + sprintf(tempstr, "%d", sndbuffersize); + SetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr); + + // Setup Volume Slider + SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_SETRANGE, 0, MAKELONG(0, 100)); + + // Set Selected Volume + SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_SETPOS, TRUE, sndvolume); + + timerid = SetTimer(hDlg, 1, 500, NULL); + return TRUE; + } + case WM_TIMER: + { + if (timerid == wParam) + { + int setting; + setting = SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_GETPOS, 0, 0); + SPU_SetVolume(setting); + break; + } + break; + } + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDOK: + { + char tempstr[MAX_PATH]; + + EndDialog(hDlg, TRUE); + + NDS_Pause(); + + // Write Sound core type + sndcoretype = SNDCoreList[SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_GETCURSEL, 0, 0)]->id; + sprintf(tempstr, "%d", sndcoretype); + WritePrivateProfileString("Sound", "SoundCore", tempstr, IniName); + + // Write Sound Buffer size + GetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr, 6); + sscanf(tempstr, "%d", &sndbuffersize); + WritePrivateProfileString("Sound", "SoundBufferSize", tempstr, IniName); + + SPU_ChangeSoundCore(sndcoretype, sndbuffersize); + + // Write Volume + sndvolume = SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_GETPOS, 0, 0); + sprintf(tempstr, "%d", sndvolume); + WritePrivateProfileString("Sound", "Volume", tempstr, IniName); + SPU_SetVolume(sndvolume); + NDS_UnPause(); + + return TRUE; + } + case IDCANCEL: + { + EndDialog(hDlg, FALSE); + return TRUE; + } + default: break; + } + + break; + } + case WM_DESTROY: + { + if (timerid != 0) + KillTimer(hDlg, timerid); + break; + } + } + + return FALSE; +} + diff --git a/tags/release_0_5_0/desmume/src/windows/mapView.c b/tags/release_0_5_0/desmume/src/windows/mapView.c new file mode 100644 index 000000000..4b24428a1 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/mapView.c @@ -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 + +////////////////////////////////////////////////////////////////////////////// + +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); +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/tags/release_0_5_0/desmume/src/windows/mapView.h b/tags/release_0_5_0/desmume/src/windows/mapView.h new file mode 100644 index 000000000..6151717c4 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/mapView.h @@ -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 +#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 diff --git a/tags/release_0_5_0/desmume/src/windows/memView.c b/tags/release_0_5_0/desmume/src/windows/memView.c new file mode 100644 index 000000000..46741c5a5 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/memView.c @@ -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 +#include +#include +#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>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='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>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='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); +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/tags/release_0_5_0/desmume/src/windows/memView.h b/tags/release_0_5_0/desmume/src/windows/memView.h new file mode 100644 index 000000000..a464755e0 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/memView.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/windows/oamView.c b/tags/release_0_5_0/desmume/src/windows/oamView.c new file mode 100644 index 000000000..3e75cf6af --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/oamView.c @@ -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 +#include +#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); +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/tags/release_0_5_0/desmume/src/windows/oamView.h b/tags/release_0_5_0/desmume/src/windows/oamView.h new file mode 100644 index 000000000..784372aa7 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/oamView.h @@ -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 diff --git a/tags/release_0_5_0/desmume/src/windows/palView.c b/tags/release_0_5_0/desmume/src/windows/palView.c new file mode 100644 index 000000000..c7133c934 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/palView.c @@ -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 +#include "resource.h" +#include "palView.h" +#include "../MMU.h" +#include + +////////////////////////////////////////////////////////////////////////////// + +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 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); +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/tags/release_0_5_0/desmume/src/windows/palView.h b/tags/release_0_5_0/desmume/src/windows/palView.h new file mode 100644 index 000000000..a0a3c4fea --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/palView.h @@ -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 PALVIEW_H +#define PALVIEW_H + +#include "CWindow.h" + +typedef struct +{ + HWND hwnd; + BOOL autoup; + void *prev; + void *next; + void *first; + void (*Refresh)(void *win); + + u16 *adr; + s16 palnum; +} palview_struct; + +//BOOL CALLBACK palView_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + +palview_struct *PalView_Init(HINSTANCE hInst, HWND parent); +void PalView_Deinit(palview_struct *PalView); + +#endif + diff --git a/tags/release_0_5_0/desmume/src/windows/resource.h b/tags/release_0_5_0/desmume/src/windows/resource.h new file mode 100644 index 000000000..7943726e0 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/resource.h @@ -0,0 +1,223 @@ +/* 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 RESOURCE_H +#define RESOURCE_H + +#if 0 +#include "../NDSSystem.hpp" + +extern NDSSystem nds; +extern BOOL execute; +extern unsigned long glock; +void refreshAll(); +#endif + +#define IconDeSmuME 100 + +#define IDC_STATIC -1 +#define IDM_OPEN 101 +#define IDM_QUIT 102 +#define IDC_FERMER 103 +#define IDC_STEP 104 +#define IDC_SETPNUM 105 +#define IDC_SCROLLER 106 +#define IDC_GO 107 +#define IDC_AUTO_UPDATE 108 + +#define IDM_MEMORY 109 +#define IDM_DISASSEMBLER 110 +#define IDM_GAME_INFO 111 +#define IDM_EXEC 112 +#define IDM_PAUSE 113 +#define IDM_RESET 114 +#define IDM_IOREG 115 +#define IDM_LOG 116 +#define IDM_PAL 117 +#define IDM_TILE 118 +#define IDM_MAP 119 +#define IDM_MBG0 120 +#define IDM_MBG1 121 +#define IDM_MBG2 122 +#define IDM_MBG3 123 +#define IDM_SBG0 124 +#define IDM_SBG1 125 +#define IDM_SBG2 126 +#define IDM_SBG3 127 +#define IDM_OAM 128 +#define IDM_PRINTSCREEN 129 +#define IDM_QUICK_PRINTSCREEN 130 +#define IDM_SOUNDSETTINGS 131 +#define IDM_WEBSITE 132 +#define IDM_FORUM 133 +#define IDM_SUBMITBUGREPORT 134 +#define IDM_STATE_LOAD 135 +#define IDM_STATE_SAVE 136 + +#define IDR_MAIN_ACCEL 137 +#define IDM_STATE_SAVE_F1 140 +#define IDM_STATE_SAVE_F2 141 +#define IDM_STATE_SAVE_F3 142 +#define IDM_STATE_SAVE_F4 143 +#define IDM_STATE_SAVE_F5 144 +#define IDM_STATE_SAVE_F6 145 +#define IDM_STATE_SAVE_F7 146 +#define IDM_STATE_SAVE_F8 147 +#define IDM_STATE_SAVE_F9 148 +#define IDM_STATE_SAVE_F10 149 +#define IDM_STATE_LOAD_F1 150 +#define IDM_STATE_LOAD_F2 151 +#define IDM_STATE_LOAD_F3 152 +#define IDM_STATE_LOAD_F4 153 +#define IDM_STATE_LOAD_F5 154 +#define IDM_STATE_LOAD_F6 155 +#define IDM_STATE_LOAD_F7 156 +#define IDM_STATE_LOAD_F8 157 +#define IDM_STATE_LOAD_F9 158 +#define IDM_STATE_LOAD_F10 159 + +#define IDC_COMBO1 160 +#define IDC_COMBO2 161 +#define IDC_COMBO3 162 +#define IDC_COMBO4 163 +#define IDC_COMBO5 164 +#define IDC_COMBO6 165 +#define IDC_COMBO7 166 +#define IDC_COMBO8 167 +#define IDC_COMBO9 168 +#define IDC_COMBO10 169 +#define IDC_COMBO11 170 +#define IDC_COMBO12 171 +#define IDC_COMBO13 172 + +#define IDC_BUTTON1 173 +#define IDM_CONFIG 180 +#define IDD_CONFIG 181 + +#define IDC_SAVETYPE1 182 +#define IDC_SAVETYPE2 183 +#define IDC_SAVETYPE3 184 +#define IDC_SAVETYPE4 185 +#define IDC_SAVETYPE5 186 +#define IDC_SAVETYPE6 187 + +#define IDC_FRAMESKIPAUTO 190 +#define IDC_FRAMESKIP0 191 +#define IDC_FRAMESKIP1 192 +#define IDC_FRAMESKIP2 193 +#define IDC_FRAMESKIP3 194 +#define IDC_FRAMESKIP4 195 +#define IDC_FRAMESKIP5 196 +#define IDC_FRAMESKIP6 197 +#define IDC_FRAMESKIP7 198 +#define IDC_FRAMESKIP8 199 +#define IDC_FRAMESKIP9 200 + +#define IDD_MEM_VIEWER 301 +#define IDC_8_BIT 302 +#define IDC_16_BIT 303 +#define IDC_32_BIT 304 +#define IDC_MEM_BOX 305 +#define IDC_GOTOMEM 306 + +#define IDD_DESASSEMBLEUR_VIEWER 401 +#define IDC_DES_BOX 402 +#define IDC_R0 403 +#define IDC_R1 404 +#define IDC_R2 405 +#define IDC_R3 406 +#define IDC_R4 407 +#define IDC_R5 408 +#define IDC_R6 409 +#define IDC_R7 410 +#define IDC_R8 411 +#define IDC_R9 412 +#define IDC_R10 413 +#define IDC_R11 414 +#define IDC_R12 415 +#define IDC_R13 416 +#define IDC_R14 417 +#define IDC_R15 418 +#define IDC_MODE 419 +#define IDC_AUTO_DES 420 +#define IDC_ARM 421 +#define IDC_THUMB 422 +#define IDC_GOTODES 423 +#define IDC_TMP 424 + +#define IDD_GAME_INFO 501 +#define IDC_NOM_JEU 502 +#define IDC_CDE 503 +#define IDC_FAB 504 +#define IDC_TAILLE 505 +#define IDC_ARM9_T 506 +#define IDC_ARM7_T 507 +#define IDC_DATA 508 + +#define IDD_IO_REG 601 +#define IDC_INTHAND 602 +#define IDC_IE 603 +#define IDC_IME 604 +#define IDC_DISPCNT 605 +#define IDC_DISPSTAT 606 +#define IDC_IPCSYNC 607 +#define IDC_IPCFIFO 608 + +#define IDD_LOG 701 +#define IDC_LOG 702 +#define IDD_PAL 703 +#define IDD_TILE 704 +#define IDC_PAL_SELECT 705 +#define IDC_PALNUM 706 +#define IDC_MEM_SELECT 707 +#define IDC_Tile_BOX 708 +#define IDC_BITMAP 709 +#define IDC_256COUL 710 +#define IDC_16COUL 711 +#define IDC_MINI_TILE 712 +#define IDC_TILENUM 713 + +#define IDD_MAP 800 +#define IDC_BG_SELECT 801 +#define IDC_PAL 803 +#define IDC_PRIO 804 +#define IDC_CHAR 805 +#define IDC_SCR 806 +#define IDC_MSIZE 807 +#define IDC_SCROLL 808 + +#define IDD_OAM 900 +#define IDC_SCR_SELECT 901 +#define IDC_TILE 902 +#define IDC_OAMNUM 903 +#define IDC_COOR 904 +#define IDC_DIM 905 +#define IDC_ROT 906 +#define IDC_MOS 907 +#define IDC_PROP0 908 +#define IDC_PROP1 909 +#define IDC_OAM_BOX 910 + +#define IDC_SOUNDCORECB 1000 +#define IDC_SOUNDBUFFERET 1001 +#define IDC_SLVOLUME 1002 + +#endif diff --git a/tags/release_0_5_0/desmume/src/windows/resources.rc b/tags/release_0_5_0/desmume/src/windows/resources.rc new file mode 100644 index 000000000..e0b5c3583 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/resources.rc @@ -0,0 +1,693 @@ +/* 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 +#include "resource.h" + +IconDeSmuME ICON MOVEABLE PURE LOADONCALL DISCARDABLE "DeSmuME.ico" +//IconDeSmuME ICON MOVEABLE PURE LOADONCALL DISCARDABLE "DeSmuME3D.ico" + +// FRENCH //////////////////////////////////////////////////////////////////// + +LANGUAGE LANG_FRENCH,SUBLANG_FRENCH + +MENU_PRINCIPAL MENU +{ + POPUP "&Fichier" + { + MENUITEM "&Ouvrir", IDM_OPEN + MENUITEM "&Info rom", IDM_GAME_INFO + MENUITEM SEPARATOR + MENUITEM "&Printscreen", IDM_PRINTSCREEN + MENUITEM "&Quick Printscreen", IDM_QUICK_PRINTSCREEN + MENUITEM SEPARATOR + MENUITEM "&Quitter", IDM_QUIT + } + POPUP "&Emulation" + { + MENUITEM "&Execute", IDM_EXEC + MENUITEM "&Pause", IDM_PAUSE + MENUITEM "&Reset", IDM_RESET + } + POPUP "&Outils" + { + MENUITEM "&Desassembleur", IDM_DISASSEMBLER + MENUITEM "Visualiser la &memoire", IDM_MEMORY + MENUITEM "Visualiser les ®istres", IDM_IOREG +// MENUITEM "Visualiser le &log", IDM_LOG + MENUITEM "Visualiser les &palettes", IDM_PAL + MENUITEM "Visualiser les &tiles", IDM_TILE + MENUITEM "Visualiser les m&aps", IDM_MAP + MENUITEM "Visualiser les &oams", IDM_OAM + MENUITEM SEPARATOR + POPUP "&Visualiser les &couches" + { + MENUITEM "Main BG 0", IDM_MBG0, CHECKED + MENUITEM "Main BG 1", IDM_MBG1, CHECKED + MENUITEM "Main BG 2", IDM_MBG2, CHECKED + MENUITEM "Main BG 3", IDM_MBG3, CHECKED + MENUITEM SEPARATOR + MENUITEM "Sub BG 0", IDM_SBG0, CHECKED + MENUITEM "Sub BG 1", IDM_SBG1, CHECKED + MENUITEM "Sub BG 2", IDM_SBG2, CHECKED + MENUITEM "Sub BG 3", IDM_SBG3, CHECKED + } + } +} + + +IDD_MEM_VIEWER DIALOG DISCARDABLE 0, 0, 428, 178 +STYLE WS_SYSMENU +CAPTION "Visualisation de la memoire" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "8 bit",IDC_8_BIT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,29,10 + CONTROL "16 bit",IDC_16_BIT,"Button",BS_AUTORADIOBUTTON,44,4,33,10 + CONTROL "32 bit",IDC_32_BIT,"Button",BS_AUTORADIOBUTTON,82,4,33,10 + LTEXT "Aller E:",IDC_STATIC,130,4,33,10 + EDITTEXT IDC_GOTOMEM,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP + PUSHBUTTON "&GO",IDC_GO,240,1,20,14 + CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,350,1,75,14 + CONTROL "Edit", IDC_MEM_BOX,"MemViewBox",WS_TABSTOP | WS_VSCROLL,4,16,424,142,WS_EX_CLIENTEDGE + PUSHBUTTON "&Fermer",IDC_FERMER,185,162,50,14 +END + +IDD_DESASSEMBLEUR_VIEWER DIALOG DISCARDABLE 0, 0, 380, 186 +STYLE WS_SYSMENU +CAPTION "Desassembleur" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Auto ",IDC_AUTO_DES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,35,10 + CONTROL "ARM",IDC_ARM,"Button",BS_AUTORADIOBUTTON,44,4,35,10 + CONTROL "Thumb",IDC_THUMB,"Button",BS_AUTORADIOBUTTON,82,4,40,10 + LTEXT "Aller E:",IDC_STATIC,130,4,33,10 + EDITTEXT IDC_GOTODES,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | + ES_WANTRETURN | WS_GROUP + PUSHBUTTON "&GO",IDC_GO,240,1,20,14 + CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,300,1,75,14 + CONTROL "Edit", IDC_DES_BOX,"DesViewBox",WS_TABSTOP | WS_VSCROLL,4,16,296,150,WS_EX_CLIENTEDGE + PUSHBUTTON "&Fermer",IDC_FERMER,185,170,50,14 + EDITTEXT IDC_SETPNUM,5,170,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | WS_GROUP | ES_NUMBER + PUSHBUTTON "&Step",IDC_STEP,75,170,50,14 + LTEXT "R0 :",IDC_STATIC,304,16,17,8 + LTEXT "R1 :",IDC_STATIC,304,24,17,8 + LTEXT "R2 :",IDC_STATIC,304,32,17,8 + LTEXT "R3 :",IDC_STATIC,304,40,17,8 + LTEXT "R4 :",IDC_STATIC,304,48,17,8 + LTEXT "R5 :",IDC_STATIC,304,56,17,8 + LTEXT "R6 :",IDC_STATIC,304,64,17,8 + LTEXT "R7 :",IDC_STATIC,304,72,17,8 + LTEXT "R8 :",IDC_STATIC,304,80,17,8 + LTEXT "R9 :",IDC_STATIC,304,88,17,8 + LTEXT "R10 :",IDC_STATIC,304,96,17,8 + LTEXT "R11 :",IDC_STATIC,304,104,17,8 + LTEXT "R12 :",IDC_STATIC,304,112,17,8 + LTEXT "SP :",IDC_STATIC,304,120,17,8 + LTEXT "LR :",IDC_STATIC,304,128,17,8 + LTEXT "PC :",IDC_STATIC,304,136,17,8 + LTEXT "Mode :",IDC_STATIC,304,158,22,8 + LTEXT "SPSR :",IDC_STATIC,304,168,22,8 + LTEXT "00000000",IDC_R0,325,16,40,8 + LTEXT "00000000",IDC_R1,325,24,40,8 + LTEXT "00000000",IDC_R2,325,32,40,8 + LTEXT "00000000",IDC_R3,325,40,40,8 + LTEXT "00000000",IDC_R4,325,48,40,8 + LTEXT "00000000",IDC_R5,325,56,40,8 + LTEXT "00000000",IDC_R6,325,64,40,8 + LTEXT "00000000",IDC_R7,325,72,40,8 + LTEXT "00000000",IDC_R8,325,80,40,8 + LTEXT "00000000",IDC_R9,325,88,40,8 + LTEXT "00000000",IDC_R10,325,96,40,8 + LTEXT "00000000",IDC_R11,325,104,40,8 + LTEXT "00000000",IDC_R12,325,112,40,8 + LTEXT "00000000",IDC_R13,325,120,40,8 + LTEXT "00000000",IDC_R14,325,128,40,8 + LTEXT "00000000",IDC_R15,325,136,40,8 + LTEXT "",IDC_MODE,327,158,28,8 + LTEXT "",IDC_TMP,327,168,40,8 +END + +IDD_GAME_INFO DIALOG DISCARDABLE 0, 0, 150, 150 +STYLE WS_VISIBLE | WS_SYSMENU +CAPTION "Info ROM" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "&Fermer",IDC_FERMER,50,134,50,14 + LTEXT "Nom du jeu :",IDC_STATIC,4,4,41,8 + LTEXT "Code :",IDC_STATIC,4,12,41,8 + LTEXT "Fabriquant :",IDC_STATIC,4,20,41,8 + LTEXT "Taille :",IDC_STATIC,4,28,41,8 + LTEXT "ARM9 taille :",IDC_STATIC,4,36,41,8 + LTEXT "ARM7 taille :",IDC_STATIC,4,44,41,8 + LTEXT "Donnee :",IDC_STATIC,4,52,41,8 + LTEXT "",IDC_NOM_JEU,45,4,100,8 + LTEXT "",IDC_CDE,45,12,100,8 + LTEXT "",IDC_FAB,45,20,100,8 + LTEXT "",IDC_TAILLE,45,28,100,8 + LTEXT "",IDC_ARM9_T,45,36,100,8 + LTEXT "",IDC_ARM7_T,45,44,100,8 + LTEXT "",IDC_DATA,45,52,100,8 +END + +IDD_IO_REG DIALOG DISCARDABLE 0, 0, 150, 150 +STYLE WS_SYSMENU +CAPTION "IO REG" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "&Fermer",IDC_FERMER,50,134,50,14 + LTEXT "Int Handler :",IDC_STATIC,4,4,41,8 + LTEXT "IE :",IDC_STATIC,4,12,41,8 + LTEXT "IME :",IDC_STATIC,4,20,41,8 + LTEXT "DISPCNT :",IDC_STATIC,4,28,41,8 + LTEXT "DISPSTAT :",IDC_STATIC,4,36,41,8 + LTEXT "IPCSYNC :",IDC_STATIC,4,44,41,8 + LTEXT "IPCFIFO :",IDC_STATIC,4,52,41,8 + LTEXT "",IDC_INTHAND,45,4,100,8 + LTEXT "",IDC_IE,45,12,130,8 + LTEXT "",IDC_IME,45,20,130,8 + LTEXT "",IDC_DISPCNT,45,28,130,8 + LTEXT "",IDC_DISPSTAT,45,36,130,8 + LTEXT "",IDC_IPCSYNC,45,44,130,8 + LTEXT "",IDC_IPCFIFO,45,52,130,8 +END + +IDD_LOG DIALOG DISCARDABLE 0, 0, 300, 300 +STYLE WS_SYSMENU +CAPTION "Log" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Edit", IDC_LOG,"LogView",WS_TABSTOP | WS_VSCROLL,4,4,292,280,WS_EX_CLIENTEDGE + PUSHBUTTON "&Fermer",IDC_FERMER,125,285,50,14 +END + +IDD_PAL DIALOG DISCARDABLE 0, 0, 120, 165 +STYLE WS_SYSMENU +CAPTION "PAL VIEW" +FONT 8, "MS Sans Serif" +BEGIN + COMBOBOX IDC_PAL_SELECT, 15, 3, 90, 14, WS_TABSTOP | CBS_DROPDOWN + LTEXT "Pal : 0",IDC_PALNUM,3,21,25,8 + SCROLLBAR IDC_SCROLLER,30,18,20,14, SBS_HORZ + CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,60,18,75,14 + PUSHBUTTON "&Fermer",IDC_FERMER,35,149,50,14 +END + +IDD_TILE DIALOG DISCARDABLE 0, 0, 446, 180 +STYLE WS_SYSMENU +CAPTION "TILE VIEW" +FONT 8, "MS Sans Serif" +BEGIN + COMBOBOX IDC_PAL_SELECT, 4, 13, 90, 14, WS_TABSTOP | CBS_DROPDOWN + LTEXT "Pal : 0",IDC_PALNUM,4,31,25,8 + SCROLLBAR IDC_SCROLLER,30,28,20,14, SBS_HORZ + COMBOBOX IDC_MEM_SELECT, 4, 50, 90, 14, WS_TABSTOP | CBS_DROPDOWN + CONTROL "Bitmap",IDC_BITMAP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,4,68,35,10 + CONTROL "256 couleurs",IDC_256COUL,"Button",BS_AUTORADIOBUTTON,4,80,55,10 + CONTROL "16 couleurs",IDC_16COUL,"Button",BS_AUTORADIOBUTTON,4,92,50,10 + CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,369,164,75,14 + CONTROL "Edit", IDC_Tile_BOX,"TileViewBox",WS_TABSTOP ,100,2,344,160,WS_EX_CLIENTEDGE + CONTROL "Edit", IDC_MINI_TILE,"MiniTileViewBox",WS_TABSTOP ,22,116,56,52,WS_EX_CLIENTEDGE + LTEXT "Tile num : 0",IDC_TILENUM,23,170,100,8 + PUSHBUTTON "&Fermer",IDC_FERMER,198,164,50,14 +END + +IDD_MAP DIALOG DISCARDABLE 0, 0, 485, 320 +STYLE WS_SYSMENU +CAPTION "MAP VIEW" +FONT 8, "MS Sans Serif" +BEGIN + COMBOBOX IDC_BG_SELECT, 4, 4, 90, 14, WS_TABSTOP | CBS_DROPDOWN + LTEXT "Mode :",IDC_STATIC,4,20,45,8 + LTEXT "Palette :",IDC_STATIC,4,30,45,8 + LTEXT "Prio :",IDC_STATIC,4,40,45,8 + LTEXT "Char base :",IDC_STATIC,4,50,45,8 + LTEXT "Screen base :",IDC_STATIC,4,60,45,8 + LTEXT "Size :",IDC_STATIC,4,70,45,8 + LTEXT "Scroll :",IDC_STATIC,4,80,45,8 + LTEXT "",IDC_MODE,48,20,85,8 + LTEXT "",IDC_PAL,48,30,85,8 + LTEXT "",IDC_PRIO,48,40,85,8 + LTEXT "",IDC_CHAR,48,50,85,8 + LTEXT "",IDC_SCR,48,60,85,8 + LTEXT "",IDC_MSIZE,48,70,85,8 + LTEXT "",IDC_SCROLL,48,80,85,8 +// CONTROL "Edit", IDC_MAP_BOX,"MapViewBox",WS_TABSTOP | WS_VSCROLL | WS_HSCROLL,4,16,296,150,WS_EX_CLIENTEDGE + PUSHBUTTON "&Fermer",IDC_FERMER,4,300,50,14 +END + +IDD_OAM DIALOG DISCARDABLE 0, 0, 300, 200//150, 150 +STYLE WS_SYSMENU +CAPTION "OAM Viewer" +FONT 8, "MS Sans Serif" +BEGIN + COMBOBOX IDC_SCR_SELECT, 4, 4, 90, 14, WS_TABSTOP | CBS_DROPDOWN + SCROLLBAR IDC_SCROLLER,48,20,20,14, SBS_HORZ + LTEXT "Mode :",IDC_STATIC,4,36,45,8 + LTEXT "Tile :",IDC_STATIC,4,46,45,8 + LTEXT "Palette :",IDC_STATIC,4,56,45,8 + LTEXT "Prio :",IDC_STATIC,4,66,45,8 + LTEXT "Coordonnées :",IDC_STATIC,4,76,45,8 + LTEXT "Dimensions :",IDC_STATIC,4,86,45,8 + LTEXT "Rotation :",IDC_STATIC,4,96,45,8 + LTEXT "Mosaic :",IDC_STATIC,4,106,45,8 + LTEXT "OAM : 0",IDC_OAMNUM,4,24,40,8 + LTEXT "",IDC_MODE,48,36,42,8 + LTEXT "",IDC_TILE,48,46,72,8 + LTEXT "",IDC_PAL,48,56,72,8 + LTEXT "",IDC_PRIO,48,66,72,8 + LTEXT "",IDC_COOR,48,76,42,8 + LTEXT "",IDC_DIM,48,86,42,8 + LTEXT "",IDC_ROT,48,96,42,8 + LTEXT "",IDC_MOS,48,106,42,8 + LTEXT "",IDC_PROP0,4,116,86,8 + LTEXT "",IDC_PROP1,4,126,86,8 +// CONTROL "Edit", IDC_OAM_BOX,"OAMViewBox",WS_TABSTOP,100,50,45,42,WS_EX_CLIENTEDGE + PUSHBUTTON "&Fermer",IDC_FERMER,50,134,50,14 +END + +// ENGLISH /////////////////////////////////////////////////////////////////// + +LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US + +MENU_PRINCIPAL MENU +{ + POPUP "&File" + { + MENUITEM "&Open", IDM_OPEN + MENUITEM "Rom &Info", IDM_GAME_INFO + MENUITEM SEPARATOR + MENUITEM "Save State As", IDM_STATE_SAVE + MENUITEM "Load State As", IDM_STATE_LOAD + POPUP "Save State" + { + MENUITEM "1", IDM_STATE_SAVE_F1 + MENUITEM "2", IDM_STATE_SAVE_F2 + MENUITEM "3", IDM_STATE_SAVE_F3 + MENUITEM "4", IDM_STATE_SAVE_F4 + MENUITEM "5", IDM_STATE_SAVE_F5 + MENUITEM "6", IDM_STATE_SAVE_F6 + MENUITEM "7", IDM_STATE_SAVE_F7 + MENUITEM "8", IDM_STATE_SAVE_F8 + MENUITEM "9", IDM_STATE_SAVE_F9 + MENUITEM "10", IDM_STATE_SAVE_F10 + } + POPUP "Load State" + { + MENUITEM "1", IDM_STATE_LOAD_F1 + MENUITEM "2", IDM_STATE_LOAD_F2 + MENUITEM "3", IDM_STATE_LOAD_F3 + MENUITEM "4", IDM_STATE_LOAD_F4 + MENUITEM "5", IDM_STATE_LOAD_F5 + MENUITEM "6", IDM_STATE_LOAD_F6 + MENUITEM "7", IDM_STATE_LOAD_F7 + MENUITEM "8", IDM_STATE_LOAD_F8 + MENUITEM "9", IDM_STATE_LOAD_F9 + MENUITEM "10", IDM_STATE_LOAD_F10 + } + MENUITEM SEPARATOR + MENUITEM "Save Screenshot &As", IDM_PRINTSCREEN + MENUITEM "&Quick Screenshot", IDM_QUICK_PRINTSCREEN + MENUITEM SEPARATOR + MENUITEM "&Quit", IDM_QUIT + } + POPUP "&Emulation" + { + MENUITEM "&Execute", IDM_EXEC + MENUITEM "&Pause", IDM_PAUSE + MENUITEM "&Reset", IDM_RESET + } + POPUP "&Config" + { + POPUP "&Save Type" + { + MENUITEM "Autodetect", IDC_SAVETYPE1 + MENUITEM "EEPROM 4kbit", IDC_SAVETYPE2 + MENUITEM "EEPROM 64kbit", IDC_SAVETYPE3 + MENUITEM "EEPROM 512kbit", IDC_SAVETYPE4 + MENUITEM "FRAM 256kbit", IDC_SAVETYPE5 + MENUITEM "FLASH 2mbit", IDC_SAVETYPE6 + } + MENUITEM "Control Config", IDM_CONFIG + MENUITEM "Sound Settings", IDM_SOUNDSETTINGS + POPUP "&Frame Skip" + { + MENUITEM "Auto", IDC_FRAMESKIPAUTO + MENUITEM "0", IDC_FRAMESKIP0 + MENUITEM "1", IDC_FRAMESKIP1 + MENUITEM "2", IDC_FRAMESKIP2 + MENUITEM "3", IDC_FRAMESKIP3 + MENUITEM "4", IDC_FRAMESKIP4 + MENUITEM "5", IDC_FRAMESKIP5 + MENUITEM "6", IDC_FRAMESKIP6 + MENUITEM "7", IDC_FRAMESKIP7 + MENUITEM "8", IDC_FRAMESKIP8 + MENUITEM "9", IDC_FRAMESKIP9 + } + } + POPUP "&Tools" + { + MENUITEM "&Disassembler", IDM_DISASSEMBLER + MENUITEM "View &Memory", IDM_MEMORY + MENUITEM "View &Registers", IDM_IOREG +// MENUITEM "View Log", IDM_LOG + MENUITEM "View &Palette", IDM_PAL + MENUITEM "View &Tiles", IDM_TILE + MENUITEM "View M&aps", IDM_MAP + MENUITEM "View &OAM", IDM_OAM + MENUITEM SEPARATOR + POPUP "&View &Layers" + { + MENUITEM "Main BG 0", IDM_MBG0, CHECKED + MENUITEM "Main BG 1", IDM_MBG1, CHECKED + MENUITEM "Main BG 2", IDM_MBG2, CHECKED + MENUITEM "Main BG 3", IDM_MBG3, CHECKED + MENUITEM SEPARATOR + MENUITEM "Sub BG 0", IDM_SBG0, CHECKED + MENUITEM "Sub BG 1", IDM_SBG1, CHECKED + MENUITEM "Sub BG 2", IDM_SBG2, CHECKED + MENUITEM "Sub BG 3", IDM_SBG3, CHECKED + } + } + POPUP "&Help" + { + MENUITEM "&Website", IDM_WEBSITE + MENUITEM "&Forums", IDM_FORUM + MENUITEM "&Submit a bug report", IDM_SUBMITBUGREPORT + } +} + +IDD_CONFIG DIALOG DISCARDABLE 0, 0, 125, 227 +STYLE DS_MODALFRAME | DS_SETFOREGROUND | WS_POPUP | WS_CAPTION +CAPTION "Configure Keys" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDC_FERMER,67,208,50,14 + PUSHBUTTON "Default",IDC_BUTTON1,7,208,50,14 + COMBOBOX IDC_COMBO1,46,13,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "Up:",IDC_STATIC,17,14,27,10 + COMBOBOX IDC_COMBO4,46,29,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "Down:",IDC_STATIC,17,31,28,9 + COMBOBOX IDC_COMBO2,46,45,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "Left:",IDC_STATIC,17,47,28,9 + COMBOBOX IDC_COMBO3,46,61,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "Right:",IDC_STATIC,17,63,28,9 + COMBOBOX IDC_COMBO7,46,77,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "A:",IDC_STATIC,18,78,28,9 + COMBOBOX IDC_COMBO8,46,92,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "B:",IDC_STATIC,17,94,28,9 + COMBOBOX IDC_COMBO10,46,108,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "L:",IDC_STATIC,17,110,28,9 + COMBOBOX IDC_COMBO11,46,124,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "R:",IDC_STATIC,17,126,28,9 + COMBOBOX IDC_COMBO6,46,140,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "X:",IDC_STATIC,17,142,28,9 + COMBOBOX IDC_COMBO5,46,156,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "Y:",IDC_STATIC,17,158,28,9 + GROUPBOX "",IDC_STATIC,7,3,111,203 + COMBOBOX IDC_COMBO9,46,172,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "Start:",IDC_STATIC,17,174,28,9 + COMBOBOX IDC_COMBO12,46,188,59,14,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "Select:",IDC_STATIC,17,190,28,9 +END + +IDD_MEM_VIEWER DIALOG DISCARDABLE 0, 0, 428, 178 +STYLE WS_SYSMENU +CAPTION "View Memory" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "8 bit",IDC_8_BIT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,29,10 + CONTROL "16 bit",IDC_16_BIT,"Button",BS_AUTORADIOBUTTON,44,4,33,10 + CONTROL "32 bit",IDC_32_BIT,"Button",BS_AUTORADIOBUTTON,82,4,33,10 + LTEXT "Go to:",IDC_STATIC,130,4,33,10 + EDITTEXT IDC_GOTOMEM,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP + PUSHBUTTON "&GO",IDC_GO,240,1,20,14 + CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,350,1,75,14 + CONTROL "Edit", IDC_MEM_BOX,"MemViewBox",WS_TABSTOP | WS_VSCROLL,4,16,424,142,WS_EX_CLIENTEDGE + PUSHBUTTON "&Close",IDC_FERMER,185,162,50,14 +END + +IDD_DESASSEMBLEUR_VIEWER DIALOG DISCARDABLE 0, 0, 380, 186 +STYLE WS_SYSMENU +CAPTION "Disassembler" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Auto ",IDC_AUTO_DES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,35,10 + CONTROL "ARM",IDC_ARM,"Button",BS_AUTORADIOBUTTON,44,4,35,10 + CONTROL "Thumb",IDC_THUMB,"Button",BS_AUTORADIOBUTTON,82,4,40,10 + LTEXT "Go to:",IDC_STATIC,130,4,33,10 + EDITTEXT IDC_GOTODES,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | + ES_WANTRETURN | WS_GROUP + PUSHBUTTON "&GO",IDC_GO,240,1,20,14 + CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,300,1,75,14 + CONTROL "Edit", IDC_DES_BOX,"DesViewBox",WS_TABSTOP | WS_VSCROLL,4,16,296,150,WS_EX_CLIENTEDGE + PUSHBUTTON "&Close",IDC_FERMER,185,170,50,14 + EDITTEXT IDC_SETPNUM,5,170,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | WS_GROUP | ES_NUMBER + PUSHBUTTON "&Step",IDC_STEP,75,170,50,14 + LTEXT "R0 :",IDC_STATIC,304,16,17,8 + LTEXT "R1 :",IDC_STATIC,304,24,17,8 + LTEXT "R2 :",IDC_STATIC,304,32,17,8 + LTEXT "R3 :",IDC_STATIC,304,40,17,8 + LTEXT "R4 :",IDC_STATIC,304,48,17,8 + LTEXT "R5 :",IDC_STATIC,304,56,17,8 + LTEXT "R6 :",IDC_STATIC,304,64,17,8 + LTEXT "R7 :",IDC_STATIC,304,72,17,8 + LTEXT "R8 :",IDC_STATIC,304,80,17,8 + LTEXT "R9 :",IDC_STATIC,304,88,17,8 + LTEXT "R10 :",IDC_STATIC,304,96,17,8 + LTEXT "R11 :",IDC_STATIC,304,104,17,8 + LTEXT "R12 :",IDC_STATIC,304,112,17,8 + LTEXT "SP :",IDC_STATIC,304,120,17,8 + LTEXT "LR :",IDC_STATIC,304,128,17,8 + LTEXT "PC :",IDC_STATIC,304,136,17,8 + LTEXT "Mode :",IDC_STATIC,304,158,22,8 + LTEXT "SPSR :",IDC_STATIC,304,168,22,8 + LTEXT "00000000",IDC_R0,325,16,40,8 + LTEXT "00000000",IDC_R1,325,24,40,8 + LTEXT "00000000",IDC_R2,325,32,40,8 + LTEXT "00000000",IDC_R3,325,40,40,8 + LTEXT "00000000",IDC_R4,325,48,40,8 + LTEXT "00000000",IDC_R5,325,56,40,8 + LTEXT "00000000",IDC_R6,325,64,40,8 + LTEXT "00000000",IDC_R7,325,72,40,8 + LTEXT "00000000",IDC_R8,325,80,40,8 + LTEXT "00000000",IDC_R9,325,88,40,8 + LTEXT "00000000",IDC_R10,325,96,40,8 + LTEXT "00000000",IDC_R11,325,104,40,8 + LTEXT "00000000",IDC_R12,325,112,40,8 + LTEXT "00000000",IDC_R13,325,120,40,8 + LTEXT "00000000",IDC_R14,325,128,40,8 + LTEXT "00000000",IDC_R15,325,136,40,8 + LTEXT "",IDC_MODE,327,158,28,8 + LTEXT "",IDC_TMP,327,168,40,8 +END + +IDD_GAME_INFO DIALOG DISCARDABLE 0, 0, 150, 150 +STYLE WS_VISIBLE | WS_SYSMENU +CAPTION "ROM Info" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "&Close",IDC_FERMER,50,134,50,14 + LTEXT "Name of Game :",IDC_STATIC,4,4,51,8 + LTEXT "Code :",IDC_STATIC,4,12,51,8 + LTEXT "Manufacturer :",IDC_STATIC,4,20,51,8 + LTEXT "Size :",IDC_STATIC,4,28,51,8 + LTEXT "ARM9 Size :",IDC_STATIC,4,36,51,8 + LTEXT "ARM7 Size :",IDC_STATIC,4,44,51,8 + LTEXT "Data :",IDC_STATIC,4,52,51,8 + LTEXT "",IDC_NOM_JEU,60,4,100,8 + LTEXT "",IDC_CDE,60,12,100,8 + LTEXT "",IDC_FAB,60,20,100,8 + LTEXT "",IDC_TAILLE,60,28,100,8 + LTEXT "",IDC_ARM9_T,60,36,100,8 + LTEXT "",IDC_ARM7_T,60,44,100,8 + LTEXT "",IDC_DATA,60,52,100,8 +END + +IDD_IO_REG DIALOG DISCARDABLE 0, 0, 150, 150 +STYLE WS_SYSMENU +CAPTION "IO REG" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "&Close",IDC_FERMER,50,134,50,14 + LTEXT "Int Handler :",IDC_STATIC,4,4,41,8 + LTEXT "IE :",IDC_STATIC,4,12,41,8 + LTEXT "IME :",IDC_STATIC,4,20,41,8 + LTEXT "DISPCNT :",IDC_STATIC,4,28,41,8 + LTEXT "DISPSTAT :",IDC_STATIC,4,36,41,8 + LTEXT "IPCSYNC :",IDC_STATIC,4,44,41,8 + LTEXT "IPCFIFO :",IDC_STATIC,4,52,41,8 + LTEXT "",IDC_INTHAND,45,4,100,8 + LTEXT "",IDC_IE,45,12,130,8 + LTEXT "",IDC_IME,45,20,130,8 + LTEXT "",IDC_DISPCNT,45,28,130,8 + LTEXT "",IDC_DISPSTAT,45,36,130,8 + LTEXT "",IDC_IPCSYNC,45,44,130,8 + LTEXT "",IDC_IPCFIFO,45,52,130,8 +END + +IDD_LOG DIALOG DISCARDABLE 0, 0, 300, 300 +STYLE WS_SYSMENU +CAPTION "Log" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Edit", IDC_LOG,"LogView",WS_TABSTOP | WS_VSCROLL,4,4,292,280,WS_EX_CLIENTEDGE + PUSHBUTTON "&Close",IDC_FERMER,125,285,50,14 +END + +IDD_PAL DIALOG DISCARDABLE 0, 0, 120, 165 +STYLE WS_SYSMENU +CAPTION "PAL VIEW" +FONT 8, "MS Sans Serif" +BEGIN + COMBOBOX IDC_PAL_SELECT, 15, 3, 90, 14, WS_TABSTOP | CBS_DROPDOWN + LTEXT "Pal : 0",IDC_PALNUM,3,21,25,8 + SCROLLBAR IDC_SCROLLER,30,18,20,14, SBS_HORZ + CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,60,18,75,14 + PUSHBUTTON "&Close",IDC_FERMER,35,149,50,14 +END + +IDD_TILE DIALOG DISCARDABLE 0, 0, 446, 180 +STYLE WS_SYSMENU +CAPTION "TILE VIEW" +FONT 8, "MS Sans Serif" +BEGIN + COMBOBOX IDC_PAL_SELECT, 4, 13, 90, 14, WS_TABSTOP | CBS_DROPDOWN + LTEXT "Pal : 0",IDC_PALNUM,4,31,25,8 + SCROLLBAR IDC_SCROLLER,30,28,20,14, SBS_HORZ + COMBOBOX IDC_MEM_SELECT, 4, 50, 90, 14, WS_TABSTOP | CBS_DROPDOWN + CONTROL "Bitmap",IDC_BITMAP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,4,68,35,10 + CONTROL "256 colors",IDC_256COUL,"Button",BS_AUTORADIOBUTTON,4,80,55,10 + CONTROL "16 colors",IDC_16COUL,"Button",BS_AUTORADIOBUTTON,4,92,50,10 + CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,369,164,75,14 + CONTROL "Edit", IDC_Tile_BOX,"TileViewBox",WS_TABSTOP ,100,2,344,160,WS_EX_CLIENTEDGE + CONTROL "Edit", IDC_MINI_TILE,"MiniTileViewBox",WS_TABSTOP ,22,116,56,52,WS_EX_CLIENTEDGE + LTEXT "Tile num : 0",IDC_TILENUM,23,170,100,8 + PUSHBUTTON "&Close",IDC_FERMER,198,164,50,14 +END + +IDD_MAP DIALOG DISCARDABLE 0, 0, 485, 320 +STYLE WS_SYSMENU +CAPTION "MAP VIEW" +FONT 8, "MS Sans Serif" +BEGIN + COMBOBOX IDC_BG_SELECT, 4, 4, 90, 14, WS_TABSTOP | CBS_DROPDOWN + LTEXT "Mode :",IDC_STATIC,4,20,45,8 + LTEXT "Palette :",IDC_STATIC,4,30,45,8 + LTEXT "Prio :",IDC_STATIC,4,40,45,8 + LTEXT "Char base :",IDC_STATIC,4,50,45,8 + LTEXT "Screen base :",IDC_STATIC,4,60,45,8 + LTEXT "Size :",IDC_STATIC,4,70,45,8 + LTEXT "Scroll :",IDC_STATIC,4,80,45,8 + LTEXT "",IDC_MODE,48,20,85,8 + LTEXT "",IDC_PAL,48,30,85,8 + LTEXT "",IDC_PRIO,48,40,85,8 + LTEXT "",IDC_CHAR,48,50,85,8 + LTEXT "",IDC_SCR,48,60,85,8 + LTEXT "",IDC_MSIZE,48,70,85,8 + LTEXT "",IDC_SCROLL,48,80,85,8 +// CONTROL "Edit", IDC_MAP_BOX,"MapViewBox",WS_TABSTOP | WS_VSCROLL | WS_HSCROLL,4,16,296,150,WS_EX_CLIENTEDGE + PUSHBUTTON "&Close",IDC_FERMER,4,300,50,14 +END + +IDD_OAM DIALOG DISCARDABLE 0, 0, 300, 200//150, 150 +STYLE WS_SYSMENU +CAPTION "OAM Viewer" +FONT 8, "MS Sans Serif" +BEGIN + COMBOBOX IDC_SCR_SELECT, 4, 4, 90, 14, WS_TABSTOP | CBS_DROPDOWN + SCROLLBAR IDC_SCROLLER,48,20,20,14, SBS_HORZ + LTEXT "Mode :",IDC_STATIC,4,36,45,8 + LTEXT "Tile :",IDC_STATIC,4,46,45,8 + LTEXT "Palette :",IDC_STATIC,4,56,45,8 + LTEXT "Prio :",IDC_STATIC,4,66,45,8 + LTEXT "Coordinates :",IDC_STATIC,4,76,45,8 + LTEXT "Dimensions :",IDC_STATIC,4,86,45,8 + LTEXT "Rotation :",IDC_STATIC,4,96,45,8 + LTEXT "Mosaic :",IDC_STATIC,4,106,45,8 + LTEXT "OAM : 0",IDC_OAMNUM,4,24,40,8 + LTEXT "",IDC_MODE,48,36,42,8 + LTEXT "",IDC_TILE,48,46,72,8 + LTEXT "",IDC_PAL,48,56,72,8 + LTEXT "",IDC_PRIO,48,66,72,8 + LTEXT "",IDC_COOR,48,76,42,8 + LTEXT "",IDC_DIM,48,86,42,8 + LTEXT "",IDC_ROT,48,96,42,8 + LTEXT "",IDC_MOS,48,106,42,8 + LTEXT "",IDC_PROP0,4,116,86,8 + LTEXT "",IDC_PROP1,4,126,86,8 +// CONTROL "Edit", IDC_OAM_BOX,"OAMViewBox",WS_TABSTOP,100,50,45,42,WS_EX_CLIENTEDGE + PUSHBUTTON "&Close",IDC_FERMER,50,134,50,14 +END + +SOUNDSETTINGSDLG DIALOG DISCARDABLE 0, 0, 174, 96 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Sound Settings" +FONT 8, "MS Sans Serif" +BEGIN + GROUPBOX "Sound Core Settings", -1, 3, 2, 168, 28, WS_CHILD | WS_VISIBLE + LTEXT "Sound Core", -1, 10, 14, 40, 10 + COMBOBOX IDC_SOUNDCORECB, 54, 13, 110, 33, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Other Settings", -1, 3, 31, 168, 43, WS_CHILD | WS_VISIBLE + LTEXT "Buffer Size", -1, 10, 42, 60, 10 + EDITTEXT IDC_SOUNDBUFFERET, 136, 41, 28, 13 + LTEXT "Volume", -1, 10, 57, 30, 10 + CONTROL "", IDC_SLVOLUME, "msctls_trackbar32", WS_VISIBLE | WS_CHILD, 40, 57, 128, 10 + DEFPUSHBUTTON "&OK",IDOK,82,78,40,14 + PUSHBUTTON "&Cancel",IDCANCEL,127,78,40,14 +END + +IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE +BEGIN + VK_F1, IDM_STATE_SAVE_F1, VIRTKEY, SHIFT, NOINVERT + VK_F2, IDM_STATE_SAVE_F2, VIRTKEY, SHIFT, NOINVERT + VK_F3, IDM_STATE_SAVE_F3, VIRTKEY, SHIFT, NOINVERT + VK_F4, IDM_STATE_SAVE_F4, VIRTKEY, SHIFT, NOINVERT + VK_F5, IDM_STATE_SAVE_F5, VIRTKEY, SHIFT, NOINVERT + VK_F6, IDM_STATE_SAVE_F6, VIRTKEY, SHIFT, NOINVERT + VK_F7, IDM_STATE_SAVE_F7, VIRTKEY, SHIFT, NOINVERT + VK_F8, IDM_STATE_SAVE_F8, VIRTKEY, SHIFT, NOINVERT + VK_F9, IDM_STATE_SAVE_F9, VIRTKEY, SHIFT, NOINVERT + VK_F10, IDM_STATE_SAVE_F10, VIRTKEY, SHIFT, NOINVERT + VK_F1, IDM_STATE_LOAD_F1, VIRTKEY, NOINVERT + VK_F2, IDM_STATE_LOAD_F2, VIRTKEY, NOINVERT + VK_F3, IDM_STATE_LOAD_F3, VIRTKEY, NOINVERT + VK_F4, IDM_STATE_LOAD_F4, VIRTKEY, NOINVERT + VK_F5, IDM_STATE_LOAD_F5, VIRTKEY, NOINVERT + VK_F6, IDM_STATE_LOAD_F6, VIRTKEY, NOINVERT + VK_F7, IDM_STATE_LOAD_F7, VIRTKEY, NOINVERT + VK_F8, IDM_STATE_LOAD_F8, VIRTKEY, NOINVERT + VK_F9, IDM_STATE_LOAD_F9, VIRTKEY, NOINVERT + VK_F10, IDM_STATE_LOAD_F10, VIRTKEY, NOINVERT +END + +////////////////////////////////////////////////////////////////////////////// diff --git a/tags/release_0_5_0/desmume/src/windows/snddx.c b/tags/release_0_5_0/desmume/src/windows/snddx.c new file mode 100755 index 000000000..1ab5c45dd --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/snddx.c @@ -0,0 +1,266 @@ +/* Copyright (C) 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. + + 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 +#ifdef __MINGW32__ +// I have to do this because for some reason because the dxerr8.h header is fubared +const char* __stdcall DXGetErrorString8A(HRESULT hr); +#define DXGetErrorString8 DXGetErrorString8A +const char* __stdcall DXGetErrorDescription8A(HRESULT hr); +#define DXGetErrorDescription8 DXGetErrorDescription8A +#else +#include +#endif +#include "../SPU.h" +#include "snddx.h" + +int SNDDXInit(int buffersize); +void SNDDXDeInit(); +void SNDDXUpdateAudio(s16 *buffer, u32 num_samples); +u32 SNDDXGetAudioSpace(); +void SNDDXMuteAudio(); +void SNDDXUnMuteAudio(); +void SNDDXSetVolume(int volume); + +SoundInterface_struct SNDDIRECTX = { +SNDCORE_DIRECTX, +"Direct Sound Interface", +SNDDXInit, +SNDDXDeInit, +SNDDXUpdateAudio, +SNDDXGetAudioSpace, +SNDDXMuteAudio, +SNDDXUnMuteAudio, +SNDDXSetVolume +}; + +LPDIRECTSOUND8 lpDS8; +LPDIRECTSOUNDBUFFER lpDSB, lpDSB2; +extern HWND hwnd; + +static s16 *stereodata16; +static u32 soundoffset=0; +static u32 soundbufsize; +static LONG soundvolume; +static int issoundmuted; + +////////////////////////////////////////////////////////////////////////////// + +int SNDDXInit(int buffersize) +{ + DSBUFFERDESC dsbdesc; + WAVEFORMATEX wfx; + HRESULT ret; + char tempstr[512]; + + if ((ret = DirectSoundCreate8(NULL, &lpDS8, NULL)) != DS_OK) + { + sprintf(tempstr, "DirectSound8Create error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + + if ((ret = IDirectSound8_SetCooperativeLevel(lpDS8, hwnd, DSSCL_PRIORITY)) != DS_OK) + { + sprintf(tempstr, "IDirectSound8_SetCooperativeLevel error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + + memset(&dsbdesc, 0, sizeof(dsbdesc)); + dsbdesc.dwSize = sizeof(DSBUFFERDESC); + dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER; + dsbdesc.dwBufferBytes = 0; + dsbdesc.lpwfxFormat = NULL; + + if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB, NULL)) != DS_OK) + { + sprintf(tempstr, "Error when creating primary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + + soundbufsize = buffersize * 2 * 2; + + memset(&wfx, 0, sizeof(wfx)); + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = (wfx.wBitsPerSample / 8) * wfx.nChannels; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + + if ((ret = IDirectSoundBuffer8_SetFormat(lpDSB, &wfx)) != DS_OK) + { + sprintf(tempstr, "IDirectSoundBuffer8_SetFormat error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + + memset(&dsbdesc, 0, sizeof(dsbdesc)); + dsbdesc.dwSize = sizeof(DSBUFFERDESC); + dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS | + DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | + DSBCAPS_LOCHARDWARE; + dsbdesc.dwBufferBytes = soundbufsize; + dsbdesc.lpwfxFormat = &wfx; + + if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK) + { + if (ret == DSERR_CONTROLUNAVAIL || + ret == DSERR_INVALIDCALL) + { + // Try using a software buffer instead + dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS | + DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | + DSBCAPS_LOCSOFTWARE; + + if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK) + { + sprintf(tempstr, "Error when creating secondary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + } + else + { + sprintf(tempstr, "Error when creating secondary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + } + + IDirectSoundBuffer8_Play(lpDSB2, 0, 0, DSBPLAY_LOOPING); + + if ((stereodata16 = (s16 *)malloc(soundbufsize)) == NULL) + return -1; + + memset(stereodata16, 0, soundbufsize); + + soundvolume = DSBVOLUME_MAX; + issoundmuted = 0; + + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDXDeInit() +{ + DWORD status=0; + + if (lpDSB2) + { + IDirectSoundBuffer8_GetStatus(lpDSB2, &status); + + if(status == DSBSTATUS_PLAYING) + IDirectSoundBuffer8_Stop(lpDSB2); + + IDirectSoundBuffer8_Release(lpDSB2); + lpDSB2 = NULL; + } + + if (lpDSB) + { + IDirectSoundBuffer8_Release(lpDSB); + lpDSB = NULL; + } + + if (lpDS8) + { + IDirectSound8_Release(lpDS8); + lpDS8 = NULL; + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDXUpdateAudio(s16 *buffer, u32 num_samples) +{ + LPVOID buffer1; + LPVOID buffer2; + DWORD buffer1_size, buffer2_size; + DWORD status; + + IDirectSoundBuffer8_GetStatus(lpDSB2, &status); + + if (status & DSBSTATUS_BUFFERLOST) + return; // fix me + + IDirectSoundBuffer8_Lock(lpDSB2, soundoffset, num_samples * sizeof(s16) * 2, &buffer1, &buffer1_size, &buffer2, &buffer2_size, 0); + + memcpy(buffer1, buffer, buffer1_size); + if (buffer2) + memcpy(buffer2, ((u8 *)buffer)+buffer1_size, buffer2_size); + + soundoffset += buffer1_size + buffer2_size; + soundoffset %= soundbufsize; + + IDirectSoundBuffer8_Unlock(lpDSB2, buffer1, buffer1_size, buffer2, buffer2_size); +} + +////////////////////////////////////////////////////////////////////////////// + +u32 SNDDXGetAudioSpace() +{ + DWORD playcursor, writecursor; + u32 freespace=0; + + if (IDirectSoundBuffer8_GetCurrentPosition (lpDSB2, &playcursor, &writecursor) != DS_OK) + return 0; + + if (soundoffset > playcursor) + freespace = soundbufsize - soundoffset + playcursor; + else + freespace = playcursor - soundoffset; + +// if (freespace > 512) + return (freespace / 2 / 2); +// else +// return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDXMuteAudio() +{ + issoundmuted = 1; + IDirectSoundBuffer8_SetVolume (lpDSB2, DSBVOLUME_MIN); +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDXUnMuteAudio() +{ + issoundmuted = 0; + IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume); +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDXSetVolume(int volume) +{ + soundvolume = (((LONG)volume) - 100) * 100; + if (!issoundmuted) + IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume); +} + +////////////////////////////////////////////////////////////////////////////// + diff --git a/tags/release_0_5_0/desmume/src/windows/snddx.h b/tags/release_0_5_0/desmume/src/windows/snddx.h new file mode 100755 index 000000000..bb75bc086 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/snddx.h @@ -0,0 +1,25 @@ +/* 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 SNDDX_H +#define SNDDX_H +#define SNDCORE_DIRECTX 2 + +extern SoundInterface_struct SNDDIRECTX; +#endif diff --git a/tags/release_0_5_0/desmume/src/windows/tileView.c b/tags/release_0_5_0/desmume/src/windows/tileView.c new file mode 100644 index 000000000..5df66a5f0 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/tileView.c @@ -0,0 +1,669 @@ +/* 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 +#include +#include +#include "tileView.h" +#include "resource.h" +#include "../MMU.h" + +LRESULT CALLBACK TileViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK MiniTileViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +////////////////////////////////////////////////////////////////////////////// + +void InitTileViewBox() +{ + WNDCLASSEX wc; + + wc.cbSize = sizeof(wc); + wc.lpszClassName = _T("TileViewBox"); + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = TileViewBoxWndProc; + 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); + + wc.cbSize = sizeof(wc); + wc.lpszClassName = _T("MiniTileViewBox"); + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = MiniTileViewBoxWndProc; + 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 MiniTileViewBox_Paint(tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HWND hwnd_dst = GetDlgItem(win->hwnd, IDC_MINI_TILE); + HWND hwnd_src = GetDlgItem(win->hwnd, IDC_Tile_BOX); + HDC hdc_src; + HDC hdc_dst; + char txt[80]; + + PAINTSTRUCT ps; + + hdc_dst = BeginPaint(hwnd_dst, &ps); + hdc_src = GetDC(hwnd_src); + StretchBlt(hdc_dst, 0, 0, 80, 80, hdc_src, win->x, win->y, 8, 8, SRCCOPY); + sprintf(txt, "Tile num : 0x%X", win->tilenum); + SetWindowText(GetDlgItem(win->hwnd, IDC_TILENUM), txt); + EndPaint(hwnd_dst, &ps); + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT CALLBACK MiniTileViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + tileview_struct * win = (tileview_struct *)GetWindowLong(hwnd, 0); + + switch(msg) + { + case WM_NCCREATE: + return 1; + case WM_NCDESTROY: + return 1; + case WM_PAINT : + MiniTileViewBox_Paint(win, wParam, lParam); + return 1; + case WM_ERASEBKGND: + return 1; + default: + break; + } + + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT TileViewBox_Direct(tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HWND hwnd = GetDlgItem(win->hwnd, IDC_Tile_BOX); + HDC hdc; + PAINTSTRUCT ps; +// SIZE fontsize; +// TCHAR text[80]; + BITMAPV4HEADER bmi; + RECT rect; + HDC mem_dc; + HBITMAP mem_bmp; + int lg; + int ht; + + 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 = -256; + + 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)); + + SetDIBitsToDevice(mem_dc, 0, 0, 256, 256, 0, 0, 0, 256, win->mem, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT TileViewBox_Pal256(tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HWND hwnd = GetDlgItem(win->hwnd, IDC_Tile_BOX); + HDC hdc; + PAINTSTRUCT ps; +// SIZE fontsize; + TCHAR text[80]; + u16 bitmap[256*256]; + u16 * pal = ((u16 *)win->pal) + win->palnum*256; + BITMAPV4HEADER bmi; + RECT rect; + int lg; + int ht; + HDC mem_dc; + HBITMAP mem_bmp; + + 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 = -256; + + 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)); + + if(win->pal) + { + u32 i, num2, num, y, x; + + //for(i = 0; i<256*256; ++i) + // bitmap[i] = pal[win->mem[i]]; + for(num2 = 0; num2<32; ++num2) + for(num = 0; num<32; ++num) + for(y = 0; y<8; ++y) + for(x = 0; x<8; ++x) + bitmap[x + (y*256) + (num*8) +(num2*256*8)] = pal[win->mem[x + (y*8) + (num*64) +(num2*2048)]]; + SetDIBitsToDevice(mem_dc, 0, 0, 256, 256, 0, 0, 0, 256, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + sprintf(text, "Pal : %d", win->palnum); + SetWindowText(GetDlgItem(win->hwnd, IDC_PALNUM), text); + } + else + TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT TileViewBox_Pal16(tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HWND hwnd = GetDlgItem(win->hwnd, IDC_Tile_BOX); + HDC hdc; + PAINTSTRUCT ps; +// SIZE fontsize; + TCHAR text[80]; + u16 bitmap[512*512]; + u16 * pal = ((u16 *)win->pal) + win->palnum*16; + BITMAPV4HEADER bmi; + RECT rect; + int lg; + int ht; + HDC mem_dc; + HBITMAP mem_bmp; + + 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 = 512; + bmi.bV4Height = -256; + + 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, 512, 256); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + if(win->pal) + { + u32 num2, num, y, x; + for(num2 = 0; num2<32; ++num2) + for(num = 0; num<64; ++num) + for(y = 0; y<8; ++y) + for(x = 0; x<4; ++x) + { + bitmap[(x<<1) + (y*512) + (num*8) +(num2*512*8)] = pal[win->mem[x + (y*4) + (num*32) +(num2*2048)]&0xF]; + bitmap[(x<<1)+1 + (y*512) + (num*8) +(num2*512*8)] = pal[win->mem[x + (y*4) + (num*32) +(num2*2048)]>>4]; + } + SetDIBitsToDevice(mem_dc, 0, 0, 512, 256, 0, 0, 0, 256, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + sprintf(text, "Pal : %d", win->palnum); + SetWindowText(GetDlgItem(win->hwnd, IDC_PALNUM), text); + } + else + TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT CALLBACK TileViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + tileview_struct * win = (tileview_struct *)GetWindowLong(hwnd, 0); + + switch(msg) + { + case WM_NCCREATE: + return 1; + case WM_NCDESTROY: + return 1; + case WM_PAINT: + switch(win->coul) + { + case 0 : + TileViewBox_Direct(win, wParam, lParam); + return 1; + case 1 : + TileViewBox_Pal256(win, wParam, lParam); + return 1; + case 2 : + TileViewBox_Pal16(win, wParam, lParam); + return 1; + } + return 1; + case WM_LBUTTONDOWN : + switch(win->coul) + { + case 0 : + case 1 : + if(LOWORD(lParam)<(32*8)) + { + win->x = ((LOWORD(lParam)>>3)<<3); + win->y = (HIWORD(lParam)>>3)<<3; + win->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*32; + } + break; + case 2 : + win->x = ((LOWORD(lParam)>>3)<<3); + win->y = (HIWORD(lParam)>>3)<<3; + win->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*64; + break; + } + InvalidateRect(GetDlgItem(win->hwnd, IDC_MINI_TILE), NULL, FALSE); + UpdateWindow(GetDlgItem(win->hwnd, IDC_MINI_TILE)); + //CWindow_Refresh(win); + return 1; + case WM_ERASEBKGND: + return 1; + default: + break; + } + + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +////////////////////////////////////////////////////////////////////////////// + +BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + tileview_struct * win = (tileview_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); + + combo = GetDlgItem(hwnd, IDC_MEM_SELECT); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6000000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6010000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6020000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6030000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6040000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6050000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6060000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6070000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-BG - 0x6200000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-BG - 0x6210000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6400000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6410000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6420000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6430000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-OBJ- 0x6600000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-OBJ- 0x6610000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6800000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6810000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6820000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6830000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6840000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6850000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6860000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6870000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6880000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6890000"); + SendMessage(combo, CB_SETCURSEL, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_BITMAP), BM_SETCHECK, TRUE, 0); + } + return 1; + case WM_CLOSE : + CWindow_RemoveFromRefreshList(win); + TileView_Deinit(win); + EndDialog(hwnd, 0); + 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); + TileView_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_BITMAP : + win->coul = 0; + CWindow_Refresh(win); + return 1; + case IDC_256COUL : + win->coul = 1; + CWindow_Refresh(win); + return 1; + case IDC_16COUL : + win->coul = 2; + CWindow_Refresh(win); + return 1; + case IDC_MEM_SELECT : + switch(HIWORD(wParam)) + { + case CBN_CLOSEUP : + { + u32 sel = SendMessage(GetDlgItem(hwnd, IDC_MEM_SELECT), CB_GETCURSEL, 0, 0); + switch(sel) + { + case 0 : + case 1 : + case 2 : + case 3 : + case 4 : + case 5 : + case 6 : + case 7 : + win->mem = ARM9Mem.ARM9_ABG + 0x10000*sel; + break; + case 8 : + case 9 : + win->mem = ARM9Mem.ARM9_BBG + 0x10000*(sel-8); + break; + case 10 : + case 11 : + case 12 : + case 13 : + win->mem = ARM9Mem.ARM9_AOBJ + 0x10000*(sel-10); + break; + case 14 : + case 15 : + win->mem = ARM9Mem.ARM9_BOBJ + 0x10000*(sel-14); + break; + case 16 : + case 17 : + case 18 : + case 19 : + case 20 : + case 21 : + case 22 : + case 23 : + case 24 : + case 25 : + win->mem = ARM9Mem.ARM9_LCD + 0x10000*(sel-16); + break; + default : + return 1; + } + CWindow_Refresh(win); + return 1; + } + } + 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->pal = (u16 *)ARM9Mem.ARM9_VMEM; + win->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + case 1 : + win->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200; + win->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + case 2 : + win->pal = (u16 *)ARM9Mem.ARM9_VMEM + 0x100; + win->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + case 3 : + win->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; + win->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + case 4 : + case 5 : + case 6 : + case 7 : + win->pal = ((u16 *)(ARM9Mem.ExtPal[0][sel-4])); + win->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), FALSE); + if(win->coul == 2) + { + SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); + SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); + win->coul = 1; + } + break; + case 8 : + case 9 : + case 10 : + case 11 : + win->pal = ((u16 *)(ARM9Mem.ExtPal[1][sel-8])); + win->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), FALSE); + if(win->coul == 2) + { + SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); + SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); + win->coul = 1; + } + break; + case 12 : + case 13 : + win->pal = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12])); + win->palnum = 0; + if(win->coul == 2) + { + SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); + SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); + win->coul = 1; + } + break; + case 14 : + case 15 : + win->pal = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14])); + win->palnum = 0; + if(win->coul == 2) + { + SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); + SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); + win->coul = 1; + } + break; + case 16 : + case 17 : + case 18 : + case 19 : + win->pal = ((u16 *)(ARM9Mem.texPalSlot[sel-16])); + win->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + default : + return 1; + } + CWindow_Refresh(win); + return 1; + } + } + } + return 0; + } + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +tileview_struct *TileView_Init(HINSTANCE hInst, HWND parent) +{ + tileview_struct *TileView=NULL; + + if ((TileView = (tileview_struct *)malloc(sizeof(tileview_struct))) == NULL) + return TileView; + + if (CWindow_Init2(TileView, hInst, parent, "Tile viewer", IDD_TILE, TileView_Proc) != 0) + { + free(TileView); + return NULL; + } + + TileView->mem = ARM9Mem.ARM9_ABG; + TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM); + TileView->palnum = 0; + TileView->coul = 0; + TileView->x = 0; + TileView->y = 0; + + SetWindowLong(GetDlgItem(TileView->hwnd, IDC_Tile_BOX), 0, (LONG)TileView); + SetWindowLong(GetDlgItem(TileView->hwnd, IDC_MINI_TILE), 0, (LONG)TileView); + + return TileView; +} + +////////////////////////////////////////////////////////////////////////////// + +void TileView_Deinit(tileview_struct *TileView) +{ + if (TileView) + free(TileView); +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/tags/release_0_5_0/desmume/src/windows/tileView.h b/tags/release_0_5_0/desmume/src/windows/tileView.h new file mode 100644 index 000000000..b3deaa95b --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/tileView.h @@ -0,0 +1,50 @@ +/* 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 TILEVIEW_H +#define TILEVIEW_H + +#include "CWindow.h" + +typedef struct +{ + HWND hwnd; + BOOL autoup; + void *prev; + void *next; + void *first; + void (*Refresh)(void *win); + + u8 * mem; + u16 * pal; + s16 palnum; + u16 tilenum; + u8 coul; + u32 x; + u32 y; +} tileview_struct; + + +void InitTileViewBox(); +tileview_struct *TileView_Init(HINSTANCE hInst, HWND parent); +void TileView_Deinit(tileview_struct *TileView); + +#endif diff --git a/tags/release_0_5_0/desmume/src/windows/yopyop_private.h b/tags/release_0_5_0/desmume/src/windows/yopyop_private.h new file mode 100644 index 000000000..190988a5a --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/yopyop_private.h @@ -0,0 +1,23 @@ +/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ +/* DO NOT EDIT ! */ + +#ifndef YOPYOP_PRIVATE_H +#define YOPYOP_PRIVATE_H + +/* VERSION DEFINITIONS */ +#define VER_STRING "0.0.0.1" +#define VER_MAJOR 0 +#define VER_MINOR 0 +#define VER_RELEASE 0 +#define VER_BUILD 1 +#define COMPANY_NAME "yopyop" +#define FILE_VERSION "" +#define FILE_DESCRIPTION "NDS(tm) emulator" +#define INTERNAL_NAME "" +#define LEGAL_COPYRIGHT "" +#define LEGAL_TRADEMARKS "" +#define ORIGINAL_FILENAME "" +#define PRODUCT_NAME "DeSmuME" +#define PRODUCT_VERSION "" + +#endif /*YOPYOP_PRIVATE_H*/ diff --git a/tags/release_0_5_0/desmume/src/windows/yopyop_private.rc b/tags/release_0_5_0/desmume/src/windows/yopyop_private.rc new file mode 100644 index 000000000..8b02076f7 --- /dev/null +++ b/tags/release_0_5_0/desmume/src/windows/yopyop_private.rc @@ -0,0 +1,45 @@ +/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ +/* DO NOT EDIT! */ + +#include // include for version info constants + +#include "resources.rc" + +A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "DeSmuME.ico" + +// +// SUPPORT FOR WINDOWS XP THEMES: +// THIS WILL MAKE THE PROGRAM USE THE COMMON CONTROLS +// LIBRARY VERSION 6.0 (IF IT IS AVAILABLE) +// +1 24 "DeSmuME.exe.Manifest" + +// +// TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS... +// +1 VERSIONINFO +FILEVERSION 0,0,3,4 +PRODUCTVERSION 0,0,3,4 +FILETYPE VFT_APP +{ + BLOCK "StringFileInfo" + { + BLOCK "140904E4" + { + VALUE "CompanyName", "yopyop" + VALUE "FileVersion", "" + VALUE "FileDescription", "NDS(tm) emulator" + VALUE "InternalName", "" + VALUE "LegalCopyright", "" + VALUE "LegalTrademarks", "" + VALUE "OriginalFilename", "" + VALUE "ProductName", "DeSmuME" + VALUE "ProductVersion", "" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x1409, 1252 + } +} +